Author Topic: Accessing a Tile in a Tilemap Question  (Read 2823 times)

0 Members and 1 Guest are viewing this topic.

Offline collechess

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +22/-2
    • View Profile
Accessing a Tile in a Tilemap Question
« on: October 10, 2011, 05:16:03 pm »
I have a routine for drawing a tilemap, and it works fine, but I need a way to access a specific tile.  Everything works fine except for the fact that I don't know how to change the value to a byte and back to a nibble.  Here is the code, r1 is y-position and r2 is x-position.

Code: [Select]

.Define

.Tiles
[0000000000000000->Pic1
[FFFFFFFFFFFFFFFFFF
[0123456789ABCDEF

.Map
[111111111111->GDB1
[000000000000
[101010101010
[010101010101
[101010100101
[101000000000
[010112101010
[100000000001

ClrDraw

.Draw map
For (I,0,7)
For (J,0,6)
{I*6+J+GDB1}->A
Pt-On(J*16,I*8,A/16*8+Pic1
Pt-On(J*16+8,I*8,A^16*8+Pic1
End
End

DispGraph
Repeat getkey(54)
End

sub(GT,r1,r2)
ClrDraw
DispGraph
Text(20,20,B>Dec)
Text(20,30,A>Dec)

Repeat getkey(15)
End

Lbl GT
{r1-1*6+r2+GDB1}->A
A/16->B
A^16->A
Return

I want to be able to give one x and y value and return the value of that tile.
« Last Edit: October 10, 2011, 09:52:56 pm by collechess »