Class: DemoState

Inherits:
PlayState show all
Defined in:
lib/game_states/demo_state.rb

Instance Attribute Summary collapse

Attributes inherited from PlayState

#object_pool, #update_interval

Instance Method Summary collapse

Methods inherited from PlayState

#initialize, #leave

Methods inherited from GameState

#leave, #needs_redraw?, switch

Constructor Details

This class inherits a constructor from PlayState

Instance Attribute Details

#tankObject

Returns the value of attribute tank.



2
3
4
# File 'lib/game_states/demo_state.rb', line 2

def tank
  @tank
end

Instance Method Details

#button_down(id) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/game_states/demo_state.rb', line 19

def button_down(id)
  super
  if id == Gosu::KbSpace
    target_tank = @tanks.reject do |t|
      t == @camera.target
    end.sample
    switch_to_tank(target_tank)
  end
end

#drawObject



14
15
16
17
# File 'lib/game_states/demo_state.rb', line 14

def draw
  super
  @score_display.draw_top_right
end

#enterObject



4
5
6
# File 'lib/game_states/demo_state.rb', line 4

def enter
  # Prevent reactivating HUD
end

#updateObject



8
9
10
11
12
# File 'lib/game_states/demo_state.rb', line 8

def update
  super
  @score_display = ScoreDisplay.new(
    object_pool, 20)
end