Compare commits
2 Commits
70b6565148
...
737a62b450
| Author | SHA1 | Date | |
|---|---|---|---|
| 737a62b450 | |||
| 54358fd691 |
@@ -1,5 +1,6 @@
|
|||||||
actors={
|
actors={
|
||||||
list={},
|
list={},
|
||||||
|
updating=false,
|
||||||
|
|
||||||
add=function(actor)
|
add=function(actor)
|
||||||
actor.dx,actor.dy=0,0
|
actor.dx,actor.dy=0,0
|
||||||
@@ -26,12 +27,9 @@ actors={
|
|||||||
draw=function()
|
draw=function()
|
||||||
for i,v in ipairs(actors.list) do
|
for i,v in ipairs(actors.list) do
|
||||||
local frame=((v.dx+v.dy)%2)*16
|
local frame=((v.dx+v.dy)%2)*16
|
||||||
--print(v.o)
|
|
||||||
if v.o=='u' then
|
if v.o=='u' then
|
||||||
--print(v.dy>1.." "..frame)
|
|
||||||
sspr(v.gfx.x+frame,v.gfx.y+16,16,16,v.x*8-4+v.dx*2,v.y*8-12+v.dy*2,16,16,v.dy>1)
|
sspr(v.gfx.x+frame,v.gfx.y+16,16,16,v.x*8-4+v.dx*2,v.y*8-12+v.dy*2,16,16,v.dy>1)
|
||||||
elseif v.o=='d' then
|
elseif v.o=='d' then
|
||||||
--print(-v.dy>1.." "..frame)
|
|
||||||
sspr(v.gfx.x+frame,v.gfx.y,16,16,v.x*8-4+v.dx*2,v.y*8-12+v.dy*2,16,16,-v.dy>2)
|
sspr(v.gfx.x+frame,v.gfx.y,16,16,v.x*8-4+v.dx*2,v.y*8-12+v.dy*2,16,16,-v.dy>2)
|
||||||
elseif v.o=='l' then
|
elseif v.o=='l' then
|
||||||
sspr(v.gfx.x+frame,v.gfx.y+32,16,16,v.x*8-4+v.dx*2,v.y*8-12+v.dy*2,16,16)
|
sspr(v.gfx.x+frame,v.gfx.y+32,16,16,v.x*8-4+v.dx*2,v.y*8-12+v.dy*2,16,16)
|
||||||
@@ -42,6 +40,9 @@ actors={
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
|
if actors.updating then return end
|
||||||
|
actors.updating=true
|
||||||
|
|
||||||
local needs_sorting=false
|
local needs_sorting=false
|
||||||
for i,v in ipairs(actors.list) do
|
for i,v in ipairs(actors.list) do
|
||||||
if v.dx==0 and v.dy==0 then
|
if v.dx==0 and v.dy==0 then
|
||||||
@@ -56,7 +57,8 @@ actors={
|
|||||||
local switch = switches.search(v.x,v.y)
|
local switch = switches.search(v.x,v.y)
|
||||||
if switch then switch.action() end
|
if switch then switch.action() end
|
||||||
end
|
end
|
||||||
else
|
end
|
||||||
|
if v.path and v.path.pos ~= #v.path.route then
|
||||||
v.path.pos=v.path.pos+1
|
v.path.pos=v.path.pos+1
|
||||||
local step=string.sub(v.path.route,v.path.pos,v.path.pos)
|
local step=string.sub(v.path.route,v.path.pos,v.path.pos)
|
||||||
if step=='u' then
|
if step=='u' then
|
||||||
@@ -106,6 +108,8 @@ actors={
|
|||||||
if needs_sorting then
|
if needs_sorting then
|
||||||
table.sort(actors.list, compare_actors)
|
table.sort(actors.list, compare_actors)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
actors.updating=false
|
||||||
end
|
end
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,14 +33,17 @@ game={
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
show_menu=function()
|
show_menu=function()
|
||||||
|
game.pause()
|
||||||
menu.show({ {"GUARDAR PARTIDA", editor.new},
|
menu.show({ {"GUARDAR PARTIDA", editor.new},
|
||||||
{"CARREGAR PARTIDA", function() textbox.show("FILENAME TO LOAD:",editor.load, mapa.name) end},
|
{"CARREGAR PARTIDA", function() textbox.show("FILENAME TO LOAD:",editor.load, mapa.name) end},
|
||||||
{"EIXIR", function() if mapa.name~=nil then editor.save(mapa.name) else textbox.show("FILENAME TO SAVE:",editor.save, mapa.name) end end},
|
{"EIXIR", function() if mapa.name~=nil then editor.save(mapa.name) else textbox.show("FILENAME TO SAVE:",editor.save, mapa.name) end end},
|
||||||
{"EXIT", main_init},
|
{"EXIT", main_init},
|
||||||
}, function()editor.paused=false end)
|
}, function() game.resume() end)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
|
if game.paused then return end
|
||||||
|
|
||||||
local hero = actors.search("jailer")
|
local hero = actors.search("jailer")
|
||||||
if hero then
|
if hero then
|
||||||
game.cam.x = hero.x*8 + hero.dx*2 - 80
|
game.cam.x = hero.x*8 + hero.dx*2 - 80
|
||||||
@@ -64,11 +67,28 @@ game={
|
|||||||
hero.path={pos=0,route='l',keys=true}
|
hero.path={pos=0,route='l',keys=true}
|
||||||
elseif btn(KEY_RIGHT) then
|
elseif btn(KEY_RIGHT) then
|
||||||
hero.path={pos=0,route='r',keys=true}
|
hero.path={pos=0,route='r',keys=true}
|
||||||
elseif btnp(KEY_ESCAPE) then
|
|
||||||
game.show_menu()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if btnp(KEY_ESCAPE) then
|
||||||
|
game.show_menu()
|
||||||
|
end
|
||||||
|
|
||||||
if beat() then actors.update() end
|
if beat() then actors.update() end
|
||||||
|
end,
|
||||||
|
|
||||||
|
pause=function()
|
||||||
|
game.paused = true
|
||||||
|
rectfill(10,84, 150, 128,6)
|
||||||
|
rect(10,84, 150, 128,8)
|
||||||
|
rect(9,83, 151, 129,6)
|
||||||
|
text("OBJECTES:",14,82,8)
|
||||||
|
setsource(objectes)
|
||||||
|
sspr(0,0,16,16,14,89)
|
||||||
|
sspr(0,0,16,16,34,89)
|
||||||
|
sspr(0,0,16,16,14,109)
|
||||||
|
end,
|
||||||
|
|
||||||
|
resume=function()
|
||||||
|
game.paused = nil
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@@ -2,11 +2,12 @@
|
|||||||
function _init()
|
function _init()
|
||||||
menu_option=0
|
menu_option=0
|
||||||
sprites=loadsurf("sprites.gif")
|
sprites=loadsurf("sprites.gif")
|
||||||
|
objectes=loadsurf("objects.gif")
|
||||||
tiles=loadsurf("tiles.gif")
|
tiles=loadsurf("tiles.gif")
|
||||||
setsource(tiles)
|
setsource(tiles)
|
||||||
local pal=loadpal("tiles.gif")
|
local pal=loadpal("tiles.gif")
|
||||||
setpal(pal)
|
setpal(pal)
|
||||||
beat(12)
|
beat(6)
|
||||||
fade.init()
|
fade.init()
|
||||||
main_init()
|
main_init()
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user