class DemoState

Attributes

tank[RW]

Public Instance Methods

button_down(id) click to toggle source
Calls superclass method PlayState#button_down
# 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
draw() click to toggle source
Calls superclass method PlayState#draw
# File lib/game_states/demo_state.rb, line 14
def draw
  super
  @score_display.draw_top_right
end
enter() click to toggle source
# File lib/game_states/demo_state.rb, line 4
def enter
  # Prevent reactivating HUD
end
update() click to toggle source
Calls superclass method PlayState#update
# File lib/game_states/demo_state.rb, line 8
def update
  super
  @score_display = ScoreDisplay.new(
    object_pool, 20)
end

Private Instance Methods

create_tanks(amount) click to toggle source
# File lib/game_states/demo_state.rb, line 31
def create_tanks(amount)
  @map.spawn_points(amount * 3)
  @tanks = []
  amount.times do |i|
    @tanks << Tank.new(@object_pool, AiInput.new(
      @names.random, @object_pool))
  end
  target_tank = @tanks.sample
  @hud = HUD.new(@object_pool, target_tank)
  @hud.active = false
  switch_to_tank(target_tank)
end
switch_to_tank(tank) click to toggle source
# File lib/game_states/demo_state.rb, line 44
def switch_to_tank(tank)
  @camera.target = tank
  @hud.player = tank
  self.tank = tank
end