Class: WallFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/games_and_rpg_paradise/games/flappy_bird/gosu/wallfactory.rb

Overview

#

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(window) ⇒ WallFactory

#

initialize

#


13
14
15
16
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wallfactory.rb', line 13

def initialize(window)
  @window = window
  reset
end

Instance Attribute Details

#xObject

Returns the value of attribute x.



7
8
9
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wallfactory.rb', line 7

def x
  @x
end

#yObject

Returns the value of attribute y.



8
9
10
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wallfactory.rb', line 8

def y
  @y
end

Instance Method Details

#addObject

#

add

Add a 2 walls separate by a standard height

#


41
42
43
44
45
46
47
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wallfactory.rb', line 41

def add
  wall_down = Wall.new(@window, 'down')
  wall_up   = Wall.new(@window, 'up')
  wall_up.y = wall_down.y - wall_up.height - @offset_y
  @window.entities.push(wall_down, wall_up)
  @window.walls.push(wall_down, wall_up)
end

#drawObject

#

draw

#


52
53
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wallfactory.rb', line 52

def draw
end

#resetObject

#

reset (reset tag)

#


21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wallfactory.rb', line 21

def reset
  # ======================================================================= #
  # === @counter
  # ======================================================================= #
  @counter = 0
  # ======================================================================= #
  # === @offset_y
  # ======================================================================= #
  @offset_y = 100
  # ======================================================================= #
  # === @intervall
  # ======================================================================= #
  @intervall = 175
end

#updateObject

#

update

Add a wall for each intervall

#


60
61
62
63
64
65
66
67
# File 'lib/games_and_rpg_paradise/games/flappy_bird/gosu/wallfactory.rb', line 60

def update
  if @counter >= @intervall
    add
    @counter = 0
  else
    @counter += 1
  end
end