Développement SNES > PVSnesLib English section

Get value of the certain tile position in Map Collision

(1/2) > >>

faeldaniel:
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.


--- Citer --- 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

...


--- Fin de citation ---

alekmaul:
Hello,
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 ...

faeldaniel:
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.


--- Code: ---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);
}

--- Fin du code ---

Original image:
http://faeldaniel.com.br/stg_1_1_col.bmp


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

alekmaul:
Well, your problem is with the coordinates.
I think you must only have
--- Citer ---  //512 pixel width 512/8 = 64
   u16 *ptrMap = (u16 *) &mapCol +  (OBJY>>3)*64 + (OBJX>>3);

--- Fin de citation ---
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).

faeldaniel:
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.

Navigation

[0] Index des messages

[#] Page suivante

Sortir du mode mobile