Hexadecimal colors, particle data, cleaned a bit of entities, added player dash animation particles
This commit is contained in:
@@ -16,7 +16,7 @@ Arrow = Entity:New(x,y)
|
||||
|
||||
-- animations
|
||||
o.body = Animation:New(animation.kupo.arrow)
|
||||
|
||||
|
||||
table.insert(LoadedEntities,o)
|
||||
o.id = #LoadedEntities
|
||||
|
||||
@@ -25,10 +25,6 @@ Arrow = Entity:New(x,y)
|
||||
return o
|
||||
end
|
||||
|
||||
function Arrow:Smart()
|
||||
|
||||
end
|
||||
|
||||
function Arrow:HandleAnimation()
|
||||
self:Draw(self.body)
|
||||
end
|
||||
|
||||
@@ -23,9 +23,6 @@ function Decoration:New(x,y,animation,lightRange)
|
||||
return o
|
||||
end
|
||||
|
||||
function Decoration:Smart()
|
||||
end
|
||||
|
||||
function Decoration:HandleAnimation()
|
||||
self.body:Animate()
|
||||
self:Draw(self.body)
|
||||
|
||||
@@ -42,7 +42,14 @@ function Fairy:Smart()
|
||||
self.vel.x = math.cos(angle)*self.speed*distance/(8*game.scale)
|
||||
self.vel.y = math.sin(angle)*self.speed*distance/(8*game.scale)
|
||||
end
|
||||
Particle:New(self.pos.x,self.pos.y,animation.particle.fairy,angle-math.rad(180),self.speed*distance/(16*game.scale))
|
||||
|
||||
local particle_data = {
|
||||
animation = animation.particle.fairy,
|
||||
direction = angle-math.rad(180),
|
||||
speed = self.speed*distance/(16*game.scale)
|
||||
}
|
||||
|
||||
Particle:New(self.pos.x,self.pos.y,particle_data)
|
||||
end
|
||||
|
||||
function Fairy:HandleAnimation()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -122,7 +122,19 @@ function Player:DoPhysics()
|
||||
self.isOnGround = false
|
||||
|
||||
self.dashTimer = self.dashTimer - current_dt
|
||||
|
||||
-- DASH STATE
|
||||
if self.dashTimer > 0 then
|
||||
|
||||
local particle_data = {
|
||||
animation = self.body,
|
||||
sprite_tint = HEX2RGB("#fed100"),
|
||||
sprite_flip = {
|
||||
x = self.sprite_flip.x,
|
||||
y = self.sprite_flip.y
|
||||
}
|
||||
}
|
||||
Particle:New(self.pos.x,self.pos.y,particle_data)
|
||||
self.dashCooldownTimer = self.dashCooldownTime
|
||||
self.vel.x = self.dashSpeed * math.cos(self.dashDirection)
|
||||
self.vel.y = self.dashSpeed * math.sin(self.dashDirection)
|
||||
@@ -149,11 +161,6 @@ function Player:DoPhysics()
|
||||
end
|
||||
|
||||
function Player:HandleAnimation()
|
||||
if self.dashTimer > 0 then
|
||||
self.sprite_tint = {1,1,0}
|
||||
else
|
||||
self.sprite_tint = {1,1,1}
|
||||
end
|
||||
-- flip sprite to look in the direction is moving
|
||||
if self.move_x ~= 0 then self.sprite_flip.x = math.sign(self.move_x) end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user