naming convention for most stuff but not all

This commit is contained in:
lustlion
2022-03-04 23:28:30 +01:00
parent c978855711
commit cef2096577
29 changed files with 354 additions and 436 deletions

View File

@@ -1,8 +1,8 @@
Particle = Entity:New()
Particle = Entity:new()
LoadedObjects.Particles = {}
function Particle:New(x,y,particle_data)
local o = Entity:New(x,y)
function Particle:new(x,y,particle_data)
local o = Entity:new(x,y)
o.pos = {x = x, y = y}
@@ -29,17 +29,17 @@ function Particle:New(x,y,particle_data)
o.speed_increase = particle_data.speed_increase or 0
if particle_data.light ~= nil then
o.lightRange = particle_data.light
o.light_range = particle_data.light
local flicker = particle_data.light_flicker or nil
local color = particle_data.light_color or nil
o.light = Light:New(o.pos.x,o.pos.y,o.lightRange,flicker,color)
o.light = Light:new(o.pos.x,o.pos.y,o.light_range,flicker,color)
end
-- animations
if particle_data.animation ~= nil then
o.body = Animation:New(particle_data.animation)
o.body = Animation:new(particle_data.animation)
o:centerOffset(o.body)
o:getBoundingBox(o.body)
o:createBox(o.body)
if not o.animation_active then
o.body.speed = 0
end
@@ -53,9 +53,9 @@ function Particle:New(x,y,particle_data)
return o
end
function Particle:Kill()
function Particle:kill()
if self.light ~= nil then
self.light:Kill()
self.light:kill()
end
if self.id ~= nil then
for _, e in pairs(LoadedObjects.Particles) do
@@ -68,21 +68,21 @@ function Particle:Kill()
self = nil
end
function Particle:HandleAnimation()
function Particle:handleAnimation()
self.timer = self.timer + current_dt
self.sprite_alpha = self.sprite_alpha_base*(self.time-self.timer)/self.time
if self.light ~= nil then
self:LightAdjust()
self.light.range = self.lightRange * self.sprite_alpha/2
self:adjustLight()
self.light.range = self.light_range * self.sprite_alpha/2
end
if self.sprite_alpha < 0 then self:Kill() end
if self.sprite_alpha < 0 then self:kill() end
if self.body ~= nil then
self.body:Animate()
self:Draw(self.body)
self.body:animate()
self:draw(self.body)
end
end
function Particle:DoPhysics()
function Particle:doPhysics()
-- adjust speed
if self.speed_increase ~= 0 then
self.speed = self.speed + self.speed_increase
@@ -90,10 +90,10 @@ function Particle:DoPhysics()
self.vel.y = self.speed * math.sin(self.direction)
end
-- move
self:CollisionMove()
self:moveWithCollision()
end
function Particle:Debug()
function Particle:debug()
-- draw center CYAN
love.graphics.setColor(0,1,1)
love.graphics.circle("fill", -Camera.pos.x + self.pos.x, -Camera.pos.y + self.pos.y, 1)