Class: Rubygoal::Gui::Ball

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygoal/gui/ball.rb

Constant Summary collapse

IMAGE_SIZE =
20

Instance Method Summary collapse

Constructor Details

#initialize(window, ball) ⇒ Ball



7
8
9
10
11
12
# File 'lib/rubygoal/gui/ball.rb', line 7

def initialize(window, ball)
  @ball = ball

  image_path = File.dirname(__FILE__) + '/../../../media/ball.png'
  @image = Gosu::Image.new(window, image_path, false)
end

Instance Method Details

#drawObject



14
15
16
17
18
19
20
# File 'lib/rubygoal/gui/ball.rb', line 14

def draw
  half_side_lenght = IMAGE_SIZE / 2
  image_center_x = ball.position.x - half_side_lenght
  image_center_y = ball.position.y - half_side_lenght

  image.draw(image_center_x, image_center_y, 1)
end