mirror of
https://github.com/SleepingInsomniac/pixelfaucet
synced 2025-01-24 07:58:18 +01:00
21 lines
475 B
Crystal
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
|