Quote:
Originally Posted by MrOmega
How is this possible? How do you define the actual tile orgins since not all screenshots are aligned? What is the average time it takes to compile a image to level? Say a 640x480 png for example.
|
It probably isn't the most efficient technique but here is the gist:
Scan the tileset: Scan each pixel and put the RGB in to a string:
So RGB(0,0)+RGB(0,1).....+RGB(16,16). Since each tile is 16x16 pixels.
After the tileset is scanned it saves the information to the computer so you don't have to rescan for each level.
Then it loops through and checks each pixel of each tile in the screenshot(which is aligned and 1024x1024 pixels). If it matches a tile it adds that tile to a "recently used" array of tiles which get priority checking(so you don't have to loop back through the entire set of tiles after it gets cooking).
Each tile is synced up with the tile hex value(like "AE", or "/3". When it finds the tile it plops down the hex value in the level string. Right now it doesn't save files but outputs them as plaintext which you can copy paste in to a graal file and save with a text editor to get your level.
If the tile is unknown it puts a blackness tile so you can easily tell which tiles are missing.
All in all if the tileset is already scanned IIRC(it has been a few weeks since I generated a level from this). It pumps out the plaintext level in like (EDIT) 50 seconds which I have recorded in a video.
(Does this even make sense to anyone else?)
tl;dr:
1. Tileset scanned-->in order of the corresponding tile hex values.
2. Level is scanned tile by tile and plops out the hex value of the tileset tile that it matches.
3. Plaintext level is made and copy pasted in to a .nw with a text editor.
Again, this is probably not the best way to do this-- but it works.
(EDIT)Main problem here is I have it set up to do multiple levels in a row and as there are more tiles added to the priority list it begins to slow down-- I have a video of generating 6 levels in a row in 6:35 seconds.