pixelfaucet/src/particle.cr
2022-01-03 20:55:39 -05:00

21 lines
475 B
Crystal

require "./entity"
require "./entity/entity_age"
module PF
class Particle < Entity
include EntityAge
def update(dt : Float64)
update_age(dt)
return if dead?
super(dt)
end
def draw(engine)
return if dead?
brightness = ((((@lifespan - @age) / @lifespan) * 255) / 2).to_u8
color = Pixel.new(r: brightness, g: brightness, b: brightness)
engine.draw_point(@position.x.to_i, @position.y.to_i, color)
end
end
end