- Retreballant el sistema de objectes

- Treballant en el fluxe de programa
- Treballant en el guardat/carrega de partida
- Fades encadenats
This commit is contained in:
2023-02-01 19:14:26 +01:00
parent 1250921e4b
commit d48816bd8b
5 changed files with 91 additions and 25 deletions

View File

@@ -1,27 +1,38 @@
game={
cam={x=0,y=0},
init=function()
restart=function()
flags={}
mapa.load("test.map")
actors.add({name="jailer",x=6,y=9,o="r",gfx={x=32,y=0}})
actors.add({name="estudiant",x=12,y=8,o="d",gfx={x=64,y=0}})
actors.hero="jailer"
objects.list={}
actors.main={name="jailer",x=6,y=9,o="r",gfx={x=32,y=0},level="test"}
game.init("test")
end,
update=game.update
--objects.collect({name="diskette",x=0,y=0})
init=function(levelname,f,objs)
if f then flags=f end
if objs then objects.list=objs end
game.level=levelname
actors.init()
if actors.main.level==levelname then
actors.add({name=actors.main.name,x=actors.main.x,y=actors.main.y,o=actors.main.o,gfx=actors.main.gfx})
end
mapa.load(game.level..".map")
actors.add({name="estudiant",x=12,y=8,o="d",gfx={x=64,y=0}})
switches.add({x=8,y=8,w=1,h=3,action=
function()
if not flags.usu1 then
flags.usu1=true
flags.usu1=1
scene.start({
function() actors.add({name="usufondo",x=16,y=8,o="d",gfx={x=0,y=0}}) scene.cont() end,
function() wait.start(1) end,
function() actors.search("usufondo").path={pos=0,route='dlllll'} end,
function() balloon.show("HOY NO HAY JAIL!\nTU MISMO!!",10,"usufondo",false,{x=7,w=10,h=2}) end,
function() objects.collect({name="DISQUITO DE USUFONDO",x=0,y=0}) end,
function() objects.collect("diskito_usufondo") end,
function() actors.search("usufondo").path={pos=0,route='rrrrru'} end,
function() wait.start(0.5) end,
function() actors.remove("usufondo") scene.cont() end,
@@ -32,16 +43,56 @@ game={
end
})
if game.paused then
game.resume()
else
update=game.update
end
fade.fadein()
end,
show_menu=function()
game.pause()
menu.show({ {"GUARDAR PARTIDA", editor.new},
{"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},
{"EXIT", main_init},
}, function() game.resume() end)
menu.show({ {"GUARDAR PARTIDA", game.save},
{"CARREGAR PARTIDA", game.load},
{"EIXIR", main_init},
}, game.resume)
end,
save=function()
local i=1
file = io.open(configfolder().."slot"..i..".txt", "w")
if file then
io.output(file)
io.write("level="..game.level.."\n")
local hero = actors.search("jailer")
io.write("x="..hero.x.."\n")
io.write("y="..hero.y.."\n")
io.write("[FLAGS]\n")
for k,v in pairs(flags) do
io.write(k.."="..v.."\n")
end
io.write("[OBJECTS]\n")
for i,v in ipairs(objects.list) do
io.write(v.."\n")
end
io.close(file)
end
game.resume()
end,
load=function()
local i=1
file = io.open(configfolder().."slot"..i..".txt", "r")
if file then
io.input(file)
io.close(file)
end
fade.fadeout()
--game.resume()
actors.main.x=10
actors.main.y=8
game.init("test")
end,
update=function()
@@ -88,8 +139,9 @@ game={
setsource(objectes)
local x,y=15,90
for k,v in pairs(objects.list) do
sspr(v.x,v.y,16,16,x,y)
for i,name in ipairs(objects.list) do
local obj = object[name]
sspr(obj.x,obj.y,16,16,x,y)
x=x+19
if x==148 then x,y=15,y+19 end
end