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 / Space Combat Simulation Tutorial or Code?

Author
Message
Ultimatum
23
Years of Service
User Offline
Joined: 14th Mar 2003
Location:
Posted: 14th Mar 2003 17:18
Greetings everyone:

I am currently working with the DBpro demo and am seriously considering buying it once my time runs out (I just started playing with it yesterday).

I am looking for some sample code or even a tutorial on a space combat/flight game ala "Freelancer" or some of the other games out there.

I have been able to find little bits of information here and there, but I was wondering if there were some examples where the game environment could be absolutely gigantic, so it would have to be loaded dynamically depending on the player's position in the universe.

I was thinking about creating a database that would represent the universe with records indicating objects and their positions (coordinates). The player ship would be in some sort of skysphere that would limit the viewable distance (so the entire universe wouldn't have to be rendered at once).

Does anyone know of any examples of this? Any ideas on where I can get started researching this idea?

I wish this forum had a search feature.

Thanks in advance,
-- Ultimatum --
darkCorridor
23
Years of Service
User Offline
Joined: 27th Jan 2003
Location:
Posted: 14th Mar 2003 17:49
it does have a search thingy ... use google advanced search and enter http://darkbasicpro.com in site:

[br]mikey
The Darthster
23
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 14th Mar 2003 19:43
I have some (simple) spaceflight code that you can look at:



I think the current controls are using the keyboard, although there are other controls remmed out in there. arrowkeys to turn, q and e to apply thrust, wasd to strafe, spacekey to fire.

I've also sucessfully made a dynamically loaded large environment, I've made a 4000x4000 matrix using a random number generator. The terrain looks rubbish, but it is very big. You could do the same sort of thing in space, but I'm having trouble getting planets to scale seamlessly from space to upper atmosphere to ground.

Once I was but the learner,
now, I am the Master.
Ultimatum
23
Years of Service
User Offline
Joined: 14th Mar 2003
Location:
Posted: 14th Mar 2003 20:04
Thank you so much for the sample code, I will experiment with it to see if I can get the effect I am looking for.

Would you be willing to share your code for the large environment generator?

Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 14th Mar 2003 23:24
Here is a little one-nighter that never went anywhere - ripe for editing and making something good out of

If you run it as is then use the middle mouse button to zoom in/out - the starting camera angle is inside the camera tracked ship.

This has a few neat tricks in that might appear confusing if you are new, feel free to ask away.

I've put the media up for you to download (7mb): http://freescape.successionthebetrayal.com/spaceMedia.zip.

I had some trouble picking out the exact files I wanted from those directories and left them in the root - I have adjusted the source code to match - and here is that source code:



I did this a fair while a go as a technology tester for a much larger project i'm still working on, as i'm never going to return to it so i'm happy to let everyone have it as open-source. I am not sure but I think some of the planet textures might be copyrighted, can't remember what ones I used... /shrug

Anyway first exercise is to program it so you can fly around and take a look at the galaxy, it's quite fun to fly through the galactic arm and looks pretty if you zoom right out and look at the shape of the milky way (although you might have to flatten the universe so you can see it all when you do that, can't remember how I left it).

BTW: Unless you change it the middle mouse button zooms camera in and out, this is important because the camera starts inside a spaceship!

Andy

Pneumatic Dryll, Outrageous epic cleric of EQ/Xev
God made the world in 7 days, but we're still waiting for the patch.
Ultimatum
23
Years of Service
User Offline
Joined: 14th Mar 2003
Location:
Posted: 15th Mar 2003 18:29
Wow, thanks a bunch for posting the media files and code. I really appreciate it, it will give me a kickstart to learning how its done. I am a programmer by trade, but I just started using DarkBasic a few days ago, so I hope to learn it quickly.

BTW, I am having a few issue with the code. The Gas6.bmp file was corrupt in the media ZIP, so I copied the Gas5.bmp to take its place. However, when I run the code it crashes once the screen goes black. Does this have to do with the Gas6 file being corrupt? Or is there some other error in the code? Any ideas?

Thanks again!

Ultimatum
23
Years of Service
User Offline
Joined: 14th Mar 2003
Location:
Posted: 15th Mar 2003 19:59
Nevermind on the crash, it was because the ship models were in .3DS format, I converted them to .X format (also changing the reference to them in the code) and everything loads up now without crashing.

I can't quite figure out the zooming (my middle mouse button does nothing), but I am sure that I can figure out some way to navigate around the map eventually.

Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 15th Mar 2003 20:03
camZ#(1)=camZ#(1)+mouseMoveZ()

this is the line which is controlling the zooming, you could change it too

if upkey() then camZ#(1)=camZ#(1)+10
if downkey() then camZ#(1)=camZ#(1)-10

Pneumatic Dryll, Outrageous epic cleric of EQ/Xev
God made the world in 7 days, but we're still waiting for the patch.

Login to post a reply

Server time is: 2026-07-11 02:36:06
Your offset time is: 2026-07-11 02:36:06