Class: Wall
- Inherits:
-
Object
- Object
- Wall
- Defined in:
- lib/games_and_rpg_paradise/games/flappy_bird/gosu/wall.rb
Overview
#
Constant Summary collapse
- IMAGE_DIRECTORY =
GamesParadise.image_directory?
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
- #height ⇒ Object
- #hide? ⇒ Boolean
-
#initialize(window, type) ⇒ Wall
constructor
# === initialize ========================================================================= #.
-
#load_image(window, type) ⇒ Object
# === load_image ========================================================================= #.
-
#score?(other) ⇒ Boolean
# === score? ========================================================================= #.
-
#update ⇒ Object
# === update ========================================================================= #.
- #width ⇒ Object
Constructor Details
#initialize(window, type) ⇒ Wall
#
initialize
#
28 29 30 31 32 33 34 35 36 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wall.rb', line 28 def initialize(window, type) @active = true @offset_y = 25 @wall_image = load_image(window, type) @type = type @window = window @x = @window.width @y = @window.height - @window.ground_height - Random.new.rand(@offset_y..@wall_image.height ) end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
9 10 11 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wall.rb', line 9 def active @active end |
#x ⇒ Object
Returns the value of attribute x.
9 10 11 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wall.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/wall.rb', line 9 def y @y end |
Instance Method Details
#draw ⇒ Object
38 39 40 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wall.rb', line 38 def draw @wall_image.draw(@x, @y, 1) end |
#height ⇒ Object
69 70 71 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wall.rb', line 69 def height @wall_image.height end |
#hide? ⇒ Boolean
61 62 63 64 65 66 67 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wall.rb', line 61 def hide? if @x + (@wall_image.width) < 0 true else false end end |
#load_image(window, type) ⇒ Object
#
load_image
#
16 17 18 19 20 21 22 23 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wall.rb', line 16 def load_image(window,type) case type when 'up' @wall_image = Gosu::Image.new(IMAGE_DIRECTORY+'flappy_bird/wall_up.png') when 'down' @wall_image = Gosu::Image.new(IMAGE_DIRECTORY+'flappy_bird/wall_down.png') end end |
#score?(other) ⇒ Boolean
#
score?
#
52 53 54 55 56 57 58 59 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wall.rb', line 52 def score?(other) if @x + @wall_image.width < other.x @active = false true else false end end |
#update ⇒ Object
#
update
#
45 46 47 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wall.rb', line 45 def update @x -= 2 end |
#width ⇒ Object
73 74 75 |
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wall.rb', line 73 def width @wall_image.width end |