aspose file tools*
The moose likes Game Development and the fly likes What does it mean to convert tile positions to pixel positions in a tilebased map? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "What does it mean to convert tile positions to pixel positions in a tilebased map?" Watch "What does it mean to convert tile positions to pixel positions in a tilebased map?" New topic
Author

What does it mean to convert tile positions to pixel positions in a tilebased map?

John Quach
Ranch Hand

Joined: Sep 28, 2011
Posts: 50
Developing Games in Java by David Brackeen

In earlier demos in the book, the sprite's position was relative to the screen, but in this game, the sprite's position is relative to the tile map. You can use the TileMapRender.tilesToPixels() static function to convert tile positions to pixel positions in the map. This function multiplies the number of tiles by the tile size:

int pixelSize = numTiles * TILE_SIZE;

This way, sprites can move around to any position in the map and don't have to be justified with the tile boundaries.




I think I have some idea of this concept. But I'm still lost after a few days of trying to figure it out.
Antonio Principato
Greenhorn

Joined: May 21, 2012
Posts: 10
Say you have a tilebased map and it is 3X3 that means that if it were a 2d array storing the tile data it would look like this. With each number representing the index of the array that corresponds to the tile.

(0,0)(1,0)(2,0)
(0,1)(1,1)(2,1)
(1,2(1 ,2)(2, 2) But that's referring to the data in tiles. so if the you were referring to the middle of the screen it would be x == 1 y == 1


If you were referring to these locations in pixels it would be in a format like this. With each number referring to the location on the screen in pixels
(assuming that each tile is 32x32)

(0,0) (32,0) (64,0)
(0,32)(32,32)(64,32)
(0,64)(32,64)(64,64)

Im just assuming that this is the answer that you are looking for
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What does it mean to convert tile positions to pixel positions in a tilebased map?