Class: APanzer::Game
- Inherits:
-
Object
- Object
- APanzer::Game
- Defined in:
- lib/a_panzer.rb
Constant Summary collapse
- PANZER =
[]
Instance Method Summary collapse
- #animate ⇒ Object
- #board ⇒ Object
-
#initialize ⇒ Game
constructor
A new instance of Game.
- #move(x) ⇒ Object
- #moving? ⇒ Boolean
- #pew? ⇒ Boolean
- #shoot ⇒ Object
Constructor Details
#initialize ⇒ Game
Returns a new instance of Game.
35 36 37 38 39 40 |
# File 'lib/a_panzer.rb', line 35 def initialize @position = 0 @sprite = 0 @pew = false @moving = false end |
Instance Method Details
#animate ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/a_panzer.rb', line 65 def animate if @pew @sprite += 1 @sprite %= PANZER.size @pew = false if @sprite == 0 elsif @moving @position += @moving @moving = false if @position == 0 end end |
#board ⇒ Object
42 43 44 |
# File 'lib/a_panzer.rb', line 42 def board PANZER[@sprite].split("\n").map { |l| "#{" " * @position}#{l}" } end |
#move(x) ⇒ Object
54 55 56 57 58 |
# File 'lib/a_panzer.rb', line 54 def move(x) return if @pew @moving = x animate end |
#moving? ⇒ Boolean
50 51 52 |
# File 'lib/a_panzer.rb', line 50 def moving? @moving end |
#pew? ⇒ Boolean
46 47 48 |
# File 'lib/a_panzer.rb', line 46 def pew? @pew end |
#shoot ⇒ Object
60 61 62 63 |
# File 'lib/a_panzer.rb', line 60 def shoot @pew = true animate end |