Here's some stuff on tilemapping I sent to parser padwan in PMs
--------------------------------------------------------------------------------
Tilemapping
« Sent to: parser padwan on: 16 December 2011, 21:29:12 »
--------------------------------------------------------------------------------
First, get some pics!!
[FFFFFFFFFFFFFFFF]->Pic1 ;I'll use all black for this one in this tutorial
[hex]
[hex]
[hex]
Now you have pics.
Second, make the graph database which is the data for the tilemap.
[010101010101]->GDB1 ;this is the tilemap in hexadecimal code.
[010000000001]
[010000000001]
[010101010101]
This wil make a rectangle. If all you see in this is random numbers, this is what it is.
Look at it, its a map.
Every time there is a 01, that means Pic1.
Every time there is a 00, there is nothing.
Every pair of numbers has a pic, or no pic like in 00 that is 8x8.
If you look, there are 01s that outline a bunch of 00s, which makes a rectangle border.
Every pic is assigned a number, and I'll show that to you here:
[This pic is 01]->Pic1 ; do pic1 for all of them
[This one is 02]
[03]
[04]
[05]
It goes on until 09, then goes to 0A, 0B, since it is in hex.
So change it to
[010101010101]->GDB1
[010202020201]
[010202020201]
[010101010101]
And then the middle stuff will be the second picture in pic1 and the border will be the first.
Now, for the loop.
This is the code for a tilemap of that size:
for(b,0,3) ;loop for drawing the different columns
for(a,0,5) ; loop for drawing the rows
{B*6+A+GDB1}->T ;So this, this checks if it is 00, 01, 02 etc
if T ;checks if a tile should be drawn. If it is 00, it will skip
T-- ;I honestly don't know why aeTIos said to put this here
pt-on(a*8,b*8,T*8+pic1) ;draw the tile. A was the X, B was Y, and T shows which pic.
end
end
end
Now for scrolling, I'll get more code.
--------------------------------------------------------------------------------
More tilemapping
« Sent to: parser padwan on: 16 December 2011, 21:34:51 »
--------------------------------------------------------------------------------
I forgot to say it, but you'll have to tweak the code for different map sizes.
for(b,0,Height of tilemap in 8x8 tiles minus 1)
for(a,0,Width of tilemap in 8x8 tiles minus 1)
{B*Width of tilemap+A+GDB1}->T
if T
T--
pt-on(a*8,b*8,T*8+pic1)
end
end
end
--------------------------------------------------------------------------------
Even more tilemapping
« Sent to: parser padwan on: 16 December 2011, 21:43:29 »
--------------------------------------------------------------------------------
Most of this is from butts.
With scrolling, you need an X offset and a Y offset, in pixels. I use T for the X offset, and S for the Y offset. Assuming you have a pointer to the tilemap in W and the start of the Tile sprites in Pic1, using A, B, C, D, E, F, G, H, and I as temporary variables...
So, make a huge hex bigger than the screen and -> to a GDB, say GDB1.
Now just get a pointer, in this case W, so
GDB1->W
Im editing this code from butts to make it a whole lot more optimized, but it takes up a bunch of vars.
ClrDraw
0-(T^8)->C ;Bunch of storing
T/8-1->F ;Uses S and T, the offset, to find what to show of the tmap
T/8+11->G
S/8-1->H
S/8+11->I
For(A,F,G
0-(S^8)->D
For(B,H,I)
If {B*WIDTH_OF_MAP+A+W}->E
Pt-On(C,D,E-1*8+Pic1
End
D+8->D
End
C+8->C
End
DispGraph
So when T is 8 and S is 8, you're at the top-left most corner of the tilemap. You can increment/decrement T and S using the arrow keys.