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(level) ⇒ Hoop
constructor
A new instance of Hoop.
- #miss(player) ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(level) ⇒ Hoop
Returns a new instance of Hoop.
73 74 75 76 77 78 79 80 |
# File 'lib/rubyhop.rb', line 73 def initialize level @level = level @window = @level.window @hoop = Gosu::Image.new @window, get_my_file("hoop.png") # center of screen @x = @y = 0 @active = true end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
72 73 74 |
# File 'lib/rubyhop.rb', line 72 def active @active end |
#x ⇒ Object
Returns the value of attribute x.
72 73 74 |
# File 'lib/rubyhop.rb', line 72 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
72 73 74 |
# File 'lib/rubyhop.rb', line 72 def y @y end |
Instance Method Details
#draw ⇒ Object
92 93 94 |
# File 'lib/rubyhop.rb', line 92 def draw @hoop.draw @x - 66, @y - 98, 1000 - @x end |
#miss(player) ⇒ Object
81 82 83 84 85 86 87 88 |
# File 'lib/rubyhop.rb', line 81 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
89 90 91 |
# File 'lib/rubyhop.rb', line 89 def update @x -= @level.movement end |