Hexadecimal colors, particle data, cleaned a bit of entities, added player dash animation particles

This commit is contained in:
lustlion
2022-01-20 00:53:59 +01:00
parent d96d5dd56d
commit ccc059f40d
15 changed files with 149 additions and 456 deletions

View File

@@ -1,33 +1,55 @@
Particle = Entity:New(x,y)
function Particle:New(x,y,animation,rotation,speed)
function Particle:New(x,y,particle_data)
local o = Entity:New(x,y)
o.pos = {x = x, y = y}
o.speed = speed or 0
o.sprite_rotation = rotation or 0
o.speed = particle_data.speed or 0
o.direction = particle_data.direction or o.direction
o.sprite_rotation = particle_data.sprite_rotation or o.sprite_rotation
o.sprite_offset = particle_data.sprite_offset or o.sprite_offset
o.sprite_scale = particle_data.sprite_scale or o.sprite_scale
o.sprite_tint = particle_data.sprite_tint or o.sprite_tint
o.sprite_alpha = particle_data.sprite_alpha or o.sprite_alpha
o.sprite_flip = particle_data.sprite_flip or o.sprite_flip
o.animation_active = particle_data.animation_active or false
o.time = 0.5
o.timer = 0
o.vel = {
x = o.speed * math.cos(o.sprite_rotation),
y = o.speed * math.sin(o.sprite_rotation)
x = o.speed * math.cos(o.direction),
y = o.speed * math.sin(o.direction)
}
-- animations
o.body = Animation:New(animation)
table.insert(LoadedEntities,o)
o.id = #LoadedEntities
o.body = Animation:New(particle_data.animation)
o:centerOffset(o.body)
if not o.animation_active then
o.body.speed = 0
end
table.insert(LoadedParticles,o)
o.id = #LoadedParticles
setmetatable(o, self)
self.__index = self
return o
end
function Particle:Smart()
function Particle:Kill()
if self.id ~= nil then
for _, e in pairs(LoadedParticles) do
if e.id > self.id then
e.id = e.id - 1
end
end
table.remove(LoadedParticles,self.id)
end
self = nil
end
function Particle:HandleAnimation()