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.

Newcomers DBPro Corner / Help With a Space Game

Author
Message
madmaz
15
Years of Service
User Offline
Joined: 14th Mar 2009
Location:
Posted: 21st Aug 2010 03:56 Edited at: 24th Aug 2010 15:43
Hello, i'm madmaz and i've been playing about with DBP for ages now and i'm figuring how to make my own space game. To me this is a dream as i've always wanted to play space games and now i can create my own

but i cant do this alone, so i'm asking for guidance.

i know i'm not the best, but i've been out there and i know how hard this is. So plz some of you more experienced than me, just help out a little.


Ok here is one thing i need help with, i dont know how to add accelaration to my ship, so anyone who does know, it would be apreciated if you could help.

Ok, I'm going to be adding this project into the main forum...
this will be where i come for help though.

-accelaration for ships (With top speed included)
-calculating distance
-weapons (half done)

Programing is not as easy as it seems at first... the learning is never really over...
The Zoq2
14
Years of Service
User Offline
Joined: 4th Nov 2009
Location: Linköping, Sweden
Posted: 21st Aug 2010 11:21 Edited at: 21st Aug 2010 11:23


I hope this helps!

Srry about my english im from sweeden
madmaz
15
Years of Service
User Offline
Joined: 14th Mar 2009
Location:
Posted: 21st Aug 2010 12:01
Yeah, Idk how i didin't work that out myself. but thx Zoq2

Programing is not as easy as it seems at first... the learning is never really over...
Nights Bane
14
Years of Service
User Offline
Joined: 15th Dec 2009
Location:
Posted: 21st Aug 2010 18:48 Edited at: 21st Aug 2010 19:41
I too had a similiar dream and made some crazy space sim when i got a little bored. anyway-

Heres a useful function for any game in 3D space:



It will get the distance between any two objects,

object 'a'
and
object 'b'

note: it assumes the camera is the viewpoint with which you are viewing the 3D space. (Don't letthat confuse you, or dwell on it too much, you can take it as given that it just works if you like! hehe)

If you dunno how to use functions, they are awesome. I remember when i used to be frigthened of them, but they are so damn useful.

Heres how I would use this distance one simply as an example - Object numbers represent for example:
//10 is the spaceship, 11 is a space station:




Where I have put 'POINT ONE' basically just to show you a bit better, that the space station is therefore within a range of 10,000 Units of the spaceship. Here I use this function to delete a little sphere that appears or disappears in a kind of 'elite/frontier' radar sphere.
Nights Bane
14
Years of Service
User Offline
Joined: 15th Dec 2009
Location:
Posted: 21st Aug 2010 18:58 Edited at: 21st Aug 2010 19:39
How about this, if you are testing weapons systems for your space sim already! (hehe, the best bit in my opinion)



Note that after where it says 'endfunction' it returns the value shipCanFire. this is just part of what makes functions so awesome, it makes variables more dynamic.

Once again we are using a function here. Functions get called from in the main loop, and this one literally changes a value of 1 or 0. A value like this is called a boolean. (Think back to high school computing!) it literally only shows up as true or false, or as a computer reads it: One or Zero.

A little work like this now, can save us alot of work later on. How you might ask?

Well, lets say we initialise whether the ship can fire from the beginning with a value called 'shipCanFire'(this just means setting a value to a starting value)


Well then, outside the main loop (the do-loop) at the very beginning we define shipCanFire as 0. like so:



Now, anytime we want to make it so the ship can fire later on, we are using a tiney weeny little itty bit of memory to do so. this is a good way to minimise programs and speed up the game.

so we would say in the main loop where we wanted to turn off firing:
Nights Bane
14
Years of Service
User Offline
Joined: 15th Dec 2009
Location:
Posted: 21st Aug 2010 19:07 Edited at: 21st Aug 2010 19:09
How about some Camera Control code? Here man... I created this...



This function would primarily save you loads of headaches later on when you realise you want cutscene capability, or in fact some kind of press "F2 Button to look out the 'left window'" kind of capability that makes flight sims so cool. anyway, to use this function you would need something like this within your main loop:



Nights Bane
14
Years of Service
User Offline
Joined: 15th Dec 2009
Location:
Posted: 21st Aug 2010 19:18
Now - Finally!: Some awesome accelaration code for you sir!
the following code will move the screen exactly as elite/frontier did. Your mouse moves the way you look, the shift key accelarates your engines, the ctrl key decelerates.

I recommend using something like this instead of the dark basic default move key commands. this way you can have forces acting on the ship other than just forward backward etc... it means if you get too close to a sun or a moons gravity it could suck you in! and all it would take is a little adaptation.. hehe.



madmaz
15
Years of Service
User Offline
Joined: 14th Mar 2009
Location:
Posted: 23rd Aug 2010 13:16
WOW THX for all this adivice Nights Bane, i'll be using alot of it in the game. If i do get to release a demo, i'll be sure to post it so you guys can see how its going. i'll be adding more things i'll need help on later.

again, Thx!

Programing is not as easy as it seems at first... the learning is never really over...

Login to post a reply

Server time is: 2024-09-28 20:35:29
Your offset time is: 2024-09-28 20:35:29