Class: Rubygoal::Gui::Ball
- Inherits:
-
Object
- Object
- Rubygoal::Gui::Ball
- Defined in:
- lib/rubygoal/gui/ball.rb
Constant Summary collapse
- IMAGE_SIZE =
20
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(window, ball) ⇒ Ball
constructor
A new instance of Ball.
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
#draw ⇒ Object
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 |