- [NEW][EDITOR] Mostra coordenades tile baix cursor
- [NEW][EDITOR] Displace map
This commit is contained in:
@@ -58,6 +58,35 @@ editor={
|
|||||||
end
|
end
|
||||||
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()
|
update=function()
|
||||||
cls()
|
cls()
|
||||||
camera(editor.cam.x, editor.cam.y)
|
camera(editor.cam.x, editor.cam.y)
|
||||||
@@ -74,7 +103,12 @@ editor={
|
|||||||
rect(rx1-1, ry1-1, rx2+8, ry2+8, 8)
|
rect(rx1-1, ry1-1, rx2+8, ry2+8, 8)
|
||||||
end
|
end
|
||||||
camera(0,0)
|
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 not editor.paused then
|
||||||
if mbtn(1) then
|
if mbtn(1) then
|
||||||
editor.stamp(tx,ty)
|
editor.stamp(tx,ty)
|
||||||
@@ -98,10 +132,18 @@ editor={
|
|||||||
end
|
end
|
||||||
end
|
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_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_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_UP) then editor.cam.y=editor.cam.y-8 end
|
||||||
if btnp(KEY_DOWN) 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
|
if btnp(KEY_F) then
|
||||||
editor.floodfill(tx,ty,editor.brush.tiles[1])
|
editor.floodfill(tx,ty,editor.brush.tiles[1])
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user