Get value of the certain tile position in Map Collision

Démarré par faeldaniel, 07 Avril 2014 à 22:29:10

« précédent - suivant »

0 Membres et 1 Invité sur ce sujet


Hello alekmaul,

I am created my Routine for get Map Collision, I need to know what is the value a certain tile, for exemple, i having one Map Collision with Width 256 and Heigth 512 and genarate my Collision Map, your name is definide as &mapcol for this imagem, i liked get value of 14º tile and return if is 1st or 2st tile becouse Map Collision has only 2 tiles.

shot valueOfTile;

valueOfTile = &mapcol / (13); //13st tile, return 1 or 1st Tile
valueOfTile = &mapcol / (14); //14st tile, Return 1 or 1st Tile
valueOfTile = &mapcol / (15); //15st tile, Return 2 or 2st Tile
valueOfTile = &mapcol / (16); //16st tile, Return 2 or 2st Tile
valueOfTile = &mapcol / (17); //17st tile, Return 1 or 1st Tile
valueOfTile = &mapcol / (18); //18st tile, Return 2 or 2st Tile



I don't understand what you want to do.
If you need value of 14° tile of your 1 line, you just need to do valueOfTile=mapcol[14], why are you usigned & for address of mapcol ?
If it is value of 14° tile of 2nd line, it's mapcol[14*256] if you have a short type for mapcol, and so on ...


Yes I know, &mapcol  is one address and not usigned, this example is not correct, i am showing one possible solution for my problem, but lets go, my problem is Collision Map,I can not understand how it works, my backgrounds has 512px / 756px, this is one example below, i think this function is valid for my imagem, but dont working.

u16 checkMapCol(short OBJX, short OBJY, u8 *mapCol){
        //512 pixel width 512/8 = 64
        //768 pixel height -> 768/8 = 96     
u16 *ptrMap = (u16 *) &mapCol +  (OBJY>>3)*64 + (OBJX>>3)*96;

return (*ptrMap);

Original image:

That's the only problem I could not solve yet and i need your help for this.


Well, your problem is with the coordinates.
I think you must only have
  //512 pixel width 512/8 = 64
   u16 *ptrMap = (u16 *) &mapCol +  (OBJY>>3)*64 + (OBJX>>3);
X does not need to be multiply by height

Also, try to use u16 instead of short, short is signed and is bad for SNES (your u8 for mapcol is correct).


I try this but dont working, honestly I have no idea what's going on can. this would be a good challenge for you, take this my image and try with your code. I am using map with SC_64x32, X maximum 512pixel and Y 756, vram is update and only Y axis.


faeldaniel, no i'm not working like that.
I did an example with mario, it works so I did my job.
If you want help, share your code and I will see where it is not ok.


My code for rpg is very large and you take a long time to understand but if one day you're curious about some of my routines I can send to you brother.

I go creat new code for exemple Mode1Scroll with sprites using my engine based for we working in colission and you can post in the future realeases of exemples in lib. Anyway I want to give my contribution :)