From c2f7b470bf11cb7e8aecbe17be787b619d27b763 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Sat, 31 May 2025 14:29:29 +0200 Subject: [PATCH] - [NEW] Convertit a mini v1.0 RC2 --- data/actors.lua | 16 ++--- data/balloon.lua | 60 +++++++++---------- data/brymode.lua | 26 ++++---- data/editor.lua | 142 ++++++++++++++++++++++---------------------- data/fade.lua | 16 ++--- data/fileselect.lua | 34 +++++------ data/game.ini | 1 - data/game.lua | 64 ++++++++++---------- data/main.lua | 45 +++++++------- data/mapa.lua | 30 +++++----- data/menu.lua | 23 +++---- data/switches.lua | 2 +- data/textbox.lua | 22 +++---- data/wait.lua | 4 +- 14 files changed, 241 insertions(+), 244 deletions(-) diff --git a/data/actors.lua b/data/actors.lua index 129d4a0..68eb0a1 100644 --- a/data/actors.lua +++ b/data/actors.lua @@ -45,7 +45,7 @@ actors={ actors.search(name).o = o end, - draw=function() + display=function() actors.under_cursor="" for i,v in ipairs(actors.list) do if v.o=='' then goto continue end @@ -53,25 +53,25 @@ actors={ 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 mousex,mousey=mouse() + local mousex,mousey=mouse.pos() 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) + pal.subpal(1,16,8) end if v.o=='u' then - blit(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) + draw.surf(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 - blit(v.gfx.x+frame,v.gfx.y,16,16,x*8+v.dx*2,y*8-12+v.dy*2,16,16,-v.dy>2) + draw.surf(v.gfx.x+frame,v.gfx.y,16,16,x*8+v.dx*2,y*8-12+v.dy*2,16,16,-v.dy>2) elseif v.o=='l' then - blit(v.gfx.x+frame,v.gfx.y+32,16,16,x*8+v.dx*2,y*8-12+v.dy*2,16,16) + draw.surf(v.gfx.x+frame,v.gfx.y+32,16,16,x*8+v.dx*2,y*8-12+v.dy*2,16,16) elseif v.o=='r' then - blit(v.gfx.x+frame,v.gfx.y+32,16,16,x*8+v.dx*2,y*8-12+v.dy*2,16,16,true) + draw.surf(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 + if not key.down(key.LSHIFT) then pal.subpal() end ::continue:: end end, diff --git a/data/balloon.lua b/data/balloon.lua index 2aa4f0d..2d89227 100644 --- a/data/balloon.lua +++ b/data/balloon.lua @@ -38,36 +38,36 @@ balloon={ if below==nil or below==false then balloon.rect.y=balloon.rect.y-balloon.rect.h-16 local x,y,w,h=balloon.rect.x,balloon.rect.y,balloon.rect.w,balloon.rect.h - rectfill(x+1,y+1,x+w+1,y+h+1,5) - rectfill(x,y,x+w,y+h,8) - rect(x,y,x+w,y+h,6) + draw.rectf(x+1,y+1,w+1,h+1,5) + draw.rectf(x,y,w+1,h+1,8) + draw.rect(x,y,w+1,h+1,6) if pos<80 then - for i=0,4 do rect(pos,y+h+(4-i),pos+i,y+h+(4-i),8) end - line(pos-1,y+h+1,pos-1,y+h+6,6) - line(pos+4,y+h+1,pos-1,y+h+6,6) + for i=0,4 do draw.rect(pos,y+h+(4-i),i+1,2,8) end + draw.line(pos-1,y+h+1,pos-1,y+h+6,6) + draw.line(pos+4,y+h+1,pos-1,y+h+6,6) else pos=pos-5 - for i=0,4 do rect(pos+i,y+h+i,pos+4,y+h+i,8) end - line(pos+5,y+h+1,pos+5,y+h+6,6) - line(pos,y+h+1,pos+5,y+h+6,6) + for i=0,4 do draw.rect(pos+i,y+h+i,5-i,2,8) end + draw.line(pos+5,y+h+1,pos+5,y+h+6,6) + draw.line(pos,y+h+1,pos+5,y+h+6,6) end else balloon.rect.y=balloon.rect.y+16 local x,y,w,h=balloon.rect.x,balloon.rect.y,balloon.rect.w,balloon.rect.h - rectfill(x+1,y+1,x+w+1,y+h+1,5) - rectfill(x,y,x+w,y+h,8) - rect(x,y,x+w,y+h,6) + draw.rectf(x+1,y+1,w+1,h+1,5) + draw.rectf(x,y,w+1,h+1,8) + draw.rect(x,y,w+1,h+1,6) if pos<80 then - for i=0,4 do rect(pos,y-(4-i),pos+i,y-(4-i),8) end - line(pos-1,y,pos-1,y-6,6) - line(pos+5,y,pos-1,y-6,6) + for i=0,4 do draw.rect(pos,y-(4-i),i+1,2,8) end + draw.line(pos-1,y,pos-1,y-6,6) + draw.line(pos+5,y,pos-1,y-6,6) else pos=pos-5 - for i=0,4 do rect(pos+i,y-i,pos+4,y-i,8) end - line(pos+5,y,pos+5,y-6,6) - line(pos-1,y,pos+5,y-6,6) + for i=0,4 do draw.rect(pos+i,y-i,5-i,2,8) end + draw.line(pos+5,y,pos+5,y-6,6) + draw.line(pos-1,y,pos+5,y-6,6) end end @@ -87,15 +87,15 @@ balloon={ update=balloon.update local x,y,w,h=balloon.rect.x,balloon.rect.y,balloon.rect.w,balloon.rect.h - rectfill(x+1,y+1,x+w+1,y+h+1,5) - rectfill(x,y,x+w,y+h,15) - rect(x,y,x+w,y+h,6) + draw.rectf(x+1,y+1,w+1,h+1,5) + draw.rectf(x,y,w+1,h+1,15) + draw.rect(x,y,w+1,h+1,6) balloon.cursor={x=balloon.rect.x+12,y=balloon.rect.y+11} end, update=function() - if anykey() then + if key.any() then if balloon.pos<0 then update=balloon.old_update update() @@ -105,20 +105,20 @@ balloon={ end end - if not beat() and not balloon.quick then return end + if not sys.beat() and not balloon.quick then return end if balloon.pos<0 then if balloon.obj then - setsource(objectes) - blit(balloon.obj.x,balloon.obj.y,16,16,balloon.rect.x+balloon.rect.w-28,balloon.rect.y+10) + surf.source(objectes) + draw.surf(balloon.obj.x,balloon.obj.y,16,16,balloon.rect.x+balloon.rect.w-28,balloon.rect.y+10) end local col=8 - if math.floor(time()*4)%2==0 then col=10 end + if math.floor(sys.time()*4)%2==0 then col=10 end local x,y=balloon.rect.x+balloon.rect.w-8, balloon.rect.y+balloon.rect.h-6 - line(x,y,x+4,y,col) - line(x+1,y+1,x+3,y+1,col) - line(x+2,y+2,x+2,y+2,col) - if btnp(KEY_SPACE) then + draw.line(x,y,x+4,y,col) + draw.line(x+1,y+1,x+3,y+1,col) + draw.line(x+2,y+2,x+2,y+2,col) + if key.press(key.SPACE) then update=balloon.old_update end else diff --git a/data/brymode.lua b/data/brymode.lua index 678cb76..e37cf09 100644 --- a/data/brymode.lua +++ b/data/brymode.lua @@ -7,24 +7,24 @@ brymode = { update=brymode.update brymode.return_function=retfun - cls(0) - prnt("#include ",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) + surf.cls(0) + draw.text("#include ",1,1,8) + draw.text("int main(int argc, char *argv[])",1,1+6*2,8) + draw.text("{",1,1+6*3,8) + draw.text("SDL_Init(SDL_INIT_EVERYTHING);",21,1+6*4,8) + draw.text("SDL_Window *win=",21,1+6*6,8) + draw.text("SDL_CreateWindow('Title',320,240);",29,1+6*7,8) + draw.text("SDL_Renderer *ren =",21,1+6*9,8) + draw.text("SDL_CreateRenderer(win,-1,0);",29,1+6*10,8) + draw.text("SDL_Quit();",21,1+6*12,8) + draw.text("return 0;",21,1+6*13,8) + draw.text("}",1,1+6*14,8) end, update=function() --cls(0) - if btnp(KEY_ESCAPE) then + if key.press(key.ESCAPE) then if brymode.return_function then update=brymode.old_update brymode.return_function() diff --git a/data/editor.lua b/data/editor.lua index 6ed5ff0..141f728 100644 --- a/data/editor.lua +++ b/data/editor.lua @@ -28,35 +28,35 @@ editor={ end, reload_textures=function() - freesurf(sprites) - freesurf(objectes) - freesurf(tiles) - sprites=loadsurf("sprites.gif") - objectes=loadsurf("objects.gif") - tiles=loadsurf("tiles.gif") - setsource(tiles) - local pal=loadpal("tiles.gif") - setpal(pal) + surf.free(sprites) + surf.free(objectes) + surf.free(tiles) + sprites=surf.load("sprites.gif") + objectes=surf.load("objects.gif") + tiles=surf.load("tiles.gif") + surf.source(tiles) + local p=pal.load("tiles.gif") + pal.set(p) editor.paused=false end, toggle_front_layer=function() if editor.editing_front_layer then - setmap(mapa.surface) + map.set(mapa.surface) editor.editing_front_layer=false; else if not mapa.front_layer then - mapa.front_layer=newsurf(mapa.w,mapa.h) + mapa.front_layer=surf.new(mapa.w,mapa.h) editor.editing_front_layer=true - setmap(mapa.front_layer) + map.set(mapa.front_layer) for y=0,mapa.h-1 do for x=0,mapa.w-1 do - mset(x,y,0) + map.tile(x,y,0) end end else editor.editing_front_layer=true - setmap(mapa.front_layer) + map.set(mapa.front_layer) end end editor.paused=false @@ -76,27 +76,27 @@ editor={ local old_surface= mapa.surface mapa.w=tonumber(editor.new_w) mapa.h=tonumber(editor.new_h) - mapa.surface=newsurf(mapa.w,mapa.h) + mapa.surface=surf.new(mapa.w,mapa.h) for y=0,mapa.h-1 do for x=0,mapa.w-1 do - setmap(old_surface) - local value=mget(x,y) - setmap(mapa.surface) - mset(x,y,value) + map.set(old_surface) + local value=map.tile(x,y) + map.set(mapa.surface) + map.tile(x,y,value) end end - freesurf(old_surface) - setmap(mapa.surface) + surf.free(old_surface) + map.set(mapa.surface) editor.paused=false end, floodfill=function(x,y,tile) - local t=mget(x,y) - mset(x,y,tile) - if x0 and mget(x-1,y)==t then editor.floodfill(x-1,y,tile) end - if y0 and mget(x,y-1)==t then editor.floodfill(x,y-1,tile) end + local t=map.tile(x,y) + map.tile(x,y,tile) + if x0 and map.tile(x-1,y)==t then editor.floodfill(x-1,y,tile) end + if y0 and map.tile(x,y-1)==t then editor.floodfill(x,y-1,tile) end end, create_stamp=function() @@ -109,8 +109,8 @@ editor={ local p=1 for y=1,h do for x=1,w do - editor.brush.tiles[p]=mget(tx1+x-1,ty1+y-1) - --mset(tx+x-1,ty+y-1,editor.brush.tiles[p]) + editor.brush.tiles[p]=map.tile(tx1+x-1,ty1+y-1) + --map.tile(tx+x-1,ty+y-1,editor.brush.tiles[p]) p=p+1 end end @@ -122,7 +122,7 @@ editor={ local p=1 for y=1,h do for x=1,w do - mset(tx+x-1,ty+y-1,editor.brush.tiles[p]) + map.tile(tx+x-1,ty+y-1,editor.brush.tiles[p]) p=p+1 end end @@ -133,57 +133,57 @@ editor={ if dx>0 then for y=0,h-1 do for x=w-1,1,-1 do - mset(x,y,mget(x-1,y)) + map.tile(x,y,map.tile(x-1,y)) end end elseif dx<0 then for y=0,h-1 do for x=0,w-2 do - mset(x,y,mget(x+1,y)) + map.tile(x,y,map.tile(x+1,y)) end end elseif dy>0 then for y=h-1,1,-1 do for x=0,w-1 do - mset(x,y,mget(x,y-1)) + map.tile(x,y,map.tile(x,y-1)) end end elseif dy<0 then for y=0,h-2 do for x=0,w-1 do - mset(x,y,mget(x,y+1)) + map.tile(x,y,map.tile(x,y+1)) end end end end, update=function() - cls() - camera(editor.cam.x, editor.cam.y) - setsource(tiles) - setmap(mapa.surface) - map(0,0,0,0,mapa.w, mapa.h) + surf.cls() + view.origin(editor.cam.x, editor.cam.y) + surf.source(tiles) + map.set(mapa.surface) + map.draw() --map(0,0,0,0,mapa.w, mapa.h) if mapa.front_layer then - setmap(mapa.front_layer) - map(0,0,0,0,mapa.w, mapa.h) + map.set(mapa.front_layer) + map.draw() --map(0,0,0,0,mapa.w, mapa.h) end if editor.editing_front_layer then - setmap(mapa.front_layer) + map.set(mapa.front_layer) text("EDITING FRONT LAYER",12,2,10) else - setmap(mapa.surface) + map.set(mapa.surface) end - local mx,my=mouse() + local mx,my=mouse.pos() local tx,ty=(mx+editor.cam.x)>>3,(my+editor.cam.y)>>3 local rx,ry=tx<<3,ty<<3 - rect(rx-1, ry-1, rx+8, ry+8, 10) + draw.rect(rx-1, ry-1, 10, 10, 10) if editor.selection then local rx1,ry1,rx2,ry2=editor.selection.x1<<3,editor.selection.y1<<3,editor.selection.x2<<3,editor.selection.y2<<3 if rx1>rx2 then rx1,rx2=rx2,rx1 end if ry1>ry2 then ry1,ry2=ry2,ry1 end - rect(rx1-1, ry1-1, rx2+8, ry2+8, 8) + draw.rect(rx1-1, ry1-1, rx2-rx1+10, ry2-ry1+10, 8) end - camera(0,0) + view.origin(0,0) if tx>=0 and ty>=0 and tx>3,my>>3 local rx,ry=tx<<3,ty<<3 - rect(rx-1, ry-1, rx+8, ry+8, 10) + draw.rect(rx-1, ry-1, 10, 10, 10) - if btnp(KEY_TAB) or btnp(KEY_ESCAPE) then + if key.press(key.TAB) or key.press(key.ESCAPE) then update=editor.update end - if mbtnp(1) then + if mouse.press(mouse.LEFT) then if tx<16 and ty<16 then editor.brush.w=1 editor.brush.h=1 diff --git a/data/fade.lua b/data/fade.lua index d301da8..94c409d 100644 --- a/data/fade.lua +++ b/data/fade.lua @@ -9,7 +9,7 @@ fade={ init = function() for i=1,16 do - local r,g,b=palcolor(i) + local r,g,b=pal.color(i) fade.pal[i]={r,g,b} end end, @@ -38,13 +38,13 @@ fade={ end, update_fadeout=function() - if beat() then + if sys.beat() then for i=1,16 do local v=fade.getstep(i,fade.step) if v==0 then - palcolor(i,0,0,0) + pal.color(i,0,0,0) else - palcolor(i,fade.pal[v][1],fade.pal[v][2],fade.pal[v][3]) + pal.color(i,fade.pal[v][1],fade.pal[v][2],fade.pal[v][3]) end end fade.step=fade.step+1 @@ -66,19 +66,19 @@ fade={ fade.old_update=update update=fade.update_fadein fade.step=6 - for i=1,16 do palcolor(i,0,0,0) end + for i=1,16 do pal.color(i,0,0,0) end end, update_fadein=function() fade.old_update() - if beat() then + if sys.beat() then for i=1,16 do local v=fade.getstep(i,fade.step) if v==0 then - palcolor(i,0,0,0) + pal.color(i,0,0,0) else - palcolor(i,fade.pal[v][1],fade.pal[v][2],fade.pal[v][3]) + pal.color(i,fade.pal[v][1],fade.pal[v][2],fade.pal[v][3]) end end fade.step=fade.step-1 diff --git a/data/fileselect.lua b/data/fileselect.lua index 4867f26..0e574b4 100644 --- a/data/fileselect.lua +++ b/data/fileselect.lua @@ -20,23 +20,23 @@ fileselect={ end, update=function() - rectfill(10,10, 150, 130,5) - rect(10,10, 150, 130,8) - if fileselect.title then prnt(fileselect.title,20,13) end - rectfill(20,20, 140, 120,6) + draw.rectf(10,10, 140, 120,5) + draw.rect(10,10, 140, 120,8) + if fileselect.title then draw.text(fileselect.title,20,13,8) end + draw.rectf(20,20, 120, 100,6) local i = 22 for k,dir in pairs(fileselect.file_list) do - color(8) + local color=8 if k==fileselect.selected then - rectfill(20,i-2, 140, i+6,11) - color(15) + draw.rectf(20,i-1, 120, 8,11) + color=15 end - prnt(dir, 23, i) + draw.text(dir, 23, i, color) i=i+7 end - rect(20,20, 140, 120,8) + draw.rect(20,20, 120, 100,8) - local mx,my=mouse() + local mx,my=mouse.pos() if (mx~=fileselect.old_mx or my~=fileselect.old_my) then fileselect.old_mx,fileselect.old_my=mx,my if mx>20 and mx<140 and my>20 and my<120 then @@ -46,7 +46,7 @@ fileselect={ end end end - if mbtnp(1) then + if mouse.press(mouse.LEFT) then if mx>20 and mx<140 and my>20 and my<120 then local y = math.floor((my-21)/7)+1 if (y<=#fileselect.file_list) then @@ -57,20 +57,20 @@ fileselect={ end end -- if textbox.value then --- prnt(textbox.value,43,73) +-- draw.text(textbox.value,43,73) -- if (math.floor(time()*4)%2)==0 then --- prnt("_",43+#textbox.value*4,73) +-- draw.text("_",43+#textbox.value*4,73) -- end -- end -- - local tecla=btnp() - if tecla==KEY_DOWN then + local tecla=key.press() + if tecla==key.DOWN then if fileselect.selected < #fileselect.file_list then fileselect.selected = fileselect.selected + 1 end - elseif tecla==KEY_UP then + elseif tecla==key.UP then if fileselect.selected > 1 then fileselect.selected = fileselect.selected - 1 end -- elseif tecla==KEY_BACKSPACE then -- textbox.value=string.sub(textbox.value,1,-2) - elseif tecla==KEY_RETURN then + elseif tecla==key.RETURN then update=fileselect.old_update fileselect.return_function(fileselect.file_list[fileselect.selected]) end diff --git a/data/game.ini b/data/game.ini index b01005d..94d6860 100644 --- a/data/game.ini +++ b/data/game.ini @@ -3,4 +3,3 @@ config=ja2 width=160 height=144 zoom=4 -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 diff --git a/data/game.lua b/data/game.lua index 8d7e8e4..3b86a9c 100644 --- a/data/game.lua +++ b/data/game.lua @@ -63,7 +63,7 @@ game={ save=function() local i=1 - file = io.open(configfolder().."slot"..i..".txt", "w") + file = io.open(config.folder().."slot"..i..".txt", "w") if file then io.output(file) io.write("level="..game.level.."\n") @@ -86,7 +86,7 @@ game={ load=function() local i=1 - file = io.open(configfolder().."slot"..i..".txt", "r") + file = io.open(config.folder().."slot"..i..".txt", "r") local level_name = "" local new_flags={} local new_objects={} @@ -97,7 +97,7 @@ game={ local k,v=getkeyval(io.read()) actors.main.x=tonumber(v) local k,v=getkeyval(io.read()) actors.main.y=tonumber(v) local k,v=getkeyval(io.read()) actors.main.o=v - io.read() -- ignore "[FLAGS]" line + local ignore = io.read() -- ignore "[FLAGS]" line local line = io.read() while line ~= "[OBJECTS]" do local k,v=getkeyval(line) @@ -120,17 +120,17 @@ game={ 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) + surf.cls(6) + view.origin(game.cam.x, game.cam.y) + surf.source(tiles) + map.set(mapa.surface) + map.draw()--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() - local mx,my=mouse() + surf.source(sprites) + if key.down(key.LSHIFT) then pal.subpal(1,16,8) end + actors.display() + pal.subpal() + local mx,my=mouse.pos() if actors.under_cursor~="" then if (mx<=80) then text(actors.under_cursor,mx+game.cam.x+4,my+game.cam.y+4,9) @@ -140,13 +140,13 @@ game={ end end if mapa.front_layer then - setsource(tiles) - setmap(mapa.front_layer) - map(0,0,0,0,mapa.w, mapa.h) + surf.source(tiles) + map.set(mapa.front_layer) + map.draw() -- map(0,0,0,0,mapa.w, mapa.h) end - setmap(mapa.surface) - camera(0,0) - for i=0,15 do rectfill(20+i*4,0,20+i*4+4,4,i) end + map.set(mapa.surface) + view.origin(0,0) + for i=0,15 do draw.rectf(20+i*4,0,4,4,i) end end, update=function() @@ -164,7 +164,7 @@ game={ game.draw() - local mx,my=mouse() + local mx,my=mouse.pos() text(math.floor((mx+game.cam.x)/8)..","..math.floor((my+game.cam.y)/8),1,19,8) text(game.cam.x..","..game.cam.y,1,1,8) @@ -174,37 +174,37 @@ game={ text(game.level,1,13,8) if not scene.script and hero and not hero.path and hero.dx+hero.dy==0 then - if btn(KEY_DOWN) then + if key.down(key.DOWN) then hero.path={pos=0,route='d',keys=true} - elseif btn(KEY_UP) then + elseif key.down(key.UP) then hero.path={pos=0,route='u',keys=true} - elseif btn(KEY_LEFT) then + elseif key.down(key.LEFT) then hero.path={pos=0,route='l',keys=true} - elseif btn(KEY_RIGHT) then + elseif key.down(key.RIGHT) then hero.path={pos=0,route='r',keys=true} - elseif btnp(KEY_SPACE) then + elseif key.press(key.SPACE) then actors.interact(hero.x,hero.y,hero.o) end end - if btnp(KEY_ESCAPE) then + if key.press(key.ESCAPE) then game.show_menu() end - if beat() then actors.update() end + if sys.beat() then actors.update() end end, pause=function() game.paused = true - rectfill(9,84, 150, 128,6) - rect(9,84, 150, 128,8) - rect(8,83, 151, 129,6) + draw.rectf(9,84, 141, 44,6) + draw.rect(9,84, 141, 44,8) + draw.rect(8,83, 143, 46,6) text("OBJECTES:",14,82,8) - setsource(objectes) + surf.source(objectes) local x,y=15,90 for i,name in ipairs(objects.list) do local obj = object[name] - blit(obj.x,obj.y,16,16,x,y) + draw.surf(obj.x,obj.y,16,16,x,y) x=x+19 if x==148 then x,y=15,y+19 end end diff --git a/data/main.lua b/data/main.lua index 895c111..4ca5f5b 100644 --- a/data/main.lua +++ b/data/main.lua @@ -3,41 +3,39 @@ require "game" require "editor" require "menu" -function _init() +function mini.init() menu_option=0 - sprites=loadsurf("sprites.gif") - objectes=loadsurf("objects.gif") - tiles=loadsurf("tiles.gif") - setsource(tiles) - local pal=loadpal("tiles.gif") - setpal(pal) - beat(6) + objectes=surf.load("objects.gif") + tiles=surf.load("tiles.gif") + surf.source(tiles) + local p=pal.load("tiles.gif") + pal.set(p) + sprites=surf.load("sprites.gif") + sys.beat(6) fade.init() main_init() end -function _update() +function mini.update() update() end function text(txt,x,y,col) - color(6) - prnt(txt,x-1,y-1) - prnt(txt,x,y-1) - prnt(txt,x+1,y-1) - prnt(txt,x-1,y) - prnt(txt,x+1,y) - prnt(txt,x-1,y+1) - prnt(txt,x,y+1) - prnt(txt,x+1,y+1) - color(col) - prnt(txt,x,y) + draw.text(txt,x-1,y-1,6) + draw.text(txt,x,y-1,6) + draw.text(txt,x+1,y-1,6) + draw.text(txt,x-1,y,6) + draw.text(txt,x+1,y,6) + draw.text(txt,x-1,y+1,6) + draw.text(txt,x,y+1,6) + draw.text(txt,x+1,y+1,6) + draw.text(txt,x,y,col) end function main_init() --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 } } + main_menu = { {"JUGAR", game.restart}, {"EDITOR", editor.init}, {"EIXIR", sys.quit}, {"TEST", function() menu.show(second_menu) end } } show_main_menu() end @@ -50,9 +48,8 @@ function set_update(new_update) end function menu_update() - cls() - color(1) - prnt("JAIL'S ADVENTURE 2",10,10) + surf.cls() + draw.text("JAIL'S ADVENTURE 2",10,10,1) end function getkeyval(str) diff --git a/data/mapa.lua b/data/mapa.lua index 8ad5afb..11192e3 100644 --- a/data/mapa.lua +++ b/data/mapa.lua @@ -2,17 +2,17 @@ mapa={ name=nil, w=128, h=128, - surface=nil, + surface=-1, new = function(w,h) mapa.name=nil mapa.w,mapa.h=w,h - if mapa.surface~=nil then freesurf(mapa.surface) end - mapa.surface=newsurf(w,h) - setmap(mapa.surface) + if mapa.surface~=-1 then surf.free(mapa.surface) end + mapa.surface=surf.new(w,h) + map.set(mapa.surface) for y=0,127 do for x=0,127 do - mset(x,y,0) + map.tile(x,y,0) end end mapa.front_layer=nil @@ -32,25 +32,25 @@ mapa={ local line = io.read() local x=0 for m in string.gmatch(line, "%d+") do - mset(x,y,m) + map.tile(x,y,m) x=x+1 end end if num_layers==2 then - mapa.front_layer=newsurf(mapa.w,mapa.h) - setmap(mapa.front_layer) + mapa.front_layer=surf.new(mapa.w,mapa.h) + map.set(mapa.front_layer) for y=0,mapa.h-1 do local line = io.read() local x=0 for m in string.gmatch(line, "%d+") do - mset(x,y,m) + map.tile(x,y,m) x=x+1 end end end - setmap(mapa.surface) + map.set(mapa.surface) io.close(file) end end, @@ -63,18 +63,18 @@ mapa={ io.write(mapa.w.."\n") io.write(mapa.h.."\n") if mapa.front_layer then io.write("2\n") else io.write("1\n") end - setmap(mapa.surface) + map.set(mapa.surface) for y=0,mapa.h-1 do for x=0,mapa.w-1 do - io.write(mget(x,y)..",") + io.write(map.tile(x,y)..",") end io.write("\n") end if mapa.front_layer then - setmap(mapa.front_layer) + map.set(mapa.front_layer) for y=0,mapa.h-1 do for x=0,mapa.w-1 do - io.write(mget(x,y)..",") + io.write(map.tile(x,y)..",") end io.write("\n") end @@ -84,6 +84,6 @@ mapa={ end, check_collision=function(x,y) - return mget(x,y) >= 32 or mget(x+1,y) >= 32 + return map.tile(x,y) >= 32 or map.tile(x+1,y) >= 32 end } \ No newline at end of file diff --git a/data/menu.lua b/data/menu.lua index 95dbde7..bd81974 100644 --- a/data/menu.lua +++ b/data/menu.lua @@ -15,35 +15,36 @@ menu = { update=function() --menu.old_update() - rectfill(9,20, 150, 34+#menu.options*10,6) - rect(9,20, 150, 34+#menu.options*10,8) - rect(8,19, 151, 35+#menu.options*10,6) + draw.rectf(9,20, 141, 14+#menu.options*10,6) + draw.rect(9,20, 141, 14+#menu.options*10,8) + draw.rect(8,19, 143, 16+#menu.options*10,6) for i,v in ipairs(menu.options) do - color(4) if menu.selected==i then color(15) prnt(">",20,20+i*10) end - prnt(v[1],24,20+i*10) + local color=4 + if menu.selected==i then color=15 draw.text(">",20,20+i*10,color) end + draw.text(v[1],24,20+i*10,color) end - if btnp(KEY_DOWN) then menu.selected=menu.selected+1 end - if btnp(KEY_UP) then menu.selected=menu.selected-1 end + if key.press(key.DOWN) then menu.selected=menu.selected+1 end + if key.press(key.UP) then menu.selected=menu.selected-1 end if menu.selected==0 then menu.selected=#menu.options end if menu.selected>#menu.options then menu.selected=1 end - local mx,my=mouse() + local mx,my=mouse.pos() if mx>=20 and mx<=140 and my>=28 and my<=(28+#menu.options*10) then menu.selected=math.min(1+math.floor((my-28)/10),#menu.options) - if mbtnp(1) then + if mouse.press(mouse.LEFT) then update=menu.old_update menu.options[menu.selected][2]() end end - if btnp(KEY_RETURN) then + if key.press(key.RETURN) then update=menu.old_update menu.options[menu.selected][2]() end - if btnp(KEY_ESCAPE) then + if key.press(key.ESCAPE) then if menu.return_function then update=menu.old_update menu.return_function() diff --git a/data/switches.lua b/data/switches.lua index 3b4f709..84e5415 100644 --- a/data/switches.lua +++ b/data/switches.lua @@ -25,7 +25,7 @@ switches={ 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); + draw.rect(v.x*8, v.y*8, (v.w+1)*8, (v.h)*8, 8); end end switches.col=(switches.col+1)%32 diff --git a/data/textbox.lua b/data/textbox.lua index adb06a6..e6e2fd5 100644 --- a/data/textbox.lua +++ b/data/textbox.lua @@ -15,25 +15,25 @@ textbox={ end, update=function() - rectfill(20,50, 140, 90,6) - rect(20,50, 140, 90,8) - if textbox.title then prnt(textbox.title,30,55) end - rect(40,70, 120, 80,8) + draw.rectf(20,50, 120, 40,6) + draw.rect(20,50, 120, 40,8) + if textbox.title then draw.text(textbox.title,30,55,8) end + draw.rect(40,70, 80, 11,8) if textbox.value then - prnt(textbox.value,43,73) - if (math.floor(time()*4)%2)==0 then - prnt("_",43+#textbox.value*4,73) + draw.text(textbox.value,43,73,8) + if (math.floor(sys.time()*4)%2)==0 then + draw.text("_",43+#textbox.value*4,73,8) end end - local tecla=btnp() + local tecla=key.press() if tecla>=4 and tecla<=39 then textbox.value=textbox.value..string.sub(keyvalues,tecla,tecla) - elseif tecla==KEY_PERIOD then + elseif tecla==key.PERIOD then textbox.value=textbox.value.."." - elseif tecla==KEY_BACKSPACE then + elseif tecla==key.BACKSPACE then textbox.value=string.sub(textbox.value,1,-2) - elseif tecla==KEY_RETURN then + elseif tecla==key.RETURN then update=textbox.old_update textbox.return_function(textbox.value) end diff --git a/data/wait.lua b/data/wait.lua index c80858d..942dd45 100644 --- a/data/wait.lua +++ b/data/wait.lua @@ -7,12 +7,12 @@ wait={ wait.old_update=update update=wait.update wait.total_time=seconds - wait.start_time=time() + wait.start_time=sys.time() end, update=function() wait.old_update() - if wait.total_time <= time()-wait.start_time then + if wait.total_time <= sys.time()-wait.start_time then update=wait.old_update scene.cont() end