- [NEW] Brymode
- [FIX] El switches no es resetejaven al eixir de una habitació - [NEW] [EDITOR] Es mostra el tile sobre el que està el cursor - [NEW] [EDITOR]: Es mostra el nom de l'actor sobre el que està el cursor - [FIX] Durant una escena es repinta abans de seguir al seguent punt de l'script - [NEW] [EDITOR] Es mostra la posició dels switches parpadejant
This commit is contained in:
@@ -2,6 +2,7 @@ actors={
|
|||||||
list={},
|
list={},
|
||||||
updating=false,
|
updating=false,
|
||||||
main={},
|
main={},
|
||||||
|
under_cursor="",
|
||||||
|
|
||||||
init=function()
|
init=function()
|
||||||
actors.list={}
|
actors.list={}
|
||||||
@@ -45,11 +46,20 @@ actors={
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
draw=function()
|
draw=function()
|
||||||
|
actors.under_cursor=""
|
||||||
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
|
||||||
local x,y = v.x, v.y
|
local x,y = v.x, v.y
|
||||||
if v.ox then x = x + v.ox end
|
if v.ox then x = x + v.ox end
|
||||||
if v.oy then y = y + v.oy end
|
if v.oy then y = y + v.oy end
|
||||||
|
|
||||||
|
local mx = math.floor((mousex()-game.cam.x)/8)
|
||||||
|
local my = math.floor((mousey()-game.cam.y)/8)
|
||||||
|
if (mx==x or mx==x+1) and (my==y or my==y-1) then
|
||||||
|
actors.under_cursor=v.name
|
||||||
|
subpal(1,16,8)
|
||||||
|
end
|
||||||
|
|
||||||
if v.o=='u' then
|
if v.o=='u' then
|
||||||
sspr(v.gfx.x+frame,v.gfx.y+16,16,16,x*8+v.dx*2,y*8-12+v.dy*2,16,16,v.dy>1)
|
sspr(v.gfx.x+frame,v.gfx.y+16,16,16,x*8+v.dx*2,y*8-12+v.dy*2,16,16,v.dy>1)
|
||||||
elseif v.o=='d' then
|
elseif v.o=='d' then
|
||||||
@@ -59,6 +69,8 @@ actors={
|
|||||||
elseif v.o=='r' then
|
elseif v.o=='r' then
|
||||||
sspr(v.gfx.x+frame,v.gfx.y+32,16,16,x*8+v.dx*2,y*8-12+v.dy*2,16,16,true)
|
sspr(v.gfx.x+frame,v.gfx.y+32,16,16,x*8+v.dx*2,y*8-12+v.dy*2,16,16,true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not btn(KEY_LSHIFT) then subpal() end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|||||||
34
data/brymode.lua
Normal file
34
data/brymode.lua
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
brymode = {
|
||||||
|
old_update=nil,
|
||||||
|
return_function=nil,
|
||||||
|
|
||||||
|
show=function(retfun)
|
||||||
|
brymode.old_update=update
|
||||||
|
update=brymode.update
|
||||||
|
brymode.return_function=retfun
|
||||||
|
|
||||||
|
cls(0)
|
||||||
|
prnt("#include <stdio.h>",1,1,8)
|
||||||
|
prnt("int main(int argc, char *argv[])",1,1+6*2,8)
|
||||||
|
prnt("{",1,1+6*3,8)
|
||||||
|
prnt("SDL_Init(SDL_INIT_EVERYTHING);",21,1+6*4,8)
|
||||||
|
prnt("SDL_Window *win=",21,1+6*6,8)
|
||||||
|
prnt("SDL_CreateWindow('Title',320,240);",29,1+6*7,8)
|
||||||
|
prnt("SDL_Renderer *ren =",21,1+6*9,8)
|
||||||
|
prnt("SDL_CreateRenderer(win,-1,0);",29,1+6*10,8)
|
||||||
|
prnt("SDL_Quit();",21,1+6*12,8)
|
||||||
|
prnt("return 0;",21,1+6*13,8)
|
||||||
|
prnt("}",1,1+6*14,8)
|
||||||
|
end,
|
||||||
|
|
||||||
|
update=function()
|
||||||
|
--cls(0)
|
||||||
|
|
||||||
|
if btnp(KEY_ESCAPE) then
|
||||||
|
if brymode.return_function then
|
||||||
|
update=brymode.old_update
|
||||||
|
brymode.return_function()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
@@ -3,4 +3,4 @@ config=ja2
|
|||||||
width=160
|
width=160
|
||||||
height=144
|
height=144
|
||||||
zoom=4
|
zoom=4
|
||||||
files=fade.lua,objects.lua,wait.lua,switches.lua,scene.lua,balloon.lua,actors.lua,game.lua,mapa.lua,editor.lua,textbox.lua,menu.lua,m_arq.lua,m_prac3.lua,m_prac2.lua,m_prac1.lua,m_jail1.lua,main.lua
|
files=brymode.lua,fade.lua,objects.lua,wait.lua,switches.lua,scene.lua,balloon.lua,actors.lua,game.lua,mapa.lua,editor.lua,textbox.lua,menu.lua,m_arq.lua,m_prac3.lua,m_prac2.lua,m_prac1.lua,m_jail1.lua,main.lua
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ require "objects"
|
|||||||
require "scene"
|
require "scene"
|
||||||
require "wait"
|
require "wait"
|
||||||
require "switches"
|
require "switches"
|
||||||
|
require "brymode"
|
||||||
|
|
||||||
levels={}
|
levels={}
|
||||||
|
|
||||||
@@ -19,8 +20,8 @@ game={
|
|||||||
restart=function()
|
restart=function()
|
||||||
flags={}
|
flags={}
|
||||||
objects.list={}
|
objects.list={}
|
||||||
actors.main={name="jailer",x=9,y=14,o="u",gfx={x=32,y=0},level="repro"}
|
actors.main={name="jailer",x=8,y=5,o="u",gfx={x=32,y=0},level="prac2"}
|
||||||
game.init("repro")
|
game.init("prac2")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
init=function(levelname,f,objs)
|
init=function(levelname,f,objs)
|
||||||
@@ -30,6 +31,7 @@ game={
|
|||||||
|
|
||||||
game.level=levelname
|
game.level=levelname
|
||||||
actors.init()
|
actors.init()
|
||||||
|
switches.reset()
|
||||||
if actors.main.level==levelname then
|
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})
|
actors.add({name=actors.main.name,x=actors.main.x,y=actors.main.y,o=actors.main.o,gfx=actors.main.gfx})
|
||||||
end
|
end
|
||||||
@@ -47,10 +49,11 @@ game={
|
|||||||
|
|
||||||
show_menu=function()
|
show_menu=function()
|
||||||
game.pause()
|
game.pause()
|
||||||
menu.show({ {"GUARDAR PARTIDA", game.save},
|
brymode.show(game.resume)
|
||||||
{"CARREGAR PARTIDA", game.load},
|
--menu.show({ {"GUARDAR PARTIDA", game.save},
|
||||||
{"EIXIR", main_init},
|
-- {"CARREGAR PARTIDA", game.load},
|
||||||
}, game.resume)
|
-- {"EIXIR", main_init},
|
||||||
|
-- }, game.resume)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
save=function()
|
save=function()
|
||||||
@@ -111,6 +114,29 @@ game={
|
|||||||
game.init(level_name,new_flags,new_objects)
|
game.init(level_name,new_flags,new_objects)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
draw=function()
|
||||||
|
cls(6)
|
||||||
|
camera(game.cam.x, game.cam.y)
|
||||||
|
setsource(tiles)
|
||||||
|
setmap(mapa.surface)
|
||||||
|
map(0,0,0,0,mapa.w, mapa.h)
|
||||||
|
switches.draw();
|
||||||
|
setsource(sprites)
|
||||||
|
if btn(KEY_LSHIFT) then subpal(1,16,8) end
|
||||||
|
actors.draw()
|
||||||
|
subpal()
|
||||||
|
if actors.under_cursor~="" then
|
||||||
|
text(actors.under_cursor,mousex()+8,mousey()+8,9)
|
||||||
|
end
|
||||||
|
if mapa.front_layer then
|
||||||
|
setsource(tiles)
|
||||||
|
setmap(mapa.front_layer)
|
||||||
|
map(0,0,0,0,mapa.w, mapa.h)
|
||||||
|
end
|
||||||
|
setmap(mapa.surface)
|
||||||
|
camera(0,0)
|
||||||
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
if game.paused then return end
|
if game.paused then return end
|
||||||
|
|
||||||
@@ -123,20 +149,12 @@ game={
|
|||||||
if game.cam.y+144 > mapa.h*8 then game.cam.y = mapa.h*8-144 end
|
if game.cam.y+144 > mapa.h*8 then game.cam.y = mapa.h*8-144 end
|
||||||
if game.cam.y < 0 then game.cam.y=0 end
|
if game.cam.y < 0 then game.cam.y=0 end
|
||||||
end
|
end
|
||||||
cls(6)
|
|
||||||
camera(game.cam.x, game.cam.y)
|
game.draw()
|
||||||
setsource(tiles)
|
|
||||||
setmap(mapa.surface)
|
local mx = math.floor((mousex()-game.cam.x)/8)
|
||||||
map(0,0,0,0,mapa.w, mapa.h)
|
local my = math.floor((mousey()-game.cam.y)/8)
|
||||||
setsource(sprites)
|
text(mx..","..my,1,19,8)
|
||||||
actors.draw()
|
|
||||||
if mapa.front_layer then
|
|
||||||
setsource(tiles)
|
|
||||||
setmap(mapa.front_layer)
|
|
||||||
map(0,0,0,0,mapa.w, mapa.h)
|
|
||||||
end
|
|
||||||
setmap(mapa.surface)
|
|
||||||
camera(0,0)
|
|
||||||
|
|
||||||
text(game.cam.x..","..game.cam.y,1,1,8)
|
text(game.cam.x..","..game.cam.y,1,1,8)
|
||||||
if hero then
|
if hero then
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ function text(txt,x,y,col)
|
|||||||
end
|
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.restart}, {"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()
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ scene={
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
cont=function()
|
cont=function()
|
||||||
|
game.draw()
|
||||||
if scene.script==nil then return end
|
if scene.script==nil then return end
|
||||||
scene.pos=scene.pos+1
|
scene.pos=scene.pos+1
|
||||||
if scene.script[scene.pos]==nil then
|
if scene.script[scene.pos]==nil then
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
switches={
|
switches={
|
||||||
list={},
|
list={},
|
||||||
|
col=0,
|
||||||
|
|
||||||
|
reset=function()
|
||||||
|
switches.list={}
|
||||||
|
end,
|
||||||
|
|
||||||
add=function(switch)
|
add=function(switch)
|
||||||
if not switch.w then switch.w=1 end
|
if not switch.w then switch.w=1 end
|
||||||
@@ -15,4 +20,14 @@ switches={
|
|||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
draw=function()
|
||||||
|
text(#switches.list,1,25,8)
|
||||||
|
if switches.col<16 then
|
||||||
|
for i,v in ipairs(switches.list) do
|
||||||
|
rect(v.x*8, v.y*8, (v.x+v.w+1)*8-1, (v.y+v.h)*8-1, 8);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
switches.col=(switches.col+1)%32
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user