- 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:
@@ -1,6 +1,12 @@
|
||||
actors={
|
||||
list={},
|
||||
updating=false,
|
||||
main={},
|
||||
|
||||
init=function()
|
||||
actors.list={}
|
||||
actors.updating=false
|
||||
end,
|
||||
|
||||
add=function(actor)
|
||||
actor.dx,actor.dy=0,0
|
||||
@@ -53,7 +59,7 @@ actors={
|
||||
game.update()
|
||||
if in_scene then scene.cont() end
|
||||
v.keys=nil
|
||||
if v.name == actors.hero then
|
||||
if v.name == actors.main.name then
|
||||
local switch = switches.search(v.x,v.y)
|
||||
if switch then switch.action() end
|
||||
end
|
||||
|
||||
@@ -59,6 +59,10 @@ fade={
|
||||
end,
|
||||
|
||||
fadein = function()
|
||||
if update==fade.update_fadeout then
|
||||
fade.outin=true
|
||||
return
|
||||
end
|
||||
fade.old_update=update
|
||||
update=fade.update_fadein
|
||||
fade.step=6
|
||||
|
||||
@@ -1,27 +1,38 @@
|
||||
game={
|
||||
cam={x=0,y=0},
|
||||
|
||||
init=function()
|
||||
restart=function()
|
||||
flags={}
|
||||
mapa.load("test.map")
|
||||
objects.list={}
|
||||
actors.main={name="jailer",x=6,y=9,o="r",gfx={x=32,y=0},level="test"}
|
||||
game.init("test")
|
||||
end,
|
||||
|
||||
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="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"
|
||||
|
||||
update=game.update
|
||||
--objects.collect({name="diskette",x=0,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
|
||||
|
||||
@@ -33,7 +33,7 @@ end
|
||||
function main_init()
|
||||
set_update(menu_update)
|
||||
second_menu = {{"PEIV", function() end},{"TORNAR",show_main_menu}}
|
||||
main_menu = { {"JUGAR", game.init}, {"EDITOR", editor.init}, {"EIXIR", quit}, {"TEST", function() menu.show(second_menu) end } }
|
||||
main_menu = { {"JUGAR", game.restart}, {"EDITOR", editor.init}, {"EIXIR", quit}, {"TEST", function() menu.show(second_menu) end } }
|
||||
show_main_menu()
|
||||
end
|
||||
|
||||
|
||||
@@ -3,23 +3,27 @@ objects={
|
||||
|
||||
collect=function(obj)
|
||||
table.insert(objects.list, obj)
|
||||
balloon.narrator(obj)
|
||||
balloon.narrator(object[obj])
|
||||
end,
|
||||
|
||||
search=function(name)
|
||||
leave=function(name)
|
||||
for i,obj in ipairs(objects.list) do
|
||||
if obj.name and obj.name==name then
|
||||
if object[obj].name and object[obj].name==name then
|
||||
table.remove(objects.list,i)
|
||||
return
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
leave=function(name)
|
||||
search=function(name)
|
||||
for i,obj in ipairs(objects.list) do
|
||||
if obj.name and obj.name==name then
|
||||
return obj
|
||||
if object[obj].name and object[obj].name==name then
|
||||
return object[obj]
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
object={
|
||||
diskito_usufondo={name="DISQUITO DE USUFONDO",x=0,y=0}
|
||||
}
|
||||
Reference in New Issue
Block a user