class RubyMan::Hud
Game overlay showing number of lives and score
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/ruby_man/GameObjects/hud.rb, line 7 def initialize super @text = ResourceManager['text_normal'] @life_sprite = ResourceManager['rubyman'] end
Public Instance Methods
draw()
click to toggle source
# File lib/ruby_man/GameObjects/hud.rb, line 13 def draw y_offset = 608 @text.draw("Score: #{@game.score}", 8, y_offset + 2, 0) x_offset = 160 lives_text = 'Lives: ' @text.draw(lives_text, x_offset, y_offset + 2, 0) x_offset += @text.text_width(lives_text) @game.lives.times do @life_sprite.draw(x_offset + 2, y_offset) x_offset += @life_sprite.width end end