View Single Post
  #16  
Old 11-24-2013, 06:12 PM
jacob_bald6225 jacob_bald6225 is offline
Doctor Who?
jacob_bald6225's Avatar
Join Date: Feb 2002
Posts: 851
jacob_bald6225 is a splendid one to beholdjacob_bald6225 is a splendid one to beholdjacob_bald6225 is a splendid one to beholdjacob_bald6225 is a splendid one to beholdjacob_bald6225 is a splendid one to behold
Quote:
Originally Posted by Emera View Post
It actually takes a tremendous amount of time, but I wasn't expecting anything else. Regarding dealing with tile obscurities though, it has been suggested that I use an algorithm to check for similarities between tiles instead of directly comparing pixel data. Obviously, it's not fool proof and I doubt I'm capable of coming up with something that is, but it's a step in the right direction
I think mine got down to something insane like 20 seconds for a level the more I worked with it and changed how I did things.


I am a noob but heres kind of some rambling advice as to how I was doing it and saving time.

Each scan read the r,g,b color of each tile in an X(Top left to bottom right, top right to bottom left). That is scanning 32 pixels per tiles instead of 256 (all of them)-- this increased my speed by 8 times.

I stored that in a big array from the tileset.


The scanning of the level is where time was made up:
Then when scanning the level I scanned 0,0-- looped through and checked it against the array of the tileset tiles. If a match was found-- I reorganized the tileset array of tiles to move the tile that was found to the 0 position. That way, common tiles in the level are closer to the first checked.

If a tile wasn't found-- I put it in a "not found" array. Which it'd scan before the tileset. Since there usually weren't 100s of not found tiles this stopped the thing from looping through all 4000 or so tiles each time one wasn't found.
__________________
Reply With Quote