Game Development Reference
In-Depth Information
And one more fancy font will make our game title look good. Too bad we don't have a title
yet, but “Tanks Prototype” writen in a thematic way still looks pretty good.
To have convenient access to these fonts, we will add a helper methods in Utils :
module Utils
# ...
def self . title_font
media_path( 'top_secret.ttf' )
end
def self . main_font
media_path( 'armalite_rifle.ttf' )
end
# ...
end
Use it instead of Gosu.default_font_name :
size = 20
Gosu :: Image . from_text( $window , "Your text" , Utils . main_font, size)
Implementing HUD Class
After we have put everything together, we will get HUD class:
12-stats/entities/hud.rb
1 class HUD
2 attr_accessor :active
3 def initialize (object_pool, tank)
4 @object_pool = object_pool
5 @tank = tank
6 @radar = Radar . new( @object_pool , tank)
7 end
8
9 def player = (tank)
10 @tank = tank
11 @radar . target = tank
12 end
13
14 def update
15 @radar . update
16 end
17
18 def health_image
Search WWH ::




Custom Search