diff --git a/batman.lua b/batman.lua index ae4acc7..0583a0f 100644 --- a/batman.lua +++ b/batman.lua @@ -4,8 +4,8 @@ function batman.init() batman.hit=batman.hit batman.update=batman.update_normal batman.draw=batman.draw - local habs={5,46,36,39} - batman.hab=habs[1+rnd(4)] + local habs={5,9,46,36,39} + batman.hab=habs[1+rnd(#habs)] end function batman.draw() diff --git a/game.ini b/game.ini index e54faea..67d18dd 100644 --- a/game.ini +++ b/game.ini @@ -2,4 +2,4 @@ title=Cacaus width=128 height=96 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 diff --git a/gorro.lua b/gorro.lua index 193a562..bd0896c 100644 --- a/gorro.lua +++ b/gorro.lua @@ -1,8 +1,10 @@ gorro={hab=5,x=48,y=24,bb={x=0,y=0,w=8,h=8}} function gorro.init() - local habs={11,11,11,11} - gorro.hab=habs[1+rnd(4)] + local habs={{60,5},{4,5},{34,4},{62,7},{75,4}} + local r=1+rnd(#habs) + gorro.hab=habs[r][1] + gorro.x=habs[r][2]*8 gorro.update=gorro.update gorro.draw=gorro.draw end @@ -15,6 +17,7 @@ function gorro.update() if gorro.hab==abad.hab then if aabb(abad,gorro) then abad.objects.gorro=true + if abad.objects.gps~=nil then current_camera=3 end remove_actor(gorro) end end diff --git a/gps.lua b/gps.lua new file mode 100644 index 0000000..45df90d --- /dev/null +++ b/gps.lua @@ -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 diff --git a/main.lua b/main.lua index 12d7055..18ac840 100644 --- a/main.lua +++ b/main.lua @@ -7,8 +7,8 @@ seltile = 0 actors={} cameras={} -camera_names={"Premiere","EL_ALIEN","BatMan"} -current_camera=1 +camera_names={[0]="GPS","Gorro","Peu de Paco","Premiere","EL_ALIEN","BatMan"} +current_camera=0 function remove_actor(actor) for index, value in pairs(actors) do @@ -28,9 +28,15 @@ function _init() abad_init() table.insert(actors,abad) + gps.init() + table.insert(actors,gps) + gorro.init() table.insert(actors,gorro) + peu.init() + table.insert(actors,peu) + premiere.init() table.insert(actors,premiere) @@ -49,6 +55,9 @@ function _init() table.insert(actors,starter.new(11,16,32,scenes.abad_corfes)) score.create() + cameras[0]=gps + table.insert(cameras,gorro) + table.insert(cameras,peu) table.insert(cameras,premiere) table.insert(cameras,elalien) table.insert(cameras,batman) @@ -193,14 +202,20 @@ function update_game() if btnp(KEY_RETURN) then mode=modes.editing 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 - + 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 diff --git a/peu.lua b/peu.lua new file mode 100644 index 0000000..ffac6f2 --- /dev/null +++ b/peu.lua @@ -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