Some fixes to the Tiler script.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1833 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
da48c58445
commit
6e30a87f4c
@ -1,10 +1,8 @@
|
|||||||
--PICTURE: Tiler
|
--Picture Tiler by Adrien Destugues
|
||||||
--By Adrien Destugues
|
--Extract unique tiles from the spare page
|
||||||
|
--to the main one. Main page is erased.
|
||||||
--
|
--
|
||||||
--Extract unique tiles from the spare page to the main one
|
-- Copyright 2011 Adrien Destugues <pulkomandy@pulkomandy.ath.cx>
|
||||||
--Main page is erased.
|
|
||||||
--
|
|
||||||
-- Copyright 2010 Adrien Destugues <pulkomandy@pulkomandy.ath.cx>
|
|
||||||
--
|
--
|
||||||
-- This program is free software; you can redistribute it and/or
|
-- This program is free software; you can redistribute it and/or
|
||||||
-- modify it under the terms of the GNU General Public License
|
-- modify it under the terms of the GNU General Public License
|
||||||
@ -16,24 +14,24 @@
|
|||||||
|
|
||||||
-- Grid size
|
-- Grid size
|
||||||
-- TODO : get it from GrafX2
|
-- TODO : get it from GrafX2
|
||||||
xgrid = 8
|
xgrid = 8;
|
||||||
ygrid = 16
|
ygrid = 16;
|
||||||
|
|
||||||
-- picture size
|
-- picture size
|
||||||
w, h = getsparepicturesize()
|
w, h = getsparepicturesize();
|
||||||
|
|
||||||
-- We may need less if there are duplicates
|
-- We may need less if there are duplicates
|
||||||
setpicturesize(xgrid, w*h/xgrid)
|
setpicturesize(xgrid, w*h/xgrid);
|
||||||
|
clearpicture(255);
|
||||||
|
|
||||||
tileid = 0
|
tileid = 0;
|
||||||
|
|
||||||
-- blit part of the spare to picture
|
-- blit part of the spare to picture
|
||||||
function blitsparetopicture(srcx, srcy, dstx, dsty, width, height)
|
function blitsparetopicture(srcx, srcy, dstx, dsty, width, height)
|
||||||
local x,y,color
|
local x,y;
|
||||||
for y = 0, height - 1, 1 do
|
for y = 0, height - 1, 1 do
|
||||||
for x = 0, width - 1, 1 do
|
for x = 0, width - 1, 1 do
|
||||||
color = getsparepicturepixel(srcx + x, srcy + y);
|
putpicturepixel(dstx+x, dsty+y, getsparepicturepixel(srcx + x, srcy + y));
|
||||||
putpicturepixel(dstx+x, dsty+y, color);
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -72,7 +70,7 @@ tilemap = {}
|
|||||||
-- foreach tile
|
-- foreach tile
|
||||||
for y = 0, h-1, ygrid do
|
for y = 0, h-1, ygrid do
|
||||||
for x = 0, w - 1, xgrid do
|
for x = 0, w - 1, xgrid do
|
||||||
--TODO - existing one ?
|
-- existing one ?
|
||||||
csum = checksum(x,y,xgrid,ygrid);
|
csum = checksum(x,y,xgrid,ygrid);
|
||||||
if tilemap[csum] ~= nil then
|
if tilemap[csum] ~= nil then
|
||||||
-- potential match
|
-- potential match
|
||||||
@ -108,12 +106,9 @@ for y = 0, h-1, ygrid do
|
|||||||
-- give it a tile id
|
-- give it a tile id
|
||||||
tileid = tileid + 1;
|
tileid = tileid + 1;
|
||||||
end
|
end
|
||||||
--statusmessage("processed " .. tileid .. " tiles");
|
|
||||||
--updatescreen();
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
finalizepicture(); -- resize from what we just did
|
||||||
setpicturesize(xgrid, (tileid-1)*ygrid)
|
setpicturesize(xgrid, (tileid-1)*ygrid)
|
||||||
|
updatescreen();
|
||||||
finalizepicture()
|
|
||||||
updatescreen()
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user