Game Development Reference
In-Depth Information
65 if @active
66 @object_pool . camera . draw_crosshair
67 end
68 @radar . draw
69 offset = 20
70 health_image . draw( 20 , offset, 1000 )
71 stats_image . draw( 20 , offset += 30 , 1000 )
72 if fire_rate_image
73 fire_rate_image . draw( 20 , offset += 30 , 1000 )
74 end
75 if speed_image
76 speed_image . draw( 20 , offset += 30 , 1000 )
77 end
78 end
79 end
To use it, we need to hook into PlayState :
class PlayState < GameState
# ...
def initialize
# ...
@hud = HUD . new( @object_pool , @tank )
end
def update
# ...
@hud . update
end
def draw
# ...
@hud . draw
end
# ...
end
Assuming you have mocked @tank.input.stats.kills in HUD , you should get a
neat view showing interesting things in top-left corner of the screen:
Search WWH ::




Custom Search