Using a 3/4th perspective, I'm trying to create a way to render cliffs where nothing is overlapped, and it creates an accurate representation of the elevation. This is a rough mockup of how it might look in-game:
The way the tile data is organized is by layer. Each elevation has a layer class which holds all of the ground data for that specific layer, and all unoccupied space is simply null in the array. I can't seem to come up with a way to render the data so it would look something like this. I've thought about rendering from highest to lowest elevation, the other way around, etc. All entailed a situation where something is getting overlapped that shouldn't be.
What's the best way to do this?
I suggest that you draw the top rows [on the screen] first, and build up from the ground, overwriting the higher rows as you draw those tiles (you'll have to traverse the upper layers as you do this, but that should be easy as the X and Y will remain unchanged), and do so until all rows are completely drawn for you.
You can even loop beyond the bottom and just draw other things that are higher up even though their corresponding ground tiles are off the screen (creating a sense of even more depth for your scenes as your players navigate in any direction).
Additionally, if alpha-blending (transparency) mode is support, and if your character is always positioned in the centre of the screen (e.g., because the background scrolls when the player's character moves), you could also use transparency effects (with alpha-blending) when drawing the tiles that would block the view of the character (so the player can see what's going on), and gradually reduce this transparency effect with each tile that is further away from the character (80% transparency for the blocking tile, 60% for the next ones, 40% for the ones outside of that, then 20% outside of that, and finally 0% for all the rest).
I don't know if it's important to how your game works to actually make the tile have depth information or just APPEAR to have depth. If appearing to have depth is ok, then here's the way I addressed this in my tile engine:
Each map has a two-dimensional array of MapCell objects. A MapCell can be thought of as a "tile slot" in that it represents an area on the map where a tile would be drawn.
Now, each MapCell has two (it could be more, but I only use two) MapCellLayer objects. The first MapCellLayer object is always defined, but the second one is optional (i.e. often == null).
A MapCellLayer can have up to five Tile objects. Tile objects represent the actual tiles being drawn to the screen and hold a reference to the tile index from the tilesheet. The reason there are five Tile objects is because of how they're drawn and used. They're set up like this:
Ground - This is the base tile, it's drawn on the screen first and appears below all other tiles in the MapCell and the players.
Mask 1 - This tile is drawn second (if it exists) and provides a way to add tiles with alpha transparency over top of the ground tile. It's drawn below the player.
Mask 2 - This is exactly the same as the Mask 1 tile except it's drawn after to allow for even more control of the map by overlaying more tiles.
Fringe 1 - This tile is drawn after Mask 2 and is effectively the same as Mask 1 with the only exception being that it is drawn OVER the player. Players get drawn between Mask 2 and Fringe 1.
Fringe 2 - You may have guessed it already, but this is the same as Fringe 1, but drawn over it.
My draw call works like this:
Loop through all the MapCells within the camera's view.
Loop through all MapCellLayers for the current MapCell
If the layer exists
Draw the Ground tile if it exists
Draw the Mask 1 tile if it exists
Draw the Mask 2 tile if it exists
Draw the Player on the tile if any
Draw the Fringe 1 tile if it exists
Draw the Fringe 2 tile if it exists
End if layer exists
End MapCellLayer loop
End MapCell loop
A few notes:
If you you build your maps with this system, you can create some advanced looking terrain features with the right tileset. See my example pictures below.
The point of the MapCellLayer is so that I can have areas where two players occupy the same cell but one is above another one such as on bridges or inside houses (i.e. first and second floor, although inside houses I only draw the MapCellLayer that the player is on).
I don't actually draw the players in the tile loop, I just wanted to make it simple. I actually make use of SpriteSortMode.FrontToBack so that each layer has it's own values and gets drawn in the correct order. The player/npc loop is then done separately. I recommend this method especially if your players/npcs are larger than a single tile.
Here's some example pictures from one of the maps in my game. I've taken screenshots working up from drawing only Ground tiles to all tiles up to Fringe 2. The player is stationary.
+ Mask 1 (Note the use of transparency on the bushes and tree roots.)
+ Mask 2 (Note the ladder being drawn over the rock wall from Mask 1.)
+ Fringe 1 (Note that the player is being drawn behind the tree.)
+ Fringe 2 (Note how the branches of the pink tree on the right now overlap the ones from the tree on the left.)
I hope this helps you. Let me know if you have any questions.
I would calculate the visible portion when rendering each block so that you only ever render each screen block once.
I would implement it something like this:
TileImage GetTileImage(int screenx, int screeny)
for(int height = layers.count - 1; height >= 0; height--)
//translate height down the screen to get the correct block
TileImage image = layers[height].GetTile(screenx,screeny-height);
if(image != NULL)
//If we got here no tile makes up this screen tile, handle accordingly
So what this code does, is start off at the max height layer, and looks for a tile at X: ScreenX Y: ScreenY - Height
As the block that shows at screen position 5,5 at height 3 is actually at word position 5,2
So the loop will search from the top height until it finds a block for that screen coord.
Hope this makes sense.
So in your rendering loop you would loop over x and y in screen coords and call GetTileImage() once per image square.
Using a 3/4th perspective, I'm trying to create a way to render cliffs where nothing is overlapped, and it creates an accurate representation of the elevation. This is a rough mockup of how it might look in-game: The way the tile data is organized is
I've setup a tile rendering system based on Mapnik + PostGIS. When I open the data with QGis directly from PostGIS it looks fine; but when I attempt to generate tiles with Mapnik they look stretched (notice that this issue only appears when the rende
I'm working on a 2D tiled game with Java and libGDX. I'm having problems implementing gamescreens. I'm trying to set the screen to gameScreen and start rendering tiles, but I'm getting a nullpointer exception on my camera and my renderer. I think wha
I am trying to render the visible portion of a diamond-shaped isometric map. The "world" coordinate system is a 2D Cartesian system, with the coordinates increasing diagonally (in terms of the view coordinate system) along the axes. The "vi
I've been stuck on how to use my local tiles which i rendered with mapnik's generate_tiles.py and all the data is on postgresql. I'm kinda confused on what i should do to "feed" the tiles to openlayers. The map would be used in django btw. hopin
Hitting a bit of a roadblock with my game's development and I'm just looking for some outside advice. I'm trying to render a tilemap for my mobile game (Android) and I'm using LibGDX. Now, here's the issue. Using my simplified version of LibGDX's own
I'm new to OpenStreetMap and I'm trying to figure out how to process an OSM XML file and create map tiles for offline use. I already have the OSM XML file downloaded; I just don't know what to do next. Once I have the tiles, I'll be displaying them i
Introduction: I've built a local OSM server following this guide https://switch2osm.org/serving-tiles/manually-building-a-tile-server-14-04/. I've gotten through the guide just fine, and the server appears to be rendering because when I type: <my ser
I have generated my own tiles for part of the Great Britain using the osm.pbf file from here  and the style sheets from here . I'm using Mapnik version 3.0.9 and generating the tiles using the polytiles.py script from  As I understand it the
So I am trying to render all the tiles for the state of Florida with the file generate_tiles.py that came with mapnik. The tiles are rendering, but erroneously including multiple city names (see below). Does anyone know how to fix this? -------------
I've been making some pretty (but computationally expensive) tiles with TileMill and I'd like to serve them up. First, I served them straight from TileMill. Every tile gets rendered dynamically, which is simple, but slow. Next, I exported a region as
I am looking for a solution for following use-case: I need to run a local map server using OpenStreetMap (OSM) data Map server needs to be able to render a set of map tiles to local directory on disk(TMS scheme) Input parameters for tile rendering sh
I want to serve vector tiles server in pbf format. For that I used Mapnik-vector-tiles which is bundled by avecado. Using avecado_server i can render pbf tiles on the fly using ./avecado_server -b 2 test/xml/vector_imposm_nocollect.xml 7789 But the f
We have built an OSM Tile Server following the instructions at http://switch2osm.org/serving-tiles/building-a-tile-server-from-packages/ The tile server is rendering tiles, but the street names on the tiles are not readable on high DPI devices, e.g.
I've created a GeoTiff that should have GPS coordinates in it using AgiSoft. When I load it into QGIS, it renders the image in a perspective and I want to always see the image from the "top" down. When I split the GeoTiff into bands, I get a top
I am a beginner at GIS and I am developing a Java Application which needs a map. (The map would specifically be of just one city in the Philippines.) I have researched on different ways to do this and I have found that I will need a tile server to pu
How much, if any, has the new iPad has gained in PDF rendering speed with the A5X processor (quad-core graphics)? --------------Solutions------------- I care a lot about PDFs because as a lawyer I have to review a lot of scanned documents. The perfor
I'm working on a small tile/sprite-based PC game with a team of people, and we're running into performance issues. The last time I used OpenGL was around 2004, so I've been teaching myself how to use the core profile, and I'm finding myself a little
Desktop applications pinned to the new Windows 8 start menu have the icon centered inside the tile and a default background color (like in the left image). Is there any way to make a "metro" looking tile (like in the right image) for a desktop a