Cacaus volant!

This commit is contained in:
2026-03-23 22:59:50 +01:00
parent cb03264568
commit e28e053cb4
4 changed files with 151 additions and 60 deletions

View File

@@ -1,59 +1,125 @@
local arcade_config = require("arcade_config")
o2aX = arcade_config.org2arc_escala
-- local arcade_config = require("arcade_config")
cacau={ hab=-1,
x=0,
y=0,
wait=0,
flip=false,
bb={x=0,y=0,w=4,h=4},
alive=false }
type_shot={linear=1, rear=2, way3=3}
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
cacau={
{ hab=-1, x=0, y=0, wait=0, flip=false, bb={x=0,y=0,w=4,h=4}, alive=false, power=1 },
{ hab=-1, x=0, y=0, wait=0, flip=false, bb={x=0,y=0,w=4,h=4}, alive=false, power=1 },
{ hab=-1, x=0, y=0, 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()
draw.circf(cacau.x*o2aX,cacau.y*o2aX,2*o2aX,16)
draw.circf((cacau.x+2)*o2aX,cacau.y*o2aX,2*o2aX,16)
draw.circf(cacau.x*o2aX,cacau.y*o2aX,1*o2aX,6)
draw.circf((cacau.x+2)*o2aX,cacau.y*o2aX,1*o2aX,6)
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
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)==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)==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