• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

finding y-position of a found tile

RetroKoH

Member
In Game Maker 1.4, there was a function called tile_get_y which would return the y_position of the top of a given tile. I'm porting my tile collision engine from GMS 1.4 and would like to keep it functionally intact, as much as possible (Please don't send me tutorials, I already have a working engine and don't wanna rebuilt from the ground up)

I just need something equivalent to the old tile_get_y, whether it be a replacement function, or some kind of work around. Thank you! <3
 

Slyddar

Member
tilemap_get_y will get the y position, and tilemap_get_cell_y_at_pixel will get the cell position at a pixel coordinate, if you need to go the other way.
 

RetroKoH

Member
tilemap_get_y will get the y position, and tilemap_get_cell_y_at_pixel will get the cell position at a pixel coordinate, if you need to go the other way.
I tried that, but for some reason it gave me -1.

As a test, I tried to use those to get the tile's y-position if the mouse was on top of a tile. Only ever got -1. Maybe I used the function incorrectly?
 

Slyddar

Member
Well that gets the y position of the tilemap. Sorry, misread your request. If you want the y positon of a tile, just div the y coordinate by the tile size. If you want the pixel position given the tile cell, just multiply the cell by the tile size.
 

RetroKoH

Member
Well that gets the y position of the tilemap. Sorry, misread your request. If you want the y positon of a tile, just div the y coordinate by the tile size. If you want the pixel position given the tile cell, just multiply the cell by the tile size.
Much thanks! I took that approach, and it seems to be doing the trick, though there are a couple of kinks I need to iron out. Cheers!
 

TheouAegis

Member
If you are moving your tilemap for scrolling or whatever, then you need to also remember to add the position of the tile map mod tile size. In other words, if your tile map has been shifted up 23 pixels and your tile is 16 x 16, you would need to add -7 to the calculated y.
 

RetroKoH

Member
Want to give a big thank you to everyone involved. I was able to port my old engine over, and it works exactly as it should
1627660271583.png
 
Top