Class: Ground
- Inherits:
-
Object
- Object
- Ground
- Defined in:
- lib/games_paradise/flappy_bird/gosu/ground.rb
Overview
#
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #draw ⇒ Object
- #height ⇒ Object
- #hide? ⇒ Boolean
-
#initialize(window) ⇒ Ground
constructor
A new instance of Ground.
-
#load_image(window) ⇒ Object
load_image.
- #reset ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(window) ⇒ Ground
Returns a new instance of Ground.
16 17 18 19 20 21 22 23 |
# File 'lib/games_paradise/flappy_bird/gosu/ground.rb', line 16 def initialize(window) @ground_image = load_image(window) @window = window @x = 0 @y = @window.height - @ground_image.height reset end |
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x.
9 10 11 |
# File 'lib/games_paradise/flappy_bird/gosu/ground.rb', line 9 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
9 10 11 |
# File 'lib/games_paradise/flappy_bird/gosu/ground.rb', line 9 def y @y end |
Instance Method Details
#draw ⇒ Object
30 31 32 |
# File 'lib/games_paradise/flappy_bird/gosu/ground.rb', line 30 def draw @ground_image.draw(@x, @y, 5) end |
#height ⇒ Object
47 48 49 |
# File 'lib/games_paradise/flappy_bird/gosu/ground.rb', line 47 def height @ground_image.height end |
#hide? ⇒ Boolean
39 40 41 42 43 44 45 |
# File 'lib/games_paradise/flappy_bird/gosu/ground.rb', line 39 def hide? if @x + (@ground_image.width / 2) < 0 true else false end end |
#load_image(window) ⇒ Object
load_image
12 13 14 |
# File 'lib/games_paradise/flappy_bird/gosu/ground.rb', line 12 def load_image(window) @ground_image ||= Gosu::Image.new(GamesParadise.image_directory?+'flappy_bird/ground.png') end |
#reset ⇒ Object
25 26 27 28 |
# File 'lib/games_paradise/flappy_bird/gosu/ground.rb', line 25 def reset @x = 0 @y = @window.height - @ground_image.height end |
#update ⇒ Object
34 35 36 37 |
# File 'lib/games_paradise/flappy_bird/gosu/ground.rb', line 34 def update @x -= 2 reset if hide? end |