diff --git a/src/game.lua b/src/game.lua index 2cb3762..bd90d2d 100644 --- a/src/game.lua +++ b/src/game.lua @@ -69,6 +69,10 @@ function _update() cirno.update() weapons_manager.update() + + for b in all(actors) do + b:update() + end end LAYERS = { diff --git a/src/weapons.lua b/src/weapons.lua index c30b1e8..88ddd8f 100644 --- a/src/weapons.lua +++ b/src/weapons.lua @@ -1,12 +1,13 @@ --[[pod_format="raw",created="2024-04-24 07:17:14",modified="2024-04-24 20:33:05",revision=11]] local map_manager = require(make_path("map")) +local Actor = require(make_path("actor2")) --local actor = require("actor2") M = {} local weapons = {} local bullets = {} -local particles = {} +-- local particles = {} weapon = { name = "Ice Blaster", @@ -17,30 +18,34 @@ weapon = { } -particle = { - x=0, - y=0, - life=4, - spriteIndex=81 -} -particle.__index = particle -function particle:new(x,y) - local o = setmetatable({}, particle) - o.x=x - o.y=y - return o -end +Particle = Actor:new() +Particle.life=4 +Particle.spriteIndex=81 -function particle:update() +-- particle = { +-- x=0, +-- y=0, +-- life=4, +-- spriteIndex=81 +-- } +--particle.__index = particle +-- function Particle:new(x,y) +-- local o = setmetatable({}, particle) +-- o.x=x +-- o.y=y +-- return o +-- end + +function Particle:update() self.life-=1 - if self.life<0 then - del(particles,self) + if self.life<=0 then + del(actors,self) end end -function particle:draw() - spr(self.spriteIndex,self.x,self.y) -end +-- function Particle:draw() +-- spr(self.spriteIndex,self.x,self.y) +-- end bullet = { x=0, @@ -65,9 +70,9 @@ end function bullet:destroy() -- Create particle - local p = particle:new(self.x, self.y) + local p = Particle:new(self.x, self.y) - add(particles, p) + add(actors, p) del(bullets,self) end @@ -150,9 +155,9 @@ function M.draw() b:draw() end - for p in all(particles) do - p:draw() - end + -- for p in all(particles) do + -- p:draw() + -- end end function M.update() @@ -160,13 +165,13 @@ function M.update() b:update() end - for p in all(particles) do - p:update() - end + -- for p in all(particles) do + -- p:update() + -- end end function M.debug_draw() - print(string.format("Bullets: %d Particles: %d", count(bullets), count(particles)), 0,32,1) + print(string.format("Bullets: %d", count(bullets)), 0,32,1) end return M \ No newline at end of file