Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

22 lines (18 sloc) 0.358 kb
class Energy
attr_reader :level
def initialize
@level = 100
@tank = Sprite.new :tank
@energy = Sprite.new :energy
end
def hit(value)
@level -= value
@level = 0 if @level < 0
end
def draw_on(surface, x, y)
surface.draw(@tank, x, y)
@level.times do |i|
surface.draw(@energy, x + i + 3, y + 3)
end
end
end
Jump to Line
Something went wrong with that request. Please try again.