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 / How do I create a terrain that expands

Author
Message
print TheGourglex
13
Years of Service
User Offline
Joined: 24th Dec 2012
Location:
Posted: 24th Dec 2012 15:45
excuse me for my bad English
Well, I want to put in my game a land, while the player forward, it extends, indefinitely.
I really don't know how to do that! Please help-me!
I already appreciate,
The Gourglex.

"Better than do is try"
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 24th Dec 2012 20:48 Edited at: 24th Dec 2012 21:31
Wooh, that's an interesting question. There's no 30 minute solution that I am aware of. There are terrain plugins that let you create huge terrains, but you also need to position objects with limited coordinates in a world that is limitless.

Malvolence have implemented an infinate world, so who knows, you might get a few tips from them.

On your own, you could apply the principles of global wrapping or relative generation (or both). You have to consider the limits of numeric types; particularly floats, which have single precision (7 digits).

All DBP numeric variables have a maximum value (unlike strings which cannot be calculated with); when you reach the end of the number you have to start from the begining again. You have 7 digits to play with! Therefore let's imagine -99999.99 to 99999.99 is the coordinate of TheGourglex's game world; with a couple of decimal places to spare for precision physics. What position 99999.99,99999.99,99999.99 means is is trivial; you just have 7 digits multiplied by miles/metres/km or what ever you wish.

With wrapping, your coordinates (position) is global, (added to the origin of the world; as is commonly used). You get shifted back when you exceed the limits of the current section; and the world is regenerated into the next section. In other words, if you travel from Natal to beyond Cuiabail at the edge of Brasil, you and the terrain, which represents Brasil, would be shifted east, 99999 units, where the terrain must be regenerated into Bolivia.

With relative regeneration, you are the origin of the world, and the world revolves around you; coordinates are relative to the client that queries them; and each client receives their own relative coordinates of the other clients. Your object's real location is 0,0,0; which is exclusive to you. You can never exceed the floating point limit, and neither should the world. You move forward by shifting the world back. New terrain and object data is generated on demand. Your section-space coordinate is calculated as -WorldPos. You change your references to new section data when the world coordinate exceeds the range; then wrap the terrain back. This method requires more experience; and is not supported by some convinience features of certain plugins catered towards a global coordinate system.

Not a 5 minute job.

Login to post a reply

Server time is: 2026-07-07 18:44:47
Your offset time is: 2026-07-07 18:44:47