Compare commits
4 Commits
db2f988de7
...
d82a61bd4c
| Author | SHA1 | Date | |
|---|---|---|---|
| d82a61bd4c | |||
| 8008588db4 | |||
| 2a4d7ada8f | |||
| 05ebc097d6 |
@@ -2,6 +2,7 @@ actors={
|
||||
list={},
|
||||
updating=false,
|
||||
main={},
|
||||
under_cursor="",
|
||||
|
||||
init=function()
|
||||
actors.list={}
|
||||
@@ -45,11 +46,20 @@ actors={
|
||||
end,
|
||||
|
||||
draw=function()
|
||||
actors.under_cursor=""
|
||||
for i,v in ipairs(actors.list) do
|
||||
local frame=((v.dx+v.dy)%2)*16
|
||||
local x,y = v.x, v.y
|
||||
if v.ox then x = x + v.ox 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
|
||||
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
|
||||
@@ -59,6 +69,8 @@ actors={
|
||||
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)
|
||||
end
|
||||
|
||||
if not btn(KEY_LSHIFT) then subpal() 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
|
||||
height=144
|
||||
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 "wait"
|
||||
require "switches"
|
||||
require "brymode"
|
||||
|
||||
levels={}
|
||||
|
||||
@@ -19,8 +20,8 @@ game={
|
||||
restart=function()
|
||||
flags={}
|
||||
objects.list={}
|
||||
actors.main={name="jailer",x=9,y=14,o="u",gfx={x=32,y=0},level="repro"}
|
||||
game.init("repro")
|
||||
actors.main={name="jailer",x=8,y=5,o="u",gfx={x=32,y=0},level="prac2"}
|
||||
game.init("prac2")
|
||||
end,
|
||||
|
||||
init=function(levelname,f,objs)
|
||||
@@ -30,6 +31,7 @@ game={
|
||||
|
||||
game.level=levelname
|
||||
actors.init()
|
||||
switches.reset()
|
||||
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
|
||||
@@ -47,10 +49,11 @@ game={
|
||||
|
||||
show_menu=function()
|
||||
game.pause()
|
||||
menu.show({ {"GUARDAR PARTIDA", game.save},
|
||||
{"CARREGAR PARTIDA", game.load},
|
||||
{"EIXIR", main_init},
|
||||
}, game.resume)
|
||||
brymode.show(game.resume)
|
||||
--menu.show({ {"GUARDAR PARTIDA", game.save},
|
||||
-- {"CARREGAR PARTIDA", game.load},
|
||||
-- {"EIXIR", main_init},
|
||||
-- }, game.resume)
|
||||
end,
|
||||
|
||||
save=function()
|
||||
@@ -111,6 +114,34 @@ game={
|
||||
game.init(level_name,new_flags,new_objects)
|
||||
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
|
||||
if (mousex()<=80) then
|
||||
text(actors.under_cursor,mousex()+game.cam.x+4,mousey()+game.cam.y+4,9)
|
||||
else
|
||||
local size = #actors.under_cursor
|
||||
text(actors.under_cursor,mousex()+game.cam.x-size*4,mousey()+game.cam.y+4,9)
|
||||
end
|
||||
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()
|
||||
if game.paused then return end
|
||||
|
||||
@@ -123,20 +154,12 @@ game={
|
||||
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
|
||||
end
|
||||
cls(6)
|
||||
camera(game.cam.x, game.cam.y)
|
||||
setsource(tiles)
|
||||
setmap(mapa.surface)
|
||||
map(0,0,0,0,mapa.w, mapa.h)
|
||||
setsource(sprites)
|
||||
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)
|
||||
|
||||
game.draw()
|
||||
|
||||
local mx = math.floor((mousex()+game.cam.x)/8)
|
||||
local my = math.floor((mousey()+game.cam.y)/8)
|
||||
text(mx..","..my,1,19,8)
|
||||
|
||||
text(game.cam.x..","..game.cam.y,1,1,8)
|
||||
if hero then
|
||||
|
||||
@@ -2,7 +2,7 @@ levels["prac2"]={
|
||||
load=function()
|
||||
mapa.load("prac2.map")
|
||||
|
||||
actors.add({name="profe",x=10,y=5,o="d",gfx={x=224,y=0}})
|
||||
actors.add({name="profe",x=10,y=5,o="d",gfx={x=224,y=0},action=levels.prac2.profe_action})
|
||||
|
||||
actors.add({name="comp_1_1",x=4,y=9,o="d",gfx={x=160,y=0},action=levels.prac2.comp_updating_action})
|
||||
actors.add({name="comp_2_1",x=6,y=9,o="d",gfx={x=176,y=0},action=levels.prac2.comp_updating_action})
|
||||
@@ -21,11 +21,11 @@ levels["prac2"]={
|
||||
actors.add({name="comp_profe",x=10,y=6,o="d",gfx={x=96,y=0},action=levels.prac2.comp_profe_action})
|
||||
actors.add({name="taula_profe",x=12,y=6,o="d",gfx={x=160,y=16}})
|
||||
|
||||
actors.add({name="alumne1",x=12,y=10,o="d",gfx={x=32,y=64}})
|
||||
actors.add({name="alumne2",x=6,y=12,o="d",gfx={x=16,y=96}})
|
||||
actors.add({name="alumne3",x=4,y=10,o="d",gfx={x=96,y=64}})
|
||||
actors.add({name="alumne4",x=4,y=14,o="d",gfx={x=96,y=64}})
|
||||
actors.add({name="alumne5",x=14,y=14,o="d",gfx={x=64,y=64}})
|
||||
actors.add({name="alumne1",x=12,y=10,o="d",gfx={x=32,y=64},action=levels.prac2.alumne1_action})
|
||||
actors.add({name="alumne2",x=6,y=12,o="d",gfx={x=16,y=96},action=levels.prac2.alumne2_action})
|
||||
actors.add({name="alumne3",x=4,y=10,o="d",gfx={x=96,y=64},action=levels.prac2.alumne3_action})
|
||||
actors.add({name="alumne4",x=4,y=14,o="d",gfx={x=96,y=64},action=levels.prac2.alumne4_action})
|
||||
actors.add({name="alumne5",x=14,y=14,o="d",gfx={x=64,y=64},action=levels.prac2.alumne5_action})
|
||||
--actors.add({name="taza_usufondo",x=14,y=15,o="d",gfx={x=112,y=32},action=levels.jail1.taza_usufondo_action})
|
||||
--if not objects.search("diskito_usufondo") then actors.add({name="disquito_usufondo",x=15,y=10,o="d",gfx={x=96,y=32},action=levels.jail1.disquito_usufondo_action}) end
|
||||
|
||||
@@ -53,25 +53,60 @@ levels["prac2"]={
|
||||
|
||||
comp_updating_action=function()
|
||||
local hero = actors.search(actors.main.name)
|
||||
if hero.o~="d" then return end
|
||||
if hero.o~="u" then return end
|
||||
scene.start({
|
||||
function() balloon.show("NO VAN ELS COMPS\nESTAN TOTS ACTUALITZANT",2,"jailer",true,{x=1,w=15,h=2}) end
|
||||
function() balloon.show("SON COMPS DE PRÀCTIQUES\nESTAN MEGA CAPATS",2,"jailer",false,{x=1,w=15,h=2}) end
|
||||
})
|
||||
end,
|
||||
|
||||
comp_usufondo_action=function()
|
||||
comp_profe_action=function()
|
||||
local hero = actors.search(actors.main.name)
|
||||
if hero.o~="d" then return end
|
||||
if hero.o=="l" or hero.o=="d" then return end
|
||||
scene.start({
|
||||
function() balloon.show("ESTÀ BLOQUEJAT,\nI NO ME SÉ LA CONTRASENYA.",2,"jailer",true,{x=1,w=15,h=2}) end
|
||||
function() balloon.show("NO CREC QUE PUGA\nUSAR ESTE ORDENADOR.",2,"jailer",true,{x=3,w=14,h=2}) end
|
||||
})
|
||||
end,
|
||||
|
||||
taza_usufondo_action=function()
|
||||
profe_action=function()
|
||||
local hero = actors.search(actors.main.name)
|
||||
if hero.o~="d" then return end
|
||||
scene.start({
|
||||
function() balloon.show("EL CAFÉ DE USUFONDO.\nESTÀ GELAT COM EL COR DEL DIMONI!",2,"jailer",true,{x=1,w=15,h=2}) end
|
||||
function() actors.face("profe","jailer") scene.cont() end,
|
||||
function() balloon.show("¿QUÉ NECESITA,\nCABALLERETE?",2,"profe",true,{x=6,w=9,h=2}) end,
|
||||
function() balloon.show("TENGO MUCHO TRABAJO...\n¡ESTOS EXMANEMS\nNO SE CORRIGEN SÓLOS!",2,"profe",true,{x=2,w=15,h=3}) end,
|
||||
function() actors.search("profe").o="d" scene.cont() end,
|
||||
function() balloon.show("NO PUEDO LEVANTARME\nNI PARA IR AL BAÑO...",2,"profe",true,{x=3,w=14,h=2}) end,
|
||||
})
|
||||
end,
|
||||
|
||||
alumne1_action=function()
|
||||
scene.start({
|
||||
function() balloon.show("ESTA PRÀCTICA\nES UNA MERDA...",12,"alumne1",false,{x=6,w=10,h=2}) end,
|
||||
})
|
||||
end,
|
||||
|
||||
alumne2_action=function()
|
||||
scene.start({
|
||||
function() balloon.show("QUE FAM!",12,"alumne2",false,{x=5,w=7,h=1}) end,
|
||||
function() balloon.show("ME FARIA UN BON BOCATA\nDE 'SOBRASADA PATA'!",12,"alumne2",false,{x=2,w=14,h=2}) end,
|
||||
})
|
||||
end,
|
||||
|
||||
alumne3_action=function()
|
||||
scene.start({
|
||||
function() balloon.show("ESTIC FENT UN JAILGAME!",12,"alumne3",false,{x=2,w=14,h=1}) end,
|
||||
function() balloon.show("NOMÉS ME FALTEN\nELS MENÚS...",12,"alumne3",false,{x=2,w=10,h=2}) end,
|
||||
})
|
||||
end,
|
||||
|
||||
alumne4_action=function()
|
||||
scene.start({
|
||||
function() balloon.show("POS A MI ME MOLA DLO...",12,"alumne4",false,{x=2,w=14,h=1}) end,
|
||||
})
|
||||
end,
|
||||
|
||||
alumne5_action=function()
|
||||
scene.start({
|
||||
function() balloon.show("ZZZZ...",12,"alumne5",false,{x=10,w=6,h=1}) end,
|
||||
})
|
||||
end,
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ levels["repro"]={
|
||||
if hero.o=="u" then
|
||||
scene.start({
|
||||
function() balloon.show("NO POTS PASAR!",12,"currante1",false,{x=5,w=10,h=1}) end,
|
||||
function() balloon.show("NOMES EL QUALIFICAT PERSONAL\nDE REPROGRAFIA POR ENTRAR ACÍ",12,"currante1",false,{x=2,w=17,h=2}) end
|
||||
function() balloon.show("NOMES EL QUALIFICAT PERSONAL\nDE REPROGRAFIA POT ENTRAR ACÍ",12,"currante1",false,{x=2,w=17,h=2}) end
|
||||
})
|
||||
return true
|
||||
else
|
||||
|
||||
@@ -35,7 +35,7 @@ function text(txt,x,y,col)
|
||||
end
|
||||
|
||||
function main_init()
|
||||
set_update(menu_update)
|
||||
--set_update(menu_update)
|
||||
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 } }
|
||||
show_main_menu()
|
||||
|
||||
@@ -9,6 +9,7 @@ scene={
|
||||
end,
|
||||
|
||||
cont=function()
|
||||
game.draw()
|
||||
if scene.script==nil then return end
|
||||
scene.pos=scene.pos+1
|
||||
if scene.script[scene.pos]==nil then
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
switches={
|
||||
list={},
|
||||
col=0,
|
||||
|
||||
reset=function()
|
||||
switches.list={}
|
||||
end,
|
||||
|
||||
add=function(switch)
|
||||
if not switch.w then switch.w=1 end
|
||||
@@ -15,4 +20,14 @@ switches={
|
||||
end
|
||||
return nil
|
||||
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