1
\$\begingroup\$

I am trying to make an isometric terrain editor. My problem is not to do with making isometric graphics or rendering them, rather it is to do with indexing of tiles.

Let's say I'm making a hill at tile(10,5). This would mean that tile(10,5) will be type corner_1, tile(11,5) will be corner_2, tile(10,6) will be corner_3, and tile(11,6) will be corner_4. This will create a peak in the middle of the four tiles.

It seems simple to start with, but there are so many possibilities. If we have two hills that cross over each other, we would need inverted corner tiles. If we had a diagonal mountain, the surrounding tiles would need to be turned into diagonal inverted corner tiles. I've already created most of the images for the tiles http://opengameart.org/content/simple-iso-city-work-in-progress. My question is, is there already a set of "rules" I can follow for how terrain modifies itself around surrounding terrain? Or do I have to figure out every combination of tiles myself?

\$\endgroup\$
3
  • \$\begingroup\$ I am not sure to understand completely. You store the "height" of every corner (whether it's a hill or not) and you want to select a tile based on that ? \$\endgroup\$
    – Heckel
    Jul 20, 2015 at 11:03
  • \$\begingroup\$ @Heckel I think I get what you mean. I was storing only the height of the centre of the tile, but it does make a lot more sense to store the height of each corner! Thankyou \$\endgroup\$ Jul 20, 2015 at 19:21
  • \$\begingroup\$ Great job on the tiles, you need 4 more grass tile I believe. DId you get any progress? When you change a tile do not manually change all the surrounding tiles but flag the tile changed and fix the ones around it. Thos that changed too need to be flagged as well and run that exact same piece of code until everything is lining up. \$\endgroup\$
    – Madmenyo
    Jul 20, 2015 at 20:24

1 Answer 1

1
\$\begingroup\$

If you have the height of each corner you can easily find which tile to use. For example on the following drawing, the tile number 1 has hills on its top corner and left corner. The tile number 2 has a hill on its left corner.

example

To know which tile to use you would write something like that :

if (top_corner_height == LOW
&&  bottom_corner_height == LOW
&&  left_corner_height == LOW
&&  right_corner_height == LOW)
{
    tile = FLAT_TILE;
}
else if (top_corner_height == HIGHT
&&  bottom_corner_height == LOW
&&  left_corner_height == LOW
&&  right_corner_height == LOW)
{
    tile = ...
}
else if (...)
{
    ...
}

You just test every case possible.

\$\endgroup\$
3
  • \$\begingroup\$ Thankyou! I was worried I would have to figure out every possible combination but this makes a lot of sense. \$\endgroup\$ Jul 21, 2015 at 8:44
  • \$\begingroup\$ If it is the answer you were looking for you can accept it. Otherwise you can just wait for other people to answer it. \$\endgroup\$
    – Heckel
    Jul 21, 2015 at 13:36
  • \$\begingroup\$ I worked out how to do it, thankyou @Heckel \$\endgroup\$ Jul 21, 2015 at 17:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .