1 Replies - 1508 Views - Last Post: 07 August 2012 - 01:23 AM Rate Topic: -----

#1 kamlanie  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 16
  • Joined: 06-July 12

2d Tiles question

Posted 06 August 2012 - 09:36 PM

Hello all!

I have found myself stumped on a problem and can't seem to figure it out via google.

I am trying to figure out why tile engines usually use multiple layers for things like: the ground, the entities, dither tiles and so on. why not create an array of tiles in a way that each tile contains all the data in one object. for example the sprite image, any possible entities on the tile, check it's neighboring tiles to calculate if it needs to dither, is the tile walkable and so on.

i may just be looking at this all wrong =P

if anyone knows of a good source code i can study for tile implementations i would love to see it!

my end goal one day is to be able to make a 2d top down rpg-like minecraft using a tileset similar to Danc's Flexible tiles. but if im limited to a defined number of layers, that makes building upwards a problem.

any help would be awesome!


Is This A Good Question/Topic? 0
  • +

Replies To: 2d Tiles question

#2 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: 2d Tiles question

Posted 07 August 2012 - 01:23 AM

You could in fact hold a lot of data in each tile but the multiple layers also add to the graphical touches. I'll try to give an example.

Let's say we have this map:

Attached Image

And we now want to add a nice path through it. We have these tiles to choose from:

Attached Image

As you can see, these tiles have an alpha channel (it is a PNG). If I was to directly add these tiles to this map I would get this:

Attached Image

But with a new layer I will get something like this:

Attached Image

Much better :) Also what if we want a layer above the characters that comprises things such as treetops or behind building, if these were on the same layer they would always be behind the character. For example, say a character is supposed to walk behind this tree:

Attached Image

If it was on the same layer as the ground tiles then this wouldn't be possible. Whereas if we were to split the map into layers then we could draw the background tile layer then draw the character and only then draw the top layer to give the illusion of depth. This of course doesn't stop you from adding attributes to tiles such as whether they are passable or not.

Hope that helps somewhat :)
Was This Post Helpful? 4
  • +
  • -

Page 1 of 1