Game Development Reference
In-Depth Information
def initialize ( name , object_pool)
super ( nil )
@object_pool = object_pool
@name = name
@last_update = Gosu . milliseconds
end
# ...
def draw (viewport)
@motion . draw(viewport)
@gun . draw(viewport)
@name_image ||= Gosu :: Image . from_text(
$window , @name , Gosu . default_font_name, 20 )
@name_image . draw(
x - @name_image . width / 2 - 1 ,
y + object . graphics . height / 2 , 100 ,
1 , 1 , Gosu :: Color :: WHITE )
@name_image . draw(
x - @name_image . width / 2 ,
y + object . graphics . height / 2 , 100 ,
1 , 1 , NAME_COLOR )
end
# ...
end
We can see that generic Input class can be easily extracted, but let's follow the Rule of
three and not do premature refactoring.
Instead, run the game and enjoy dying from a bunch of mad clowns.
Identity makes a difference
Search WWH ::




Custom Search