Game Development Reference
In-Depth Information
end
def create_stats_image (stats)
# ...
@stats_image = Gosu :: Image . from_text(
$window , text, Utils . main_font, @font_size )
end
# ...
def draw_top_right
@stats_image . draw(
$window . width - @stats_image . width - 20 ,
20 ,
1000 )
end
end
And here is the extended DemoState :
13-advanced-ai/game_states/demo_state.rb
1 class DemoState < PlayState
2
attr_accessor :tank
3
4 def enter
5 # Prevent reactivating HUD
6 end
7
8 def update
9 super
10
@score_display = ScoreDisplay . new(
object_pool, 20 )
11
12 end
13
14 def draw
15 super
16 @score_display . draw_top_right
17 end
18
19 def button_down ( id )
20 super
21 if id == Gosu :: KbSpace
22 target_tank = @tanks . reject do | t |
23 t == @camera . target
24 end . sample
25 switch_to_tank(target_tank)
26 end
27 end
Search WWH ::




Custom Search