Communauté PortableDev

Développement SNES => PVSnesLib English section => Discussion démarrée par: faeldaniel le 07 Avril 2014 à 22:29:10

Titre: Get value of the certain tile position in Map Collision
Posté par: faeldaniel le 07 Avril 2014 à 22:29:10
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.

Citation
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

...

Titre: Re : Get value of the certain tile position in Map Collision
Posté par: alekmaul le 08 Avril 2014 à 06:21:36
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 ...
Titre: Re : Get value of the certain tile position in Map Collision
Posté par: faeldaniel le 09 Avril 2014 à 02:27:01
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:
http://faeldaniel.com.br/stg_1_1_col.bmp (http://faeldaniel.com.br/stg_1_1_col.bmp)
(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.
Titre: Re : Get value of the certain tile position in Map Collision
Posté par: alekmaul le 09 Avril 2014 à 06:30:25
Well, your problem is with the coordinates.
I think you must only have
Citation
  //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).
Titre: Re : Get value of the certain tile position in Map Collision
Posté par: faeldaniel le 10 Avril 2014 à 02:50:57
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.
Titre: Re : Get value of the certain tile position in Map Collision
Posté par: alekmaul le 10 Avril 2014 à 09:00:29
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.
Titre: Re : Get value of the certain tile position in Map Collision
Posté par: faeldaniel le 10 Avril 2014 à 14:35:06
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 :)