- [NEW] Convertit a mini v1.0 RC2
This commit is contained in:
@@ -45,7 +45,7 @@ actors={
|
|||||||
actors.search(name).o = o
|
actors.search(name).o = o
|
||||||
end,
|
end,
|
||||||
|
|
||||||
draw=function()
|
display=function()
|
||||||
actors.under_cursor=""
|
actors.under_cursor=""
|
||||||
for i,v in ipairs(actors.list) do
|
for i,v in ipairs(actors.list) do
|
||||||
if v.o=='' then goto continue end
|
if v.o=='' then goto continue end
|
||||||
@@ -53,25 +53,25 @@ actors={
|
|||||||
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 mousex,mousey=mouse()
|
local mousex,mousey=mouse.pos()
|
||||||
local mx = math.floor((mousex+game.cam.x)/8)
|
local mx = math.floor((mousex+game.cam.x)/8)
|
||||||
local my = math.floor((mousey+game.cam.y)/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
|
if (mx==x or mx==x+1) and (my==y or my==y-1) then
|
||||||
actors.under_cursor=v.name
|
actors.under_cursor=v.name
|
||||||
subpal(1,16,8)
|
pal.subpal(1,16,8)
|
||||||
end
|
end
|
||||||
|
|
||||||
if v.o=='u' then
|
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
|
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
|
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
|
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
|
end
|
||||||
|
|
||||||
if not btn(KEY_LSHIFT) then subpal() end
|
if not key.down(key.LSHIFT) then pal.subpal() end
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -38,36 +38,36 @@ balloon={
|
|||||||
if below==nil or below==false then
|
if below==nil or below==false then
|
||||||
balloon.rect.y=balloon.rect.y-balloon.rect.h-16
|
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
|
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)
|
draw.rectf(x+1,y+1,w+1,h+1,5)
|
||||||
rectfill(x,y,x+w,y+h,8)
|
draw.rectf(x,y,w+1,h+1,8)
|
||||||
rect(x,y,x+w,y+h,6)
|
draw.rect(x,y,w+1,h+1,6)
|
||||||
|
|
||||||
if pos<80 then
|
if pos<80 then
|
||||||
for i=0,4 do rect(pos,y+h+(4-i),pos+i,y+h+(4-i),8) end
|
for i=0,4 do draw.rect(pos,y+h+(4-i),i+1,2,8) end
|
||||||
line(pos-1,y+h+1,pos-1,y+h+6,6)
|
draw.line(pos-1,y+h+1,pos-1,y+h+6,6)
|
||||||
line(pos+4,y+h+1,pos-1,y+h+6,6)
|
draw.line(pos+4,y+h+1,pos-1,y+h+6,6)
|
||||||
else
|
else
|
||||||
pos=pos-5
|
pos=pos-5
|
||||||
for i=0,4 do rect(pos+i,y+h+i,pos+4,y+h+i,8) end
|
for i=0,4 do draw.rect(pos+i,y+h+i,5-i,2,8) end
|
||||||
line(pos+5,y+h+1,pos+5,y+h+6,6)
|
draw.line(pos+5,y+h+1,pos+5,y+h+6,6)
|
||||||
line(pos,y+h+1,pos+5,y+h+6,6)
|
draw.line(pos,y+h+1,pos+5,y+h+6,6)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
balloon.rect.y=balloon.rect.y+16
|
balloon.rect.y=balloon.rect.y+16
|
||||||
local x,y,w,h=balloon.rect.x,balloon.rect.y,balloon.rect.w,balloon.rect.h
|
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)
|
draw.rectf(x+1,y+1,w+1,h+1,5)
|
||||||
rectfill(x,y,x+w,y+h,8)
|
draw.rectf(x,y,w+1,h+1,8)
|
||||||
rect(x,y,x+w,y+h,6)
|
draw.rect(x,y,w+1,h+1,6)
|
||||||
|
|
||||||
if pos<80 then
|
if pos<80 then
|
||||||
for i=0,4 do rect(pos,y-(4-i),pos+i,y-(4-i),8) end
|
for i=0,4 do draw.rect(pos,y-(4-i),i+1,2,8) end
|
||||||
line(pos-1,y,pos-1,y-6,6)
|
draw.line(pos-1,y,pos-1,y-6,6)
|
||||||
line(pos+5,y,pos-1,y-6,6)
|
draw.line(pos+5,y,pos-1,y-6,6)
|
||||||
else
|
else
|
||||||
pos=pos-5
|
pos=pos-5
|
||||||
for i=0,4 do rect(pos+i,y-i,pos+4,y-i,8) end
|
for i=0,4 do draw.rect(pos+i,y-i,5-i,2,8) end
|
||||||
line(pos+5,y,pos+5,y-6,6)
|
draw.line(pos+5,y,pos+5,y-6,6)
|
||||||
line(pos-1,y,pos+5,y-6,6)
|
draw.line(pos-1,y,pos+5,y-6,6)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -87,15 +87,15 @@ balloon={
|
|||||||
update=balloon.update
|
update=balloon.update
|
||||||
|
|
||||||
local x,y,w,h=balloon.rect.x,balloon.rect.y,balloon.rect.w,balloon.rect.h
|
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)
|
draw.rectf(x+1,y+1,w+1,h+1,5)
|
||||||
rectfill(x,y,x+w,y+h,15)
|
draw.rectf(x,y,w+1,h+1,15)
|
||||||
rect(x,y,x+w,y+h,6)
|
draw.rect(x,y,w+1,h+1,6)
|
||||||
|
|
||||||
balloon.cursor={x=balloon.rect.x+12,y=balloon.rect.y+11}
|
balloon.cursor={x=balloon.rect.x+12,y=balloon.rect.y+11}
|
||||||
end,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
if anykey() then
|
if key.any() then
|
||||||
if balloon.pos<0 then
|
if balloon.pos<0 then
|
||||||
update=balloon.old_update
|
update=balloon.old_update
|
||||||
update()
|
update()
|
||||||
@@ -105,20 +105,20 @@ balloon={
|
|||||||
end
|
end
|
||||||
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.pos<0 then
|
||||||
if balloon.obj then
|
if balloon.obj then
|
||||||
setsource(objectes)
|
surf.source(objectes)
|
||||||
blit(balloon.obj.x,balloon.obj.y,16,16,balloon.rect.x+balloon.rect.w-28,balloon.rect.y+10)
|
draw.surf(balloon.obj.x,balloon.obj.y,16,16,balloon.rect.x+balloon.rect.w-28,balloon.rect.y+10)
|
||||||
end
|
end
|
||||||
local col=8
|
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
|
local x,y=balloon.rect.x+balloon.rect.w-8, balloon.rect.y+balloon.rect.h-6
|
||||||
line(x,y,x+4,y,col)
|
draw.line(x,y,x+4,y,col)
|
||||||
line(x+1,y+1,x+3,y+1,col)
|
draw.line(x+1,y+1,x+3,y+1,col)
|
||||||
line(x+2,y+2,x+2,y+2,col)
|
draw.line(x+2,y+2,x+2,y+2,col)
|
||||||
if btnp(KEY_SPACE) then
|
if key.press(key.SPACE) then
|
||||||
update=balloon.old_update
|
update=balloon.old_update
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -7,24 +7,24 @@ brymode = {
|
|||||||
update=brymode.update
|
update=brymode.update
|
||||||
brymode.return_function=retfun
|
brymode.return_function=retfun
|
||||||
|
|
||||||
cls(0)
|
surf.cls(0)
|
||||||
prnt("#include <stdio.h>",1,1,8)
|
draw.text("#include <stdio.h>",1,1,8)
|
||||||
prnt("int main(int argc, char *argv[])",1,1+6*2,8)
|
draw.text("int main(int argc, char *argv[])",1,1+6*2,8)
|
||||||
prnt("{",1,1+6*3,8)
|
draw.text("{",1,1+6*3,8)
|
||||||
prnt("SDL_Init(SDL_INIT_EVERYTHING);",21,1+6*4,8)
|
draw.text("SDL_Init(SDL_INIT_EVERYTHING);",21,1+6*4,8)
|
||||||
prnt("SDL_Window *win=",21,1+6*6,8)
|
draw.text("SDL_Window *win=",21,1+6*6,8)
|
||||||
prnt("SDL_CreateWindow('Title',320,240);",29,1+6*7,8)
|
draw.text("SDL_CreateWindow('Title',320,240);",29,1+6*7,8)
|
||||||
prnt("SDL_Renderer *ren =",21,1+6*9,8)
|
draw.text("SDL_Renderer *ren =",21,1+6*9,8)
|
||||||
prnt("SDL_CreateRenderer(win,-1,0);",29,1+6*10,8)
|
draw.text("SDL_CreateRenderer(win,-1,0);",29,1+6*10,8)
|
||||||
prnt("SDL_Quit();",21,1+6*12,8)
|
draw.text("SDL_Quit();",21,1+6*12,8)
|
||||||
prnt("return 0;",21,1+6*13,8)
|
draw.text("return 0;",21,1+6*13,8)
|
||||||
prnt("}",1,1+6*14,8)
|
draw.text("}",1,1+6*14,8)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
--cls(0)
|
--cls(0)
|
||||||
|
|
||||||
if btnp(KEY_ESCAPE) then
|
if key.press(key.ESCAPE) then
|
||||||
if brymode.return_function then
|
if brymode.return_function then
|
||||||
update=brymode.old_update
|
update=brymode.old_update
|
||||||
brymode.return_function()
|
brymode.return_function()
|
||||||
|
|||||||
142
data/editor.lua
142
data/editor.lua
@@ -28,35 +28,35 @@ editor={
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
reload_textures=function()
|
reload_textures=function()
|
||||||
freesurf(sprites)
|
surf.free(sprites)
|
||||||
freesurf(objectes)
|
surf.free(objectes)
|
||||||
freesurf(tiles)
|
surf.free(tiles)
|
||||||
sprites=loadsurf("sprites.gif")
|
sprites=surf.load("sprites.gif")
|
||||||
objectes=loadsurf("objects.gif")
|
objectes=surf.load("objects.gif")
|
||||||
tiles=loadsurf("tiles.gif")
|
tiles=surf.load("tiles.gif")
|
||||||
setsource(tiles)
|
surf.source(tiles)
|
||||||
local pal=loadpal("tiles.gif")
|
local p=pal.load("tiles.gif")
|
||||||
setpal(pal)
|
pal.set(p)
|
||||||
editor.paused=false
|
editor.paused=false
|
||||||
end,
|
end,
|
||||||
|
|
||||||
toggle_front_layer=function()
|
toggle_front_layer=function()
|
||||||
if editor.editing_front_layer then
|
if editor.editing_front_layer then
|
||||||
setmap(mapa.surface)
|
map.set(mapa.surface)
|
||||||
editor.editing_front_layer=false;
|
editor.editing_front_layer=false;
|
||||||
else
|
else
|
||||||
if not mapa.front_layer then
|
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
|
editor.editing_front_layer=true
|
||||||
setmap(mapa.front_layer)
|
map.set(mapa.front_layer)
|
||||||
for y=0,mapa.h-1 do
|
for y=0,mapa.h-1 do
|
||||||
for x=0,mapa.w-1 do
|
for x=0,mapa.w-1 do
|
||||||
mset(x,y,0)
|
map.tile(x,y,0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
editor.editing_front_layer=true
|
editor.editing_front_layer=true
|
||||||
setmap(mapa.front_layer)
|
map.set(mapa.front_layer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
editor.paused=false
|
editor.paused=false
|
||||||
@@ -76,27 +76,27 @@ editor={
|
|||||||
local old_surface= mapa.surface
|
local old_surface= mapa.surface
|
||||||
mapa.w=tonumber(editor.new_w)
|
mapa.w=tonumber(editor.new_w)
|
||||||
mapa.h=tonumber(editor.new_h)
|
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 y=0,mapa.h-1 do
|
||||||
for x=0,mapa.w-1 do
|
for x=0,mapa.w-1 do
|
||||||
setmap(old_surface)
|
map.set(old_surface)
|
||||||
local value=mget(x,y)
|
local value=map.tile(x,y)
|
||||||
setmap(mapa.surface)
|
map.set(mapa.surface)
|
||||||
mset(x,y,value)
|
map.tile(x,y,value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
freesurf(old_surface)
|
surf.free(old_surface)
|
||||||
setmap(mapa.surface)
|
map.set(mapa.surface)
|
||||||
editor.paused=false
|
editor.paused=false
|
||||||
end,
|
end,
|
||||||
|
|
||||||
floodfill=function(x,y,tile)
|
floodfill=function(x,y,tile)
|
||||||
local t=mget(x,y)
|
local t=map.tile(x,y)
|
||||||
mset(x,y,tile)
|
map.tile(x,y,tile)
|
||||||
if x<mapa.w-1 and mget(x+1,y)==t then editor.floodfill(x+1,y,tile) end
|
if x<mapa.w-1 and map.tile(x+1,y)==t then editor.floodfill(x+1,y,tile) end
|
||||||
if x>0 and mget(x-1,y)==t then editor.floodfill(x-1,y,tile) end
|
if x>0 and map.tile(x-1,y)==t then editor.floodfill(x-1,y,tile) end
|
||||||
if y<mapa.h-1 and mget(x,y+1)==t then editor.floodfill(x,y+1,tile) end
|
if y<mapa.h-1 and map.tile(x,y+1)==t then editor.floodfill(x,y+1,tile) end
|
||||||
if y>0 and mget(x,y-1)==t then editor.floodfill(x,y-1,tile) end
|
if y>0 and map.tile(x,y-1)==t then editor.floodfill(x,y-1,tile) end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
create_stamp=function()
|
create_stamp=function()
|
||||||
@@ -109,8 +109,8 @@ editor={
|
|||||||
local p=1
|
local p=1
|
||||||
for y=1,h do
|
for y=1,h do
|
||||||
for x=1,w do
|
for x=1,w do
|
||||||
editor.brush.tiles[p]=mget(tx1+x-1,ty1+y-1)
|
editor.brush.tiles[p]=map.tile(tx1+x-1,ty1+y-1)
|
||||||
--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
|
p=p+1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -122,7 +122,7 @@ editor={
|
|||||||
local p=1
|
local p=1
|
||||||
for y=1,h do
|
for y=1,h do
|
||||||
for x=1,w 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
|
p=p+1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -133,57 +133,57 @@ editor={
|
|||||||
if dx>0 then
|
if dx>0 then
|
||||||
for y=0,h-1 do
|
for y=0,h-1 do
|
||||||
for x=w-1,1,-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
|
||||||
end
|
end
|
||||||
elseif dx<0 then
|
elseif dx<0 then
|
||||||
for y=0,h-1 do
|
for y=0,h-1 do
|
||||||
for x=0,w-2 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
|
||||||
end
|
end
|
||||||
elseif dy>0 then
|
elseif dy>0 then
|
||||||
for y=h-1,1,-1 do
|
for y=h-1,1,-1 do
|
||||||
for x=0,w-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
|
||||||
end
|
end
|
||||||
elseif dy<0 then
|
elseif dy<0 then
|
||||||
for y=0,h-2 do
|
for y=0,h-2 do
|
||||||
for x=0,w-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
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
cls()
|
surf.cls()
|
||||||
camera(editor.cam.x, editor.cam.y)
|
view.origin(editor.cam.x, editor.cam.y)
|
||||||
setsource(tiles)
|
surf.source(tiles)
|
||||||
setmap(mapa.surface)
|
map.set(mapa.surface)
|
||||||
map(0,0,0,0,mapa.w, mapa.h)
|
map.draw() --map(0,0,0,0,mapa.w, mapa.h)
|
||||||
if mapa.front_layer then
|
if mapa.front_layer then
|
||||||
setmap(mapa.front_layer)
|
map.set(mapa.front_layer)
|
||||||
map(0,0,0,0,mapa.w, mapa.h)
|
map.draw() --map(0,0,0,0,mapa.w, mapa.h)
|
||||||
end
|
end
|
||||||
if editor.editing_front_layer then
|
if editor.editing_front_layer then
|
||||||
setmap(mapa.front_layer)
|
map.set(mapa.front_layer)
|
||||||
text("EDITING FRONT LAYER",12,2,10)
|
text("EDITING FRONT LAYER",12,2,10)
|
||||||
else
|
else
|
||||||
setmap(mapa.surface)
|
map.set(mapa.surface)
|
||||||
end
|
end
|
||||||
local mx,my=mouse()
|
local mx,my=mouse.pos()
|
||||||
local tx,ty=(mx+editor.cam.x)>>3,(my+editor.cam.y)>>3
|
local tx,ty=(mx+editor.cam.x)>>3,(my+editor.cam.y)>>3
|
||||||
local rx,ry=tx<<3,ty<<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
|
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
|
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 rx1>rx2 then rx1,rx2=rx2,rx1 end
|
||||||
if ry1>ry2 then ry1,ry2=ry2,ry1 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
|
end
|
||||||
camera(0,0)
|
view.origin(0,0)
|
||||||
if tx>=0 and
|
if tx>=0 and
|
||||||
ty>=0 and
|
ty>=0 and
|
||||||
tx<mapa.w and
|
tx<mapa.w and
|
||||||
@@ -191,11 +191,11 @@ editor={
|
|||||||
text(tx..","..ty,2,2,8)
|
text(tx..","..ty,2,2,8)
|
||||||
end
|
end
|
||||||
if not editor.paused then
|
if not editor.paused then
|
||||||
if mbtn(1) then
|
if mouse.down(mouse.LEFT) then
|
||||||
editor.stamp(tx,ty)
|
editor.stamp(tx,ty)
|
||||||
--mset(tx,ty,editor.brush.tiles[1])
|
--map.tile(tx,ty,editor.brush.tiles[1])
|
||||||
end
|
end
|
||||||
if mbtn(3) then
|
if mouse.down(mouse.RIGHT) then
|
||||||
if editor.selection then
|
if editor.selection then
|
||||||
editor.selection.x2=tx
|
editor.selection.x2=tx
|
||||||
editor.selection.y2=ty
|
editor.selection.y2=ty
|
||||||
@@ -213,55 +213,55 @@ editor={
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if btn(KEY_LSHIFT) then
|
if key.down(key.LSHIFT) then
|
||||||
if btnp(KEY_RIGHT) then editor.displace(1,0) end
|
if key.press(key.RIGHT) then editor.displace(1,0) end
|
||||||
if btnp(KEY_LEFT) then editor.displace(-1,0) end
|
if key.press(key.LEFT) then editor.displace(-1,0) end
|
||||||
if btnp(KEY_UP) then editor.displace(0,-1) end
|
if key.press(key.UP) then editor.displace(0,-1) end
|
||||||
if btnp(KEY_DOWN) then editor.displace(0,1) end
|
if key.press(key.DOWN) then editor.displace(0,1) end
|
||||||
else
|
else
|
||||||
if btnp(KEY_RIGHT) then editor.cam.x=editor.cam.x+8 end
|
if key.press(key.RIGHT) then editor.cam.x=editor.cam.x+8 end
|
||||||
if btnp(KEY_LEFT) then editor.cam.x=editor.cam.x-8 end
|
if key.press(key.LEFT) then editor.cam.x=editor.cam.x-8 end
|
||||||
if btnp(KEY_UP) then editor.cam.y=editor.cam.y-8 end
|
if key.press(key.UP) then editor.cam.y=editor.cam.y-8 end
|
||||||
if btnp(KEY_DOWN) then editor.cam.y=editor.cam.y+8 end
|
if key.press(key.DOWN) then editor.cam.y=editor.cam.y+8 end
|
||||||
end
|
end
|
||||||
|
|
||||||
if btnp(KEY_F) then
|
if key.press(key.F) then
|
||||||
editor.floodfill(tx,ty,editor.brush.tiles[1])
|
editor.floodfill(tx,ty,editor.brush.tiles[1])
|
||||||
end
|
end
|
||||||
if btnp(KEY_1) then
|
if key.press(key.N1) then
|
||||||
if editor.editing_front_layer then
|
if editor.editing_front_layer then
|
||||||
editor.editing_front_layer=nil
|
editor.editing_front_layer=nil
|
||||||
else
|
else
|
||||||
editor.editing_front_layer=true
|
editor.editing_front_layer=true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if btnp(KEY_RETURN) then
|
if key.press(key.RETURN) then
|
||||||
editor.brush.tiles[1]=mget(tx,ty)
|
editor.brush.tiles[1]=map.tile(tx,ty)
|
||||||
end
|
end
|
||||||
if btnp(KEY_ESCAPE) then
|
if key.press(key.ESCAPE) then
|
||||||
editor.paused=true
|
editor.paused=true
|
||||||
editor.show_menu()
|
editor.show_menu()
|
||||||
end
|
end
|
||||||
if btnp(KEY_TAB) then
|
if key.press(key.TAB) then
|
||||||
update=editor.update_tileset
|
update=editor.update_tileset
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
update_tileset=function()
|
update_tileset=function()
|
||||||
cls()
|
surf.cls()
|
||||||
blit(0,0,128,128,0,0)
|
draw.surf(0,0,128,128,0,0)
|
||||||
|
|
||||||
local mx,my=mouse()
|
local mx,my=mouse.pos()
|
||||||
local tx,ty=mx>>3,my>>3
|
local tx,ty=mx>>3,my>>3
|
||||||
local rx,ry=tx<<3,ty<<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
|
update=editor.update
|
||||||
end
|
end
|
||||||
|
|
||||||
if mbtnp(1) then
|
if mouse.press(mouse.LEFT) then
|
||||||
if tx<16 and ty<16 then
|
if tx<16 and ty<16 then
|
||||||
editor.brush.w=1
|
editor.brush.w=1
|
||||||
editor.brush.h=1
|
editor.brush.h=1
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ fade={
|
|||||||
|
|
||||||
init = function()
|
init = function()
|
||||||
for i=1,16 do
|
for i=1,16 do
|
||||||
local r,g,b=palcolor(i)
|
local r,g,b=pal.color(i)
|
||||||
fade.pal[i]={r,g,b}
|
fade.pal[i]={r,g,b}
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@@ -38,13 +38,13 @@ fade={
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
update_fadeout=function()
|
update_fadeout=function()
|
||||||
if beat() then
|
if sys.beat() then
|
||||||
for i=1,16 do
|
for i=1,16 do
|
||||||
local v=fade.getstep(i,fade.step)
|
local v=fade.getstep(i,fade.step)
|
||||||
if v==0 then
|
if v==0 then
|
||||||
palcolor(i,0,0,0)
|
pal.color(i,0,0,0)
|
||||||
else
|
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
|
||||||
end
|
end
|
||||||
fade.step=fade.step+1
|
fade.step=fade.step+1
|
||||||
@@ -66,19 +66,19 @@ fade={
|
|||||||
fade.old_update=update
|
fade.old_update=update
|
||||||
update=fade.update_fadein
|
update=fade.update_fadein
|
||||||
fade.step=6
|
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,
|
end,
|
||||||
|
|
||||||
update_fadein=function()
|
update_fadein=function()
|
||||||
fade.old_update()
|
fade.old_update()
|
||||||
|
|
||||||
if beat() then
|
if sys.beat() then
|
||||||
for i=1,16 do
|
for i=1,16 do
|
||||||
local v=fade.getstep(i,fade.step)
|
local v=fade.getstep(i,fade.step)
|
||||||
if v==0 then
|
if v==0 then
|
||||||
palcolor(i,0,0,0)
|
pal.color(i,0,0,0)
|
||||||
else
|
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
|
||||||
end
|
end
|
||||||
fade.step=fade.step-1
|
fade.step=fade.step-1
|
||||||
|
|||||||
@@ -20,23 +20,23 @@ fileselect={
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
rectfill(10,10, 150, 130,5)
|
draw.rectf(10,10, 140, 120,5)
|
||||||
rect(10,10, 150, 130,8)
|
draw.rect(10,10, 140, 120,8)
|
||||||
if fileselect.title then prnt(fileselect.title,20,13) end
|
if fileselect.title then draw.text(fileselect.title,20,13,8) end
|
||||||
rectfill(20,20, 140, 120,6)
|
draw.rectf(20,20, 120, 100,6)
|
||||||
local i = 22
|
local i = 22
|
||||||
for k,dir in pairs(fileselect.file_list) do
|
for k,dir in pairs(fileselect.file_list) do
|
||||||
color(8)
|
local color=8
|
||||||
if k==fileselect.selected then
|
if k==fileselect.selected then
|
||||||
rectfill(20,i-2, 140, i+6,11)
|
draw.rectf(20,i-1, 120, 8,11)
|
||||||
color(15)
|
color=15
|
||||||
end
|
end
|
||||||
prnt(dir, 23, i)
|
draw.text(dir, 23, i, color)
|
||||||
i=i+7
|
i=i+7
|
||||||
end
|
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
|
if (mx~=fileselect.old_mx or my~=fileselect.old_my) then
|
||||||
fileselect.old_mx,fileselect.old_my=mx,my
|
fileselect.old_mx,fileselect.old_my=mx,my
|
||||||
if mx>20 and mx<140 and my>20 and my<120 then
|
if mx>20 and mx<140 and my>20 and my<120 then
|
||||||
@@ -46,7 +46,7 @@ fileselect={
|
|||||||
end
|
end
|
||||||
end
|
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
|
if mx>20 and mx<140 and my>20 and my<120 then
|
||||||
local y = math.floor((my-21)/7)+1
|
local y = math.floor((my-21)/7)+1
|
||||||
if (y<=#fileselect.file_list) then
|
if (y<=#fileselect.file_list) then
|
||||||
@@ -57,20 +57,20 @@ fileselect={
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- if textbox.value then
|
-- if textbox.value then
|
||||||
-- prnt(textbox.value,43,73)
|
-- draw.text(textbox.value,43,73)
|
||||||
-- if (math.floor(time()*4)%2)==0 then
|
-- if (math.floor(time()*4)%2)==0 then
|
||||||
-- prnt("_",43+#textbox.value*4,73)
|
-- draw.text("_",43+#textbox.value*4,73)
|
||||||
-- end
|
-- end
|
||||||
-- end
|
-- end
|
||||||
--
|
--
|
||||||
local tecla=btnp()
|
local tecla=key.press()
|
||||||
if tecla==KEY_DOWN then
|
if tecla==key.DOWN then
|
||||||
if fileselect.selected < #fileselect.file_list then fileselect.selected = fileselect.selected + 1 end
|
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
|
if fileselect.selected > 1 then fileselect.selected = fileselect.selected - 1 end
|
||||||
-- elseif tecla==KEY_BACKSPACE then
|
-- elseif tecla==KEY_BACKSPACE then
|
||||||
-- textbox.value=string.sub(textbox.value,1,-2)
|
-- textbox.value=string.sub(textbox.value,1,-2)
|
||||||
elseif tecla==KEY_RETURN then
|
elseif tecla==key.RETURN then
|
||||||
update=fileselect.old_update
|
update=fileselect.old_update
|
||||||
fileselect.return_function(fileselect.file_list[fileselect.selected])
|
fileselect.return_function(fileselect.file_list[fileselect.selected])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,4 +3,3 @@ config=ja2
|
|||||||
width=160
|
width=160
|
||||||
height=144
|
height=144
|
||||||
zoom=4
|
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
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ game={
|
|||||||
|
|
||||||
save=function()
|
save=function()
|
||||||
local i=1
|
local i=1
|
||||||
file = io.open(configfolder().."slot"..i..".txt", "w")
|
file = io.open(config.folder().."slot"..i..".txt", "w")
|
||||||
if file then
|
if file then
|
||||||
io.output(file)
|
io.output(file)
|
||||||
io.write("level="..game.level.."\n")
|
io.write("level="..game.level.."\n")
|
||||||
@@ -86,7 +86,7 @@ game={
|
|||||||
|
|
||||||
load=function()
|
load=function()
|
||||||
local i=1
|
local i=1
|
||||||
file = io.open(configfolder().."slot"..i..".txt", "r")
|
file = io.open(config.folder().."slot"..i..".txt", "r")
|
||||||
local level_name = ""
|
local level_name = ""
|
||||||
local new_flags={}
|
local new_flags={}
|
||||||
local new_objects={}
|
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.x=tonumber(v)
|
||||||
local k,v=getkeyval(io.read()) actors.main.y=tonumber(v)
|
local k,v=getkeyval(io.read()) actors.main.y=tonumber(v)
|
||||||
local k,v=getkeyval(io.read()) actors.main.o=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()
|
local line = io.read()
|
||||||
while line ~= "[OBJECTS]" do
|
while line ~= "[OBJECTS]" do
|
||||||
local k,v=getkeyval(line)
|
local k,v=getkeyval(line)
|
||||||
@@ -120,17 +120,17 @@ game={
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
draw=function()
|
draw=function()
|
||||||
cls(6)
|
surf.cls(6)
|
||||||
camera(game.cam.x, game.cam.y)
|
view.origin(game.cam.x, game.cam.y)
|
||||||
setsource(tiles)
|
surf.source(tiles)
|
||||||
setmap(mapa.surface)
|
map.set(mapa.surface)
|
||||||
map(0,0,0,0,mapa.w, mapa.h)
|
map.draw()--map(0,0,0,0,mapa.w, mapa.h)
|
||||||
switches.draw();
|
switches.draw();
|
||||||
setsource(sprites)
|
surf.source(sprites)
|
||||||
if btn(KEY_LSHIFT) then subpal(1,16,8) end
|
if key.down(key.LSHIFT) then pal.subpal(1,16,8) end
|
||||||
actors.draw()
|
actors.display()
|
||||||
subpal()
|
pal.subpal()
|
||||||
local mx,my=mouse()
|
local mx,my=mouse.pos()
|
||||||
if actors.under_cursor~="" then
|
if actors.under_cursor~="" then
|
||||||
if (mx<=80) then
|
if (mx<=80) then
|
||||||
text(actors.under_cursor,mx+game.cam.x+4,my+game.cam.y+4,9)
|
text(actors.under_cursor,mx+game.cam.x+4,my+game.cam.y+4,9)
|
||||||
@@ -140,13 +140,13 @@ game={
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if mapa.front_layer then
|
if mapa.front_layer then
|
||||||
setsource(tiles)
|
surf.source(tiles)
|
||||||
setmap(mapa.front_layer)
|
map.set(mapa.front_layer)
|
||||||
map(0,0,0,0,mapa.w, mapa.h)
|
map.draw() -- map(0,0,0,0,mapa.w, mapa.h)
|
||||||
end
|
end
|
||||||
setmap(mapa.surface)
|
map.set(mapa.surface)
|
||||||
camera(0,0)
|
view.origin(0,0)
|
||||||
for i=0,15 do rectfill(20+i*4,0,20+i*4+4,4,i) end
|
for i=0,15 do draw.rectf(20+i*4,0,4,4,i) end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
@@ -164,7 +164,7 @@ game={
|
|||||||
|
|
||||||
game.draw()
|
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(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)
|
text(game.cam.x..","..game.cam.y,1,1,8)
|
||||||
@@ -174,37 +174,37 @@ game={
|
|||||||
text(game.level,1,13,8)
|
text(game.level,1,13,8)
|
||||||
|
|
||||||
if not scene.script and hero and not hero.path and hero.dx+hero.dy==0 then
|
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}
|
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}
|
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}
|
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}
|
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)
|
actors.interact(hero.x,hero.y,hero.o)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if btnp(KEY_ESCAPE) then
|
if key.press(key.ESCAPE) then
|
||||||
game.show_menu()
|
game.show_menu()
|
||||||
end
|
end
|
||||||
|
|
||||||
if beat() then actors.update() end
|
if sys.beat() then actors.update() end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
pause=function()
|
pause=function()
|
||||||
game.paused = true
|
game.paused = true
|
||||||
rectfill(9,84, 150, 128,6)
|
draw.rectf(9,84, 141, 44,6)
|
||||||
rect(9,84, 150, 128,8)
|
draw.rect(9,84, 141, 44,8)
|
||||||
rect(8,83, 151, 129,6)
|
draw.rect(8,83, 143, 46,6)
|
||||||
text("OBJECTES:",14,82,8)
|
text("OBJECTES:",14,82,8)
|
||||||
setsource(objectes)
|
surf.source(objectes)
|
||||||
|
|
||||||
local x,y=15,90
|
local x,y=15,90
|
||||||
for i,name in ipairs(objects.list) do
|
for i,name in ipairs(objects.list) do
|
||||||
local obj = object[name]
|
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
|
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
|
||||||
|
|||||||
@@ -3,41 +3,39 @@ require "game"
|
|||||||
require "editor"
|
require "editor"
|
||||||
require "menu"
|
require "menu"
|
||||||
|
|
||||||
function _init()
|
function mini.init()
|
||||||
menu_option=0
|
menu_option=0
|
||||||
sprites=loadsurf("sprites.gif")
|
objectes=surf.load("objects.gif")
|
||||||
objectes=loadsurf("objects.gif")
|
tiles=surf.load("tiles.gif")
|
||||||
tiles=loadsurf("tiles.gif")
|
surf.source(tiles)
|
||||||
setsource(tiles)
|
local p=pal.load("tiles.gif")
|
||||||
local pal=loadpal("tiles.gif")
|
pal.set(p)
|
||||||
setpal(pal)
|
sprites=surf.load("sprites.gif")
|
||||||
beat(6)
|
sys.beat(6)
|
||||||
fade.init()
|
fade.init()
|
||||||
main_init()
|
main_init()
|
||||||
end
|
end
|
||||||
|
|
||||||
function _update()
|
function mini.update()
|
||||||
update()
|
update()
|
||||||
end
|
end
|
||||||
|
|
||||||
function text(txt,x,y,col)
|
function text(txt,x,y,col)
|
||||||
color(6)
|
draw.text(txt,x-1,y-1,6)
|
||||||
prnt(txt,x-1,y-1)
|
draw.text(txt,x,y-1,6)
|
||||||
prnt(txt,x,y-1)
|
draw.text(txt,x+1,y-1,6)
|
||||||
prnt(txt,x+1,y-1)
|
draw.text(txt,x-1,y,6)
|
||||||
prnt(txt,x-1,y)
|
draw.text(txt,x+1,y,6)
|
||||||
prnt(txt,x+1,y)
|
draw.text(txt,x-1,y+1,6)
|
||||||
prnt(txt,x-1,y+1)
|
draw.text(txt,x,y+1,6)
|
||||||
prnt(txt,x,y+1)
|
draw.text(txt,x+1,y+1,6)
|
||||||
prnt(txt,x+1,y+1)
|
draw.text(txt,x,y,col)
|
||||||
color(col)
|
|
||||||
prnt(txt,x,y)
|
|
||||||
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", sys.quit}, {"TEST", function() menu.show(second_menu) end } }
|
||||||
show_main_menu()
|
show_main_menu()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -50,9 +48,8 @@ function set_update(new_update)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function menu_update()
|
function menu_update()
|
||||||
cls()
|
surf.cls()
|
||||||
color(1)
|
draw.text("JAIL'S ADVENTURE 2",10,10,1)
|
||||||
prnt("JAIL'S ADVENTURE 2",10,10)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function getkeyval(str)
|
function getkeyval(str)
|
||||||
|
|||||||
@@ -2,17 +2,17 @@ mapa={
|
|||||||
name=nil,
|
name=nil,
|
||||||
w=128,
|
w=128,
|
||||||
h=128,
|
h=128,
|
||||||
surface=nil,
|
surface=-1,
|
||||||
|
|
||||||
new = function(w,h)
|
new = function(w,h)
|
||||||
mapa.name=nil
|
mapa.name=nil
|
||||||
mapa.w,mapa.h=w,h
|
mapa.w,mapa.h=w,h
|
||||||
if mapa.surface~=nil then freesurf(mapa.surface) end
|
if mapa.surface~=-1 then surf.free(mapa.surface) end
|
||||||
mapa.surface=newsurf(w,h)
|
mapa.surface=surf.new(w,h)
|
||||||
setmap(mapa.surface)
|
map.set(mapa.surface)
|
||||||
for y=0,127 do
|
for y=0,127 do
|
||||||
for x=0,127 do
|
for x=0,127 do
|
||||||
mset(x,y,0)
|
map.tile(x,y,0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
mapa.front_layer=nil
|
mapa.front_layer=nil
|
||||||
@@ -32,25 +32,25 @@ mapa={
|
|||||||
local line = io.read()
|
local line = io.read()
|
||||||
local x=0
|
local x=0
|
||||||
for m in string.gmatch(line, "%d+") do
|
for m in string.gmatch(line, "%d+") do
|
||||||
mset(x,y,m)
|
map.tile(x,y,m)
|
||||||
x=x+1
|
x=x+1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if num_layers==2 then
|
if num_layers==2 then
|
||||||
mapa.front_layer=newsurf(mapa.w,mapa.h)
|
mapa.front_layer=surf.new(mapa.w,mapa.h)
|
||||||
setmap(mapa.front_layer)
|
map.set(mapa.front_layer)
|
||||||
|
|
||||||
for y=0,mapa.h-1 do
|
for y=0,mapa.h-1 do
|
||||||
local line = io.read()
|
local line = io.read()
|
||||||
local x=0
|
local x=0
|
||||||
for m in string.gmatch(line, "%d+") do
|
for m in string.gmatch(line, "%d+") do
|
||||||
mset(x,y,m)
|
map.tile(x,y,m)
|
||||||
x=x+1
|
x=x+1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
setmap(mapa.surface)
|
map.set(mapa.surface)
|
||||||
io.close(file)
|
io.close(file)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@@ -63,18 +63,18 @@ mapa={
|
|||||||
io.write(mapa.w.."\n")
|
io.write(mapa.w.."\n")
|
||||||
io.write(mapa.h.."\n")
|
io.write(mapa.h.."\n")
|
||||||
if mapa.front_layer then io.write("2\n") else io.write("1\n") end
|
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 y=0,mapa.h-1 do
|
||||||
for x=0,mapa.w-1 do
|
for x=0,mapa.w-1 do
|
||||||
io.write(mget(x,y)..",")
|
io.write(map.tile(x,y)..",")
|
||||||
end
|
end
|
||||||
io.write("\n")
|
io.write("\n")
|
||||||
end
|
end
|
||||||
if mapa.front_layer then
|
if mapa.front_layer then
|
||||||
setmap(mapa.front_layer)
|
map.set(mapa.front_layer)
|
||||||
for y=0,mapa.h-1 do
|
for y=0,mapa.h-1 do
|
||||||
for x=0,mapa.w-1 do
|
for x=0,mapa.w-1 do
|
||||||
io.write(mget(x,y)..",")
|
io.write(map.tile(x,y)..",")
|
||||||
end
|
end
|
||||||
io.write("\n")
|
io.write("\n")
|
||||||
end
|
end
|
||||||
@@ -84,6 +84,6 @@ mapa={
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
check_collision=function(x,y)
|
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
|
end
|
||||||
}
|
}
|
||||||
@@ -15,35 +15,36 @@ menu = {
|
|||||||
update=function()
|
update=function()
|
||||||
--menu.old_update()
|
--menu.old_update()
|
||||||
|
|
||||||
rectfill(9,20, 150, 34+#menu.options*10,6)
|
draw.rectf(9,20, 141, 14+#menu.options*10,6)
|
||||||
rect(9,20, 150, 34+#menu.options*10,8)
|
draw.rect(9,20, 141, 14+#menu.options*10,8)
|
||||||
rect(8,19, 151, 35+#menu.options*10,6)
|
draw.rect(8,19, 143, 16+#menu.options*10,6)
|
||||||
|
|
||||||
for i,v in ipairs(menu.options) do
|
for i,v in ipairs(menu.options) do
|
||||||
color(4) if menu.selected==i then color(15) prnt(">",20,20+i*10) end
|
local color=4
|
||||||
prnt(v[1],24,20+i*10)
|
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
|
end
|
||||||
|
|
||||||
if btnp(KEY_DOWN) then menu.selected=menu.selected+1 end
|
if key.press(key.DOWN) then menu.selected=menu.selected+1 end
|
||||||
if btnp(KEY_UP) 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==0 then menu.selected=#menu.options end
|
||||||
if menu.selected>#menu.options then menu.selected=1 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
|
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)
|
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
|
update=menu.old_update
|
||||||
menu.options[menu.selected][2]()
|
menu.options[menu.selected][2]()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if btnp(KEY_RETURN) then
|
if key.press(key.RETURN) then
|
||||||
update=menu.old_update
|
update=menu.old_update
|
||||||
menu.options[menu.selected][2]()
|
menu.options[menu.selected][2]()
|
||||||
end
|
end
|
||||||
|
|
||||||
if btnp(KEY_ESCAPE) then
|
if key.press(key.ESCAPE) then
|
||||||
if menu.return_function then
|
if menu.return_function then
|
||||||
update=menu.old_update
|
update=menu.old_update
|
||||||
menu.return_function()
|
menu.return_function()
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ switches={
|
|||||||
text(#switches.list,1,25,8)
|
text(#switches.list,1,25,8)
|
||||||
if switches.col<16 then
|
if switches.col<16 then
|
||||||
for i,v in ipairs(switches.list) do
|
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
|
||||||
end
|
end
|
||||||
switches.col=(switches.col+1)%32
|
switches.col=(switches.col+1)%32
|
||||||
|
|||||||
@@ -15,25 +15,25 @@ textbox={
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
rectfill(20,50, 140, 90,6)
|
draw.rectf(20,50, 120, 40,6)
|
||||||
rect(20,50, 140, 90,8)
|
draw.rect(20,50, 120, 40,8)
|
||||||
if textbox.title then prnt(textbox.title,30,55) end
|
if textbox.title then draw.text(textbox.title,30,55,8) end
|
||||||
rect(40,70, 120, 80,8)
|
draw.rect(40,70, 80, 11,8)
|
||||||
if textbox.value then
|
if textbox.value then
|
||||||
prnt(textbox.value,43,73)
|
draw.text(textbox.value,43,73,8)
|
||||||
if (math.floor(time()*4)%2)==0 then
|
if (math.floor(sys.time()*4)%2)==0 then
|
||||||
prnt("_",43+#textbox.value*4,73)
|
draw.text("_",43+#textbox.value*4,73,8)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local tecla=btnp()
|
local tecla=key.press()
|
||||||
if tecla>=4 and tecla<=39 then
|
if tecla>=4 and tecla<=39 then
|
||||||
textbox.value=textbox.value..string.sub(keyvalues,tecla,tecla)
|
textbox.value=textbox.value..string.sub(keyvalues,tecla,tecla)
|
||||||
elseif tecla==KEY_PERIOD then
|
elseif tecla==key.PERIOD then
|
||||||
textbox.value=textbox.value.."."
|
textbox.value=textbox.value.."."
|
||||||
elseif tecla==KEY_BACKSPACE then
|
elseif tecla==key.BACKSPACE then
|
||||||
textbox.value=string.sub(textbox.value,1,-2)
|
textbox.value=string.sub(textbox.value,1,-2)
|
||||||
elseif tecla==KEY_RETURN then
|
elseif tecla==key.RETURN then
|
||||||
update=textbox.old_update
|
update=textbox.old_update
|
||||||
textbox.return_function(textbox.value)
|
textbox.return_function(textbox.value)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ wait={
|
|||||||
wait.old_update=update
|
wait.old_update=update
|
||||||
update=wait.update
|
update=wait.update
|
||||||
wait.total_time=seconds
|
wait.total_time=seconds
|
||||||
wait.start_time=time()
|
wait.start_time=sys.time()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
update=function()
|
update=function()
|
||||||
wait.old_update()
|
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
|
update=wait.old_update
|
||||||
scene.cont()
|
scene.cont()
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user