Class: Logic::Pipe

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

Constant Summary collapse

DEFAULTS =
{ width: 52, height: 250 }.freeze

Instance Attribute Summary collapse

Attributes inherited from BaseLogic

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

Instance Method Summary collapse

Constructor Details

#initialize(**attrs) ⇒ Pipe

initialize



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

def initialize(**attrs)
  super(width: 52, height: 250, x: attrs[:x], y: attrs[:y])
  @position = attrs[:position]
  @scored = false
end

Instance Attribute Details

#positionObject

Returns the value of attribute position.



15
16
17
# File 'lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/logic/pipe.rb', line 15

def position
  @position
end

Instance Method Details

#scored!Object

scored!



30
31
32
# File 'lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/logic/pipe.rb', line 30

def scored!
  @scored = true
end

#top?Boolean

top?

Returns:

  • (Boolean)


25
26
27
# File 'lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/logic/pipe.rb', line 25

def top?
  position == :top
end

#unscored!Object



34
35
36
# File 'lib/games_and_rpg_paradise/games/flappy_bird/ruby2d/logic/pipe.rb', line 34

def unscored!
  @scored = false
end

#unscored?Boolean

Returns:

  • (Boolean)


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

def unscored?
  @scored == false
end