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.

Code Snippets / [DBP] 3-D Grid Builder

Author
Message
Zelthor
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: in my Fort planning for world domination
Posted: 4th Mar 2008 15:55 Edited at: 4th Mar 2008 16:12
This is the level generator I created for my DarkROADS project:
http://forum.thegamecreators.com/?m=forum_view&t=124851&b=8

I know it's a bit messy, but I'll explain to you how it works:
it comes with 3 .dba files and a simple texture, which are zipped and attached!

Step 1
it initializes these global variables:

global spareObjects = 5
global gridWidth = 7
global blockWidth = 40
global blockHeight = 6
global blockDepth = 40

My function starts creating blocks with objectnumbers higher than spareObjects. So you can define how many spare objects you will need, lets say, for a player model, or items.

The gridWidth is the number of boxes you wish your grid to be wide.

blockWidth, Height and Depth represent the dimensions of you platform blocks.

Step 2
BuildGrid() takes you inside the Grid v1.dba document.

It starts of initializing some variables for positioning your 'Grid'.

Next it will loop through 3 two dimensional grids, located in Level1.txt
(note the 99 at the end of every grid. This acts as an EndOfFile marker)

The first is for the 'type' of your blocks.
0 = no block at all
1 = a metal block
You can add more stuff if you like, read the comments in de source!

next it will loop through the second grid which will define the y position of each block.
0 = do nothing
1 = place the block 1 position higher
2 = place the block 2 positions higher
etc.

last it will loop through a grid which defines the height of each block.
0 = do nothing
1 = default height
2 = twice the default height.
etc.


You can move the camera by holding down the right mouse button to steer the camera, and pressing the arrow keys to move around.

It's not the cleanest code. But heck, i own this program since 1 month now and it works!

Here are the snippets, without texture though..
You'll have to provide those yourself (only 2 needed)
V0.dba:

Grid v1.dba

level1.txt


Feedback is most welcome!

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-17 06:22:10
Your offset time is: 2024-05-17 06:22:10