mirror of
https://gitlab.com/MaddoScientisto/cirnofarm.git
synced 2026-06-11 20:35:55 +00:00
Converted particles to actors
This commit is contained in:
parent
47e9d613dc
commit
c390096f4f
2 changed files with 39 additions and 30 deletions
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue