- 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={
|
actors={
|
||||||
list={},
|
list={},
|
||||||
updating=false,
|
updating=false,
|
||||||
|
main={},
|
||||||
|
|
||||||
|
init=function()
|
||||||
|
actors.list={}
|
||||||
|
actors.updating=false
|
||||||
|
end,
|
||||||
|
|
||||||
add=function(actor)
|
add=function(actor)
|
||||||
actor.dx,actor.dy=0,0
|
actor.dx,actor.dy=0,0
|
||||||
@@ -53,7 +59,7 @@ actors={
|
|||||||
game.update()
|
game.update()
|
||||||
if in_scene then scene.cont() end
|
if in_scene then scene.cont() end
|
||||||
v.keys=nil
|
v.keys=nil
|
||||||
if v.name == actors.hero then
|
if v.name == actors.main.name then
|
||||||
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
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ fade={
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
fadein = function()
|
fadein = function()
|
||||||
|
if update==fade.update_fadeout then
|
||||||
|
fade.outin=true
|
||||||
|
return
|
||||||
|
end
|
||||||
fade.old_update=update
|
fade.old_update=update
|
||||||
update=fade.update_fadein
|
update=fade.update_fadein
|
||||||
fade.step=6
|
fade.step=6
|
||||||
|
|||||||
@@ -1,27 +1,38 @@
|
|||||||
game={
|
game={
|
||||||
cam={x=0,y=0},
|
cam={x=0,y=0},
|
||||||
|
|
||||||
init=function()
|
restart=function()
|
||||||
flags={}
|
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.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=
|
switches.add({x=8,y=8,w=1,h=3,action=
|
||||||
function()
|
function()
|
||||||
if not flags.usu1 then
|
if not flags.usu1 then
|
||||||
flags.usu1=true
|
flags.usu1=1
|
||||||
scene.start({
|
scene.start({
|
||||||
function() actors.add({name="usufondo",x=16,y=8,o="d",gfx={x=0,y=0}}) scene.cont() end,
|
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() wait.start(1) end,
|
||||||
function() actors.search("usufondo").path={pos=0,route='dlllll'} 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() 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() actors.search("usufondo").path={pos=0,route='rrrrru'} end,
|
||||||
function() wait.start(0.5) end,
|
function() wait.start(0.5) end,
|
||||||
function() actors.remove("usufondo") scene.cont() end,
|
function() actors.remove("usufondo") scene.cont() end,
|
||||||
@@ -32,16 +43,56 @@ game={
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if game.paused then
|
||||||
|
game.resume()
|
||||||
|
else
|
||||||
|
update=game.update
|
||||||
|
end
|
||||||
fade.fadein()
|
fade.fadein()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
show_menu=function()
|
show_menu=function()
|
||||||
game.pause()
|
game.pause()
|
||||||
menu.show({ {"GUARDAR PARTIDA", editor.new},
|
menu.show({ {"GUARDAR PARTIDA", game.save},
|
||||||
{"CARREGAR PARTIDA", function() textbox.show("FILENAME TO LOAD:",editor.load, mapa.name) end},
|
{"CARREGAR PARTIDA", game.load},
|
||||||
{"EIXIR", function() if mapa.name~=nil then editor.save(mapa.name) else textbox.show("FILENAME TO SAVE:",editor.save, mapa.name) end end},
|
{"EIXIR", main_init},
|
||||||
{"EXIT", main_init},
|
}, game.resume)
|
||||||
}, function() game.resume() end)
|
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,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
@@ -88,8 +139,9 @@ game={
|
|||||||
setsource(objectes)
|
setsource(objectes)
|
||||||
|
|
||||||
local x,y=15,90
|
local x,y=15,90
|
||||||
for k,v in pairs(objects.list) do
|
for i,name in ipairs(objects.list) do
|
||||||
sspr(v.x,v.y,16,16,x,y)
|
local obj = object[name]
|
||||||
|
sspr(obj.x,obj.y,16,16,x,y)
|
||||||
x=x+19
|
x=x+19
|
||||||
if x==148 then x,y=15,y+19 end
|
if x==148 then x,y=15,y+19 end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ end
|
|||||||
function main_init()
|
function main_init()
|
||||||
set_update(menu_update)
|
set_update(menu_update)
|
||||||
second_menu = {{"PEIV", function() end},{"TORNAR",show_main_menu}}
|
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()
|
show_main_menu()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,23 +3,27 @@ objects={
|
|||||||
|
|
||||||
collect=function(obj)
|
collect=function(obj)
|
||||||
table.insert(objects.list, obj)
|
table.insert(objects.list, obj)
|
||||||
balloon.narrator(obj)
|
balloon.narrator(object[obj])
|
||||||
end,
|
end,
|
||||||
|
|
||||||
search=function(name)
|
leave=function(name)
|
||||||
for i,obj in ipairs(objects.list) do
|
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)
|
table.remove(objects.list,i)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
leave=function(name)
|
search=function(name)
|
||||||
for i,obj in ipairs(objects.list) do
|
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
|
||||||
return obj
|
return object[obj]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object={
|
||||||
|
diskito_usufondo={name="DISQUITO DE USUFONDO",x=0,y=0}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user