Game Development Reference
In-Depth Information
28
29
private
30
31 def create_tanks (amount)
32
@map . spawn_points(amount * 3 )
@tanks = []
33
amount . times do | i |
34
@tanks << Tank . new( @object_pool , AiInput . new(
35
@names . random, @object_pool ))
36
37 end
38 target_tank = @tanks . sample
39 @hud = HUD . new( @object_pool , target_tank)
40 @hud . active = false
41 switch_to_tank(target_tank)
42 end
43
44 def switch_to_tank (tank)
45 @camera . target = tank
46 @hud . player = tank
47 self . tank = tank
48 end
49 end
To have a possibility to enter DemoState , we need to change MenuState a little:
class MenuState < GameState
# ...
def update
text = "Q: Quit \n N: New Game \n D: Demo"
# ...
end
# ...
def button_down ( id )
# ...
if id == Gosu :: KbD
@play_state = DemoState . new
GameState . switch( @play_state )
end
end
end
Now, main menu has the option to enter demo state:
Search WWH ::




Custom Search