Class: Logic::Bird

Inherits:
BaseLogic show all
Defined in:
lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/logic/bird.rb

Instance Attribute Summary collapse

Attributes inherited from BaseLogic

#:game, #game, #height, #width, #x, #y

Instance Method Summary collapse

Constructor Details

#initialize(game:) ⇒ Bird

#

initialize

#


18
19
20
21
# File 'lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/logic/bird.rb', line 18

def initialize(game:)
  super(game: game, width: 34, height: 24)
  reset!
end

Instance Attribute Details

#accelerationObject (readonly)

Returns the value of attribute acceleration.



13
14
15
# File 'lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/logic/bird.rb', line 13

def acceleration
  @acceleration
end

#speedObject (readonly)

Returns the value of attribute speed.



13
14
15
# File 'lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/logic/bird.rb', line 13

def speed
  @speed
end

Instance Method Details

#fly!Object

#

fly!

#


37
38
39
40
# File 'lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/logic/bird.rb', line 37

def fly!
  @acceleration = -3.5
  @speed = 0
end

#move!Object

#

move!

#


45
46
47
48
# File 'lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/logic/bird.rb', line 45

def move!
  started? ? apply_gravity! : float!
  self.y += @speed
end

#reset!Object

#

reset

#


26
27
28
29
30
31
32
# File 'lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/logic/bird.rb', line 26

def reset!
  @x = 106
  @y = 243
  @speed = 0
  @flight = 0
  @acceleration = 0
end