Calculator Community > Axe
How to tilemap?
(1/2) > >>
Michael_Lee:
Mkay, I apologize in advance, because this question has been probably asked so many times already, but how exactly do you make a tilemap in Axe?  
What different methods are there, and what types of compression are commonly employed?

I'm pretty sure there's lots of threads with similar questions floating around, so links are fine.
Builderboy:
I actually have had heaps of trouble making a reasonably fast tilemapper in Axe, and im also eager to see this question answered
nemo:
first, i'll define what a tilemap is. a tilemap is usually a 2-dimensional list (like a matrix) of numbers that map a tileset into a graphical map. what's a tileset? a set of graphics to use. the tilemap in axe is just a list of bytes. so the following could be a tilemap:
[0101010101]
[0100000001]
[0102020201]
[0101010101]
say we wanted to display this tilemap. the tile 00 will be a white square, the tile 01 will be a black square, and the tile 02 will be a white square with a black outline.
here's the code.

--- Code: ---.PROG
[0000000000000000]->Pic1
[FFFFFFFFFFFFFFFF]
[FF818181818181FF]
[0101010101]->GDB1
[0100000001]
[0102020201]
[0101010101]
For(Y,0,3
For(X,0,4
Pt-On(X*8,Y*8,{Y*5+X+GDB1}*8+Pic1
End:End
DispGraph
Repeat getKey
End

--- End code ---

this is very, very simplistic. note that each tile number takes up a byte. meaning you can have 256 different tiles. some tilemappers use half-bytes, or nibbles. you can then have only 16 different tiles, but your map is twice as compressed. many others also use RLE compression, which is a compression technique that instead of storing each tile as byte, would store the frequency of the tile in a byte, and then the tile in the next byte. so our example would become the following:
[06010300020103020601]
which would be read as "6 tile number 1's, 3 tile number 0's, 2 tile number 1's, 3 tile number 2's, 6 tile number 1's."
Deep Toaster:
Here's a nice tutorial on it: http://ourl.ca/4550.
Michael_Lee:

--- Quote from: nemo on October 19, 2010, 07:14:08 pm ---
--- Code: ---.PROG
[0000000000000000]->Pic1
[FFFFFFFFFFFFFFFF]
[FF818181818181FF]
[0101010101]->GDB1
[0100000001]
[0102020201]
[0101010101]
For(Y,0,3
For(X,0,4
Pt-On(X*8,Y*8,Y*5+X*8+Pic1
End:End
DispGraph
Repeat getKey
End

--- End code ---

--- End quote ---
Wait, wouldn't using X and Y just return random gibberish?  How does the code know that X and Y refer to GDB1?
Navigation
Message Index
Next page

Go to full version