Files
cacaus-arcade/data/cacau.lua

126 lines
3.4 KiB
Lua

-- local arcade_config = require("arcade_config")
type_shot={linear=1, rear=2, way3=3}
cacau={
{ hab=-1, x=0, y=0, w=12 ,h=8 ,wait=0, flip=false, bb={x=0,y=0,w=4,h=4}, alive=false, power=1 },
{ hab=-1, x=0, y=0, w=12 ,h=8 ,wait=0, flip=false, bb={x=0,y=0,w=4,h=4}, alive=false, power=1 },
{ hab=-1, x=0, y=0, w=12 ,h=8 ,wait=0, flip=false, bb={x=0,y=0,w=4,h=4}, alive=false, power=1 }
}
-- function cacau.init(_hab,_x,_y,_flip)
-- if cacau.hab ~= -1 then return end
-- cacau.hab=_hab
-- cacau.x=_x
-- cacau.y=_y
-- cacau.flip=_flip
-- cacau.alive = true
-- end
function cacau.init(_x,_y,_flip,_power,_num_shots,_type_shot)
if _type_shot==type_shot.linear then
for ns=1,_num_shots do
if cacau[ns].alive == true then break end
cacau[ns].x=_x
cacau[ns].y=_y
cacau[ns].flip=_flip
cacau[ns].alive = true
cacau[ns].power = _power
end
elseif _type_shot==type_shot.rear then
elseif _type_shot==type_shot.way3 then
end
end
function cacau:available(_num_shots,_type_shot)
local avail_shots = false
if _type_shot==type_shot.linear then
for ns=1,_num_shots do
if cacau[ns].alive == false then avail_shots = true end
end
elseif _type_shot==type_shot.rear then
elseif _type_shot==type_shot.way3 then
end
return avail_shots
end
function cacau.draw()
for ns=1,3 do
if cacau[ns].alive==true then
local cx, cy = viewp:screen_coords(cacau[ns].x, cacau[ns].y)
draw.circf( cx, cy, 4,16)
draw.circf( cx+4, cy, 4,16)
draw.circf( cx , cy, 2,6)
draw.circf( cx+4, cy, 2,6)
end
end
end
function cacau.update()
for ns=1,3 do
if cacau[ns].alive==true then
if viewp:inside(cacau[ns].x, cacau[ns].y, cacau[ns].w, cacau[ns].h)==false then
cacau[ns].hab=-1
cacau[ns].alive=false
break
end
end
cacau[ns].wait=cacau[ns].wait+1
if cacau[ns].wait == 3 then cacau[ns].wait = 0 end
if arc_check_tile(cacau[ns].x,cacau[ns].y)<tiletype.block then
local step=3
if cacau[ns].flip then step=-step end
cacau[ns].x=cacau[ns].x+step
if viewp:inside(cacau[ns].x, cacau[ns].y, cacau[ns].w, cacau[ns].h)==false then
cacau[ns].alive=false
break
end
else
cacau[ns].hab=-1
cacau[ns].alive = false
end
end
end
-- function cacau.update()
-- if cacau.hab == -1 then
-- cacau.alive = false
-- return
-- end
-- cacau.wait=cacau.wait+1
--
-- if cacau.wait==3 then
-- cacau.wait=0
--
-- if cacau.x>96 then
-- cacau.hab=-1
-- cacau.alive = false
-- return
-- elseif check_tile(cacau.hab,cacau.x,cacau.y)<tiletype.block then
-- if cacau.flip then
-- cacau.x=cacau.x-4
-- else
-- cacau.x=cacau.x+4
-- end
-- if cacau.x<-4 then
-- cacau.hab=-1
-- cacau.alive = false
-- return
-- end
-- else
-- cacau.hab=-1
-- cacau.alive = false
-- return
-- end
-- end
-- end