Class: Hoop

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyhop/hoop.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHoop

Returns a new instance of Hoop.



3
4
5
6
7
8
# File 'lib/rubyhop/hoop.rb', line 3

def initialize
  @hoop  = Rubyhop.image "hoop.png"
  # center of screen
  @x = @y = 0
  @active = true
end

Instance Attribute Details

#activeObject

Returns the value of attribute active.



2
3
4
# File 'lib/rubyhop/hoop.rb', line 2

def active
  @active
end

#xObject

Returns the value of attribute x.



2
3
4
# File 'lib/rubyhop/hoop.rb', line 2

def x
  @x
end

#yObject

Returns the value of attribute y.



2
3
4
# File 'lib/rubyhop/hoop.rb', line 2

def y
  @y
end

Instance Method Details

#drawObject



20
21
22
# File 'lib/rubyhop/hoop.rb', line 20

def draw
  @hoop.draw @x - 66, @y - 98, 1000 - @x
end

#miss(player) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/rubyhop/hoop.rb', line 9

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(movement) ⇒ Object



17
18
19
# File 'lib/rubyhop/hoop.rb', line 17

def update movement
  @x -= movement
end