Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Michael_Lee on October 19, 2010, 06:44:56 pm

Title: How to tilemap?
Post by: Michael_Lee on October 19, 2010, 06:44:56 pm
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.
Title: Re: How to tilemap?
Post by: Builderboy on October 19, 2010, 07:00:20 pm
I actually have had heaps of trouble making a reasonably fast tilemapper in Axe, and im also eager to see this question answered
Title: Re: How to tilemap?
Post by: nemo on October 19, 2010, 07:14:08 pm
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: [Select]
.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

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."
Title: Re: How to tilemap?
Post by: Deep Toaster on October 19, 2010, 07:18:04 pm
Here's a nice tutorial on it: http://ourl.ca/4550 (http://ourl.ca/4550).
Title: Re: How to tilemap?
Post by: Michael_Lee on October 19, 2010, 07:19:11 pm
Code: [Select]
.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
Wait, wouldn't using X and Y just return random gibberish?  How does the code know that X and Y refer to GDB1?
Title: Re: How to tilemap?
Post by: nemo on October 19, 2010, 07:22:04 pm
Code: [Select]
.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
Wait, wouldn't using X and Y just return random gibberish?  How does the code know that X and Y refer to GDB1?

oops. fixed.
Title: Re: How to tilemap?
Post by: JustCause on October 25, 2010, 10:06:07 am
This was helpful for a project I'm working on. Thanks!