mirror of
https://gitlab.com/MaddoScientisto/cirnofarm.git
synced 2026-06-22 19:43:55 +00:00
Added constructors
This commit is contained in:
parent
81a8c11823
commit
3cc9f26674
2 changed files with 18 additions and 67 deletions
|
|
@ -16,6 +16,12 @@ local Cirno = MovableActor:new()
|
||||||
Cirno.spriteIndex = 65
|
Cirno.spriteIndex = 65
|
||||||
Cirno.crosshair_index=82
|
Cirno.crosshair_index=82
|
||||||
|
|
||||||
|
function Cirno:new(x,y)
|
||||||
|
local obj = Actor:new(x,y)
|
||||||
|
|
||||||
|
return setmetatable(obj, {__index=self})
|
||||||
|
end
|
||||||
|
|
||||||
function Cirno:update()
|
function Cirno:update()
|
||||||
if (btn(0)) self.move_x -= self.speed self.hflip = true
|
if (btn(0)) self.move_x -= self.speed self.hflip = true
|
||||||
if (btn(1)) self.move_x += self.speed self.hflip = false
|
if (btn(1)) self.move_x += self.speed self.hflip = false
|
||||||
|
|
|
||||||
|
|
@ -14,27 +14,12 @@ weapon = {
|
||||||
shoot=function(self)
|
shoot=function(self)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Particle = Actor:new()
|
Particle = Actor:new()
|
||||||
Particle.life=4
|
Particle.life=4
|
||||||
Particle.spriteIndex=81
|
Particle.spriteIndex=81
|
||||||
|
|
||||||
-- 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()
|
function Particle:update()
|
||||||
self.life-=1
|
self.life-=1
|
||||||
if self.life<=0 then
|
if self.life<=0 then
|
||||||
|
|
@ -51,30 +36,21 @@ Bullet = Actor:new()
|
||||||
--function Bullet:new()
|
--function Bullet:new()
|
||||||
--
|
--
|
||||||
--end
|
--end
|
||||||
Bullet.dx=0
|
--Bullet.dx=0
|
||||||
Bullet.dy=0
|
--Bullet.dy=0
|
||||||
Bullet.spriteIndex = 80
|
Bullet.spriteIndex = 80
|
||||||
Bullet.damage=1
|
Bullet.damage=1
|
||||||
|
|
||||||
-- bullet = {
|
function Bullet:new(x,y,dir_x,dir_y)
|
||||||
-- x=0,
|
local obj = Actor:new(x,y)
|
||||||
-- y=0,
|
|
||||||
-- dx=0,
|
obj.dx = dir_x
|
||||||
-- dy=0,
|
obj.dy = dir_y
|
||||||
-- spriteIndex=80,
|
|
||||||
-- destroy_sprite_index=66,
|
-- 'obj' has 'Actor' as a prototype at the moment
|
||||||
-- life=100,
|
-- which isn't what we want so we just change it.
|
||||||
-- damage=1,
|
return setmetatable(obj, {__index=self})
|
||||||
-- }
|
end
|
||||||
-- bullet.__index = bullet
|
|
||||||
-- function bullet:new(x, y, dx, dy)
|
|
||||||
-- local o = setmetatable({}, bullet)
|
|
||||||
-- o.x = x
|
|
||||||
-- o.y = y
|
|
||||||
-- o.dx = dx
|
|
||||||
-- o.dy = dy
|
|
||||||
-- return o
|
|
||||||
-- end
|
|
||||||
|
|
||||||
function Bullet:destroy()
|
function Bullet:destroy()
|
||||||
|
|
||||||
|
|
@ -125,37 +101,6 @@ function M.create_bullet(new_x, new_y, dir_x, dir_y)
|
||||||
|
|
||||||
add(bullets, b)
|
add(bullets, b)
|
||||||
|
|
||||||
-- add(bullets, {
|
|
||||||
-- x=new_x,
|
|
||||||
-- y=new_y,
|
|
||||||
-- dx=normalized_dir_x * 2,
|
|
||||||
-- dy=normalized_dir_y * 2,
|
|
||||||
-- spriteIndex=80,
|
|
||||||
-- destroy_sprite_index=66,
|
|
||||||
-- life=100,
|
|
||||||
-- damage=1,
|
|
||||||
-- draw=function(self)
|
|
||||||
-- --pset(self.x,self.y,8)
|
|
||||||
-- spr(self.spriteIndex,self.x,self.y)
|
|
||||||
-- end,
|
|
||||||
-- update=function(self)
|
|
||||||
-- self.x+=self.dx
|
|
||||||
-- self.y+=self.dy
|
|
||||||
|
|
||||||
-- self.life-=1
|
|
||||||
-- if self.life<0 then
|
|
||||||
-- del(bullets,self)
|
|
||||||
-- -- TODO: Create particle
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- self.check_collision(self)
|
|
||||||
-- end,
|
|
||||||
-- check_collision=function(self)
|
|
||||||
-- -- If Collide with wall destroy self and create particle
|
|
||||||
|
|
||||||
-- end
|
|
||||||
-- })
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.init()
|
function M.init()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue