Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Isometric tilemap design (suggestions appreciated)  (Read 2084 times)

0 Members and 2 Guests are viewing this topic.

tsarcasm

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Isometric tilemap design (suggestions appreciated)
« on: March 30, 2020, 11:55:35 pm »
Hey all, first post here so I hope this is the correct place to ask a question like this.

I'm trying to create a 2d city builder type game (think simcity 3000) and I'm starting with terrain.
The look I'm going for is a 2d isometric terrain map. (something like this: https://i.ytimg.com/vi/EN8Y-zoknrY/maxresdefault.jpg).

My current approach uses a fixed size VertexArray of tris, each tile is represented by two tris arranged in a rhombus, the 4 points of each rhombus are calculated using trigonometry (this is fairly trivial, I calculate the X and Y offsets of the topmost vertex) - see attachment 1.

I achieve a z axis (height) by creating a heightmap (2d int array), each vertex has a height. This height is added to the Y position of each vertex. Since vertices share a height this creates a really good 2d effect - see attachment 2 & 3.

The problem here is that, since the VertexArray is rendered in one go, this 2d height effect can't be applied to sprites or objects drawn after the terrain. See attachment 2, the house sprite is rendered on "on top of" a hill on the map, obviously, since it's a 2d vertex array.

My question is, what's the best way to draw sprites "behind" features on the terrain.
One idea I had would be to draw buildings as quads on the terrain vertexarray, but I feel like this may lead to significant performance issues since each layer I add doubles the number of vertices required. This also means every graphic I want to conform to the terrain must be stored as points on the vertexarray and so have to be included in the vertexarray texture.

Any suggestions?
« Last Edit: March 30, 2020, 11:58:12 pm by tsarcasm »

Paul

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
Re: Isometric tilemap design (suggestions appreciated)
« Reply #1 on: March 31, 2020, 05:41:22 pm »
I'm not sure there is any solution how achieve it and stay in 2D.

How it's done in isometric games:
- terrain is build from sprites and there is no overlap with rest of sprites like buildings and units thanks to right view angle and limited height (Transport Tycoon, Age of Empires 2)
- "3D terrain" also with limited heights which don't overlap sprites (Age of Empires 2 HD)

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Isometric tilemap design (suggestions appreciated)
« Reply #2 on: March 31, 2020, 06:01:33 pm »
There are two "solutions" that I can think of:
1) track every thing that should be drawn in front of the sprite and then clip the sprite to those boundaries when (or before) drawing, or
2) batch together the drawing of the tiles and the things that may need to be drawn behind i.e. a single vertex array that draws the tiles as well as all of the sprites, allowing you to draw the tiles in front after those sprites (sort by y is a common approach), remembering that the number of vertices may fluctuate if the number of sprites isn't constant.

I'd recommend the second one. It's simpler and definitely works.
The only thing is that your "terrain renderer" now becomes your "scene renderer".
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything