[WIP] Reestructurant codi abans de posar-me en el nivell 2
[NEW] Afegit music_player [NEW] Música de fons des de l'inici
This commit is contained in:
+11
-30
@@ -1,25 +1,3 @@
|
||||
-- flow={
|
||||
-- level=1,
|
||||
-- step={0},
|
||||
-- actiu="",
|
||||
-- pila={},
|
||||
-- paths={ {flow_safe} },
|
||||
-- registre={}
|
||||
-- -- sub_path_enable = false,
|
||||
-- -- sub_step = 0,
|
||||
-- -- sub_path={}
|
||||
-- }
|
||||
|
||||
-- function flow:print()
|
||||
-- print("> STEP= "..self.step.." / "..#self.path)
|
||||
-- if self.sub_path_enable then
|
||||
-- print("> SUB_PATH_ENABLE= TRUE")
|
||||
-- else
|
||||
-- print("> SUB_PATH_ENABLE= FALSE")
|
||||
-- end
|
||||
-- print("> SUB_STEP= "..self.sub_step.." / "..#self.sub_path)
|
||||
-- print("")
|
||||
-- end
|
||||
|
||||
states={
|
||||
registre={}, -- {nom {ptr (a l'estat actual), path (llista de funcions ordenada)} ...}
|
||||
@@ -40,7 +18,8 @@ end
|
||||
function states:registrar(nom, _path)
|
||||
print("[STATES] REGISTRAR => "..nom)
|
||||
self.registre[nom]= {ptr=0, path=_path}
|
||||
print(self.registre[nom].ptr)
|
||||
-- print(" nom.ptr -> "..self.registre[nom].ptr)
|
||||
-- print(" nom.path -> "..#self.registre[nom].path)
|
||||
end
|
||||
|
||||
function states:borrar(nom)
|
||||
@@ -68,22 +47,24 @@ function states:executar(nom, stacking)
|
||||
end
|
||||
self.actiu=nom
|
||||
self.registre[self.actiu].ptr=0
|
||||
-- Executar el primer pas
|
||||
self:next()
|
||||
end
|
||||
|
||||
function states:next()
|
||||
print("[STATES] NEXT "..self.actiu);
|
||||
local ptr = self.registre[self.actiu].ptr
|
||||
local steps = #self.registre[self.actiu].path
|
||||
-- print("STATES_NEXT= "..self.actiu..", "..ptr..", "..steps)
|
||||
-- print("[STATES] NEXT "..self.actiu);
|
||||
local estat = self.registre[self.actiu]
|
||||
local ptr = estat.ptr
|
||||
local steps = #estat.path
|
||||
if ptr+1>steps then
|
||||
self:finish()
|
||||
else
|
||||
self.registre[self.actiu].ptr = ptr+1
|
||||
game_update = self.registre[self.actiu].path[self.registre[self.actiu].ptr]
|
||||
estat.ptr = ptr+1
|
||||
-- print("[STATES] NEXT "..self.actiu.." ("..estat.ptr.." / "..steps..")")
|
||||
game_update = estat.path[estat.ptr]
|
||||
end
|
||||
|
||||
return self.actiu, self.registre[self.actiu].ptr
|
||||
return self.actiu, estat.ptr
|
||||
end
|
||||
|
||||
function states:finish()
|
||||
|
||||
Reference in New Issue
Block a user