This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
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.
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.
(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)