2D tile game question

Advanced game related topics
UUICEO
User
User
Posts: 57
Joined: Tue Mar 10, 2009 9:09 pm
Location: Shakopee, Minnesota. USA

2D tile game question

Post by UUICEO »

I'm totally new to the graphics end of programming and I have a question regarding layering of tiles and how it works exactly. I'm going to be having sprites going inside of buildings and under bridges but I'm not sure how to layer the tiles to be able to do that. I searched the forum for layering tiles but didn't come up with much. Any help would be greatly appreciated.
Windows 7 Ultimate x64 / PureBasic 5.21 LTS / ProGUI Platinum / PureVision / http://www.linkedin.com/groups/PureBasi ... =&trk=tyah
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: 2D tile game question

Post by J. Baker »

Read all of this topic. There is a layer example. ;)

http://forum.purebasic.com/english/view ... a1985763d3
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Re: 2D tile game question

Post by citystate »

basically it comes down to the order you display the sprites to the screen - later sprites would appear to be on top of earlier sprites.

so, for a three layer display:
1) display all your background sprites
2) display all the character/object/wall sprites
3) display all the "overhead" sprites

should do the trick
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
UUICEO
User
User
Posts: 57
Joined: Tue Mar 10, 2009 9:09 pm
Location: Shakopee, Minnesota. USA

Re: 2D tile game question

Post by UUICEO »

I thank you for the info. I'm not completely understanding how this works but I will figure it out.
Windows 7 Ultimate x64 / PureBasic 5.21 LTS / ProGUI Platinum / PureVision / http://www.linkedin.com/groups/PureBasi ... =&trk=tyah
Zach
Addict
Addict
Posts: 1656
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: 2D tile game question

Post by Zach »

UUICEO wrote:I thank you for the info. I'm not completely understanding how this works but I will figure it out.
Think of it this way. When you build your Procedure that will draw/redraw your graphics to update the scene, all you have to do is draw them in the proper order, or Z-Level. Even though 2D sprite/tile games use simple X/Y coordinates, you still need to take Z coordinates into consideration, because the Z axis controls the depth at which an object is drawn. That is, how "deep" it is in the scene.

Think of it as like Disney's early animation technique of using a multi-plane camera. By positioning traditional animation cels at various positions, and controlling how and when they move, you can simulate a 3D / Parrallax effect which can give you depth of field and make a scene feel 3 dimensional.

So let's say you have a scene you want to build. You have a town square and in the center of it is a fountain. We have some shops and houses as well, some outdoor picnic tables, trees, the road is cobblestone and it cuts through large patches of green grass, with various flowers, bushes and shrubbery growing out of the ground..

The first thing you draw onto your screen buffer would be all the ground tiles. That would be grass, cobblestone for the street, perhaps some other mixed tiles showing different textures of grass, specs of dirt or flower patches, etc. If you had a stream running through the town, you might place those water related tiles as well.

The second thing you draw would be your "props" layer. Mostly this will consist of things like your Trees, Houses, Shops, fences, shrubs and bushes, picnic tables, and things like that.

The third thing you draw would be your characters, and perhaps some other props that need to be drawn on top of everything else. Like say a horse and buggy traveling through the town.

Part of what you draw and what layer it is in will also depend on any special effects you might want to do, relating to things like which tiles are passable or not passable, or if for example you want to make your character pass "behind" a tree as he runs through the area, or you want to make sure he is not covered by the tree sprite when he runs in front of it.

2D Tile based games may appear simple, but they can be very complex and can deal with a lot of different problems in their own unique way; this was just a very simplified overview of what you want to consider when setting up your drawing order for sprites
Image
Post Reply