Class: Hoop
- Inherits:
-
Object
- Object
- Hoop
- Defined in:
- lib/rubyhop.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(window) ⇒ Hoop
constructor
A new instance of Hoop.
- #miss(player) ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(window) ⇒ Hoop
Returns a new instance of Hoop.
69 70 71 72 73 74 75 76 |
# File 'lib/rubyhop.rb', line 69 def initialize window @window = window @hoop = Gosu::Image.new window, get_my_file("hoop.png") # center of screen @movement = 2 @x = @y = 0 @active = true end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
68 69 70 |
# File 'lib/rubyhop.rb', line 68 def active @active end |
#x ⇒ Object
Returns the value of attribute x.
68 69 70 |
# File 'lib/rubyhop.rb', line 68 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
68 69 70 |
# File 'lib/rubyhop.rb', line 68 def y @y end |
Instance Method Details
#draw ⇒ Object
89 90 91 |
# File 'lib/rubyhop.rb', line 89 def draw @hoop.draw @x - 66, @y - 98, 1000 - @x end |
#miss(player) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/rubyhop.rb', line 77 def miss player if (@x - player.x).abs < 12 && (@y - player.y).abs > 72 # the player missed the hoop return true end false end |
#update ⇒ Object
85 86 87 88 |
# File 'lib/rubyhop.rb', line 85 def update @movement += 0.003 @x -= @movement end |