Compare commits

...

3 Commits

Author SHA1 Message Date
adee527d70 - [NEW][EDITOR] Mostra coordenades tile baix cursor
- [NEW][EDITOR] Displace map
2023-01-29 17:51:52 +01:00
5791dbcb01 - Funció text() 2023-01-29 17:37:49 +01:00
0d6e471229 - [FIX] Quan lligca els nombres, que no els prenga com cadenes 2023-01-29 17:37:37 +01:00
3 changed files with 62 additions and 7 deletions

View File

@@ -58,6 +58,35 @@ editor={
end
end,
displace=function(dx,dy)
local w,h=mapa.w,mapa.h
if dx>0 then
for y=0,h-1 do
for x=w-1,1,-1 do
mset(x,y,mget(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))
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))
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))
end
end
end
end,
update=function()
cls()
camera(editor.cam.x, editor.cam.y)
@@ -74,7 +103,12 @@ editor={
rect(rx1-1, ry1-1, rx2+8, ry2+8, 8)
end
camera(0,0)
if tx>=0 and
ty>=0 and
tx<mapa.w and
ty<mapa.h then
text(tx..","..ty,2,2,8)
end
if not editor.paused then
if mbtn(1) then
editor.stamp(tx,ty)
@@ -98,10 +132,18 @@ editor={
end
end
if btnp(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 btnp(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 btn(KEY_LSHIFT) then
if btnp(KEY_RIGHT) then editor.displace(1,0) end
if btnp(KEY_LEFT) then editor.displace(-1,0) end
if btnp(KEY_UP) then editor.displace(0,-1) end
if btnp(KEY_DOWN) then editor.displace(0,1) end
else
if btnp(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 btnp(KEY_UP) then editor.cam.y=editor.cam.y-8 end
if btnp(KEY_DOWN) then editor.cam.y=editor.cam.y+8 end
end
if btnp(KEY_F) then
editor.floodfill(tx,ty,editor.brush.tiles[1])
end

View File

@@ -14,6 +14,19 @@ function _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)
end
function main_init()
set_update(menu_update)

View File

@@ -21,8 +21,8 @@ mapa={
file = io.open("data/"..filename, "r")
if file then
io.input(file)
mapa.w = io.read()
mapa.h = io.read()
mapa.w = tonumber(io.read())
mapa.h = tonumber(io.read())
mapa.new(mapa.w, mapa.h)
mapa.name=filename
for y=0,mapa.h-1 do