Skip to main content
2 of 2
deleted 406 characters in body
Romen
  • 406
  • 2
  • 7

If your grass tile's position in the tilemap is <Gx,Gy> then its pixel position in the game world will be:

tile_worldX = Gx * Tile_Size
tile_worldY = Gy * Tile_Size

Then you subtract the position of the screen's top-left corner from these coordinates to get their on-screen pixel position:

tile_screenX = tile_worldX - view_x
tile_screenY = tile_worldY - view_y

This assumes that the screen's top-left corner is 0,0 in your viewport. Sometimes game engines will move 0,0 to the middle or bottom-left of the viewport so you may have to compensate for that difference.

Romen
  • 406
  • 2
  • 7