Class: Wall
- Inherits:
-
Object
- Object
- Wall
- Defined in:
- lib/games_paradise/flappy_bird/gosu/wall.rb
Overview
#
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
A new instance of Wall.
-
#load_image(window, type) ⇒ Object
load_image.
- #score?(other) ⇒ Boolean
- #update ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(window, type) ⇒ Wall
Returns a new instance of Wall.
20 21 22 23 24 25 26 27 28 |
# File 'lib/games_paradise/flappy_bird/gosu/wall.rb', line 20 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_paradise/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_paradise/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_paradise/flappy_bird/gosu/wall.rb', line 9 def y @y end |
Instance Method Details
#draw ⇒ Object
30 31 32 |
# File 'lib/games_paradise/flappy_bird/gosu/wall.rb', line 30 def draw @wall_image.draw(@x, @y, 1) end |
#height ⇒ Object
55 56 57 |
# File 'lib/games_paradise/flappy_bird/gosu/wall.rb', line 55 def height @wall_image.height end |
#hide? ⇒ Boolean
47 48 49 50 51 52 53 |
# File 'lib/games_paradise/flappy_bird/gosu/wall.rb', line 47 def hide? if @x + (@wall_image.width) < 0 true else false end end |
#load_image(window, type) ⇒ Object
load_image
12 13 14 15 16 17 18 |
# File 'lib/games_paradise/flappy_bird/gosu/wall.rb', line 12 def load_image(window,type) if type == 'up' @wall_image = Gosu::Image.new(GamesParadise.image_directory?+'flappy_bird/wall_up.png') elsif type == 'down' @wall_image = Gosu::Image.new(GamesParadise.image_directory?+'flappy_bird/wall_down.png') end end |
#score?(other) ⇒ Boolean
38 39 40 41 42 43 44 45 |
# File 'lib/games_paradise/flappy_bird/gosu/wall.rb', line 38 def score?(other) if @x + @wall_image.width < other.x @active = false true else false end end |
#update ⇒ Object
34 35 36 |
# File 'lib/games_paradise/flappy_bird/gosu/wall.rb', line 34 def update @x -= 2 end |
#width ⇒ Object
59 60 61 |
# File 'lib/games_paradise/flappy_bird/gosu/wall.rb', line 59 def width @wall_image.width end |