Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Pointers requested for grid based play.

Author
Message
Yskonyn
23
Years of Service
User Offline
Joined: 19th Dec 2002
Location: Netherlands
Posted: 7th Dec 2011 01:08
I am having difficulty deciding how to progress on a project that is supposed to have a playfield consist of a grid, where every square in the grid can be a certain terrain type, while other objects can pass over them.
It should be in 2D top-down view.
Later on an algorithm would be made where, depending on the previous tile, the next tile would be made a specific terrain type (think of random terrain creation).

Appologies for sounding vague, but I would like some pointers to how one would proceed in setting up a basic system of tiles in DBPro.

In the end it would be semi-3d as there are layers of tiles below the surface terrain. (think dwarf fortress)

So here's what I'd like:
Tile based terrain
Depending on previous tile, the next tile can only be a specific one upon world creation.
Objects need to be able to detect which type of tile they are on.

Many thanks!

(Ploughing through Hands On DBP Programming)
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 7th Dec 2011 01:37 Edited at: 7th Dec 2011 01:38
Hi Yskonyn,

Your best bet is to create a multidimensional array that is the size of the world you wish to create. Then you can populate it with something like this:



Where a . is grass, T is a tree and W is water.

Then, you can place sprites on the screen according to the contents of the array! Something like this:



When the player moves, you just check the contents of the grid square that they're moving into. If it's an impassable object, don't let them move!

Hope this helps you out!

Malevolence: The Sword of Ahkranox
www.msoa-game.com
www.facebook.com/malevolencegame
Yskonyn
23
Years of Service
User Offline
Joined: 19th Dec 2002
Location: Netherlands
Posted: 7th Dec 2011 10:18
Thanks CumQuaT! That's confirms the direction I thought I needed to go.
But you say 'your best bet', does this mean that you would probably go for a different approach, perhaps using 3D functions instead of 2D functions, because that would be easier to do?

(Ploughing through Hands On DBP Programming)
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 7th Dec 2011 13:06
I always use the method I listed, personally there are other ways to do it, but this way I find to be fastest, easiest to work with and best overall

Malevolence: The Sword of Ahkranox
www.msoa-game.com
www.facebook.com/malevolencegame

Login to post a reply

Server time is: 2026-07-10 03:59:30
Your offset time is: 2026-07-10 03:59:30