Class: Ground
- Inherits:
-
Object
- Object
- Ground
- Defined in:
- lib/games_and_rpg_paradise/games/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
# === height ========================================================================= #.
- #hide? ⇒ Boolean
-
#initialize(window) ⇒ Ground
constructor
# === initialize ========================================================================= #.
-
#load_image(window) ⇒ Object
# === load_image ========================================================================= #.
- #reset ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(window) ⇒ Ground
#
initialize
#
23 24 25 26 27 28 29 30 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/ground.rb', line 23 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_and_rpg_paradise/games/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_and_rpg_paradise/games/flappy_bird/gosu/ground.rb', line 9 def y @y end |
Instance Method Details
#draw ⇒ Object
37 38 39 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/ground.rb', line 37 def draw @ground_image.draw(@x, @y, 5) end |
#height ⇒ Object
#
height
#
57 58 59 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/ground.rb', line 57 def height @ground_image.height end |
#hide? ⇒ Boolean
46 47 48 49 50 51 52 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/ground.rb', line 46 def hide? if @x + (@ground_image.width / 2) < 0 true else false end end |
#load_image(window) ⇒ Object
#
load_image
#
14 15 16 17 18 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/ground.rb', line 14 def load_image(window) @ground_image ||= Gosu::Image.new( GamesAndRpgParadise.image_directory?+'flappy_bird/ground.png' ) end |
#reset ⇒ Object
32 33 34 35 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/ground.rb', line 32 def reset @x = 0 @y = @window.height - @ground_image.height end |
#update ⇒ Object
41 42 43 44 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/ground.rb', line 41 def update @x -= 2 reset if hide? end |