- Peu de Paco implemented

- GPS implemented
- Object system working
- minor changes to batman and gorro
This commit is contained in:
2022-10-27 19:49:14 +02:00
parent 814346d3a3
commit 5587c3bd72
6 changed files with 86 additions and 14 deletions

View File

@@ -4,8 +4,8 @@ function batman.init()
batman.hit=batman.hit batman.hit=batman.hit
batman.update=batman.update_normal batman.update=batman.update_normal
batman.draw=batman.draw batman.draw=batman.draw
local habs={5,46,36,39} local habs={5,9,46,36,39}
batman.hab=habs[1+rnd(4)] batman.hab=habs[1+rnd(#habs)]
end end
function batman.draw() function batman.draw()

View File

@@ -2,4 +2,4 @@ title=Cacaus
width=128 width=128
height=96 height=96
zoom=5 zoom=5
files=scenes.lua,starter.lua,score.lua,switches.lua,map.lua,mapa.lua,cacau.lua,gorro.lua,batman.lua,elalien.lua,premiere.lua,caco.lua,zombie.lua,abad.lua,main.lua files=scenes.lua,starter.lua,score.lua,switches.lua,map.lua,mapa.lua,cacau.lua,gps.lua,peu.lua,gorro.lua,batman.lua,elalien.lua,premiere.lua,caco.lua,zombie.lua,abad.lua,main.lua

View File

@@ -1,8 +1,10 @@
gorro={hab=5,x=48,y=24,bb={x=0,y=0,w=8,h=8}} gorro={hab=5,x=48,y=24,bb={x=0,y=0,w=8,h=8}}
function gorro.init() function gorro.init()
local habs={11,11,11,11} local habs={{60,5},{4,5},{34,4},{62,7},{75,4}}
gorro.hab=habs[1+rnd(4)] local r=1+rnd(#habs)
gorro.hab=habs[r][1]
gorro.x=habs[r][2]*8
gorro.update=gorro.update gorro.update=gorro.update
gorro.draw=gorro.draw gorro.draw=gorro.draw
end end
@@ -15,6 +17,7 @@ function gorro.update()
if gorro.hab==abad.hab then if gorro.hab==abad.hab then
if aabb(abad,gorro) then if aabb(abad,gorro) then
abad.objects.gorro=true abad.objects.gorro=true
if abad.objects.gps~=nil then current_camera=3 end
remove_actor(gorro) remove_actor(gorro)
end end
end end

30
gps.lua Normal file
View File

@@ -0,0 +1,30 @@
gps={hab=5,x=48,y=24,bb={x=0,y=0,w=8,h=8}}
function gps.init()
local habs={{33,8},{13,4},{51,9},{50,4},{42,7}}
local r=1+rnd(#habs)
gps.hab=habs[r][1]
gps.x=habs[r][2]*8
gps.update=gps.update
gps.draw=gps.draw
end
function gps.draw()
sspr(112,48,16,16,gps.x,gps.y,16,16)
end
function gps.update()
if gps.hab==abad.hab then
if aabb(abad,gps) then
abad.objects.gps=true
if abad.objects.gorro==nil then
current_camera=1
elseif abad.objects.peu==nil then
current_camera=2
else
current_camera=3
end
remove_actor(gps)
end
end
end

View File

@@ -7,8 +7,8 @@ seltile = 0
actors={} actors={}
cameras={} cameras={}
camera_names={"Premiere","EL_ALIEN","BatMan"} camera_names={[0]="GPS","Gorro","Peu de Paco","Premiere","EL_ALIEN","BatMan"}
current_camera=1 current_camera=0
function remove_actor(actor) function remove_actor(actor)
for index, value in pairs(actors) do for index, value in pairs(actors) do
@@ -28,9 +28,15 @@ function _init()
abad_init() abad_init()
table.insert(actors,abad) table.insert(actors,abad)
gps.init()
table.insert(actors,gps)
gorro.init() gorro.init()
table.insert(actors,gorro) table.insert(actors,gorro)
peu.init()
table.insert(actors,peu)
premiere.init() premiere.init()
table.insert(actors,premiere) table.insert(actors,premiere)
@@ -49,6 +55,9 @@ function _init()
table.insert(actors,starter.new(11,16,32,scenes.abad_corfes)) table.insert(actors,starter.new(11,16,32,scenes.abad_corfes))
score.create() score.create()
cameras[0]=gps
table.insert(cameras,gorro)
table.insert(cameras,peu)
table.insert(cameras,premiere) table.insert(cameras,premiere)
table.insert(cameras,elalien) table.insert(cameras,elalien)
table.insert(cameras,batman) table.insert(cameras,batman)
@@ -193,14 +202,20 @@ function update_game()
if btnp(KEY_RETURN) then if btnp(KEY_RETURN) then
mode=modes.editing mode=modes.editing
mapa_restore_backup() mapa_restore_backup()
elseif btnp(KEY_1) then
current_camera=1
elseif btnp(KEY_2) then
current_camera=2
elseif btnp(KEY_3) then
current_camera=3
end end
if abad.objects.gps~=nil then
if btnp(KEY_1) then
if abad.objects.gorro==nil then current_camera=1 end
elseif btnp(KEY_2) then
if abad.objects.peu==nil then current_camera=2 end
elseif btnp(KEY_3) then
current_camera=3
elseif btnp(KEY_4) then
current_camera=4
elseif btnp(KEY_5) then
current_camera=5
end
end
end end
end end

24
peu.lua Normal file
View File

@@ -0,0 +1,24 @@
peu={hab=5,x=48,y=24,bb={x=0,y=0,w=8,h=8}}
function peu.init()
local habs={{18,8},{16,2},{16,7},{15,5},{27,1},{27,10},{29,2},{38,8},{69,2},{79,3}}
local r=1+rnd(#habs)
peu.hab=habs[r][1]
peu.x=habs[r][2]*8
peu.update=peu.update
peu.draw=peu.draw
end
function peu.draw()
sspr(112,32,16,16,peu.x,peu.y,16,16)
end
function peu.update()
if peu.hab==abad.hab then
if aabb(abad,peu) then
abad.objects.peu=true
if abad.objects.gps~=nil then current_camera=4 end
remove_actor(peu)
end
end
end