Tuesday, April 28, 2009

More code refactoring

The main script file is becoming a bit disorganized. I *did* refactor the code when I had planned to previously, but I think the time has come to break things out into separate classes. The main game class, a new class for the player, another class for the current solar system. This way, if a new system is dramatically different, we can create a class for it, and bring it up when you enter. Carrying this further, I may make a generic system class, and inherit most of the standard operations from it, but still be able to override / extend for special cases.

In any event... Later tonight there will be an update to the latest code. Orbiting is about half implemented. You can enter / exit orbit using the o key, but it is always a latitudinal only orbit, regardless of what your latitude is (even if you are above the 0 degree point). Also, you ext with no speed reference.

Plans will be to make the orbit reflect your entering angle, and add a 'Z' element to the orbit path. I will prolly have to change to calculating the path rather than cheesing out and using an orbit node that is constantly rotating and just attaching to it.

Anyway. It will be a couple days (prolly over the weekend) to get the classes broke out and restructure everything so that it works the same. The result, though, will be significant. This will step it up from being a demo to something usable.

Thanks for playing along!

--Joe

Friday, April 24, 2009

Roll Call

Just double checking to see if there is anyone following. If so, I will continue making updates. If not, then there is really no point, is there?

The current development version has added camera controls so you can change your view of the ship. Allows for some cool views of watching the collisions occur.

Next steps include adding the ability to enter and exit orbit around the planet. Add a starport near the planet. Add the ability to mine minerals from the asteroids, dock at the starport, and sell/buy/trade various materials.

Still kicking around how the multiplayer server is going to work. Part of the challenge is figuring out how to expose a server to outside connections.

Anyway. Please leave a comment to this post if you read it to let me know that someone is there. I will keep posting updates unless and until it becomes obvious that nobody is looking.

Wednesday, April 22, 2009

Collisions

So, the code is a bit messy, but collisions are working. Here is the deal:

Collision spheres have been added to the asteroids and the ship. I turned on the visibility of the collision spheres so that you can see what is going on. The next revision will have the spheres turned off.

Also, because I am impatient having to fly to the asteroids every time I test, I have added another control key. Pressing 'j' will jump you to the next asteroid in the control list.

Other interesting notes. I changed how the asteroids get added to the scene graph. I had been creating instances of the asteroid model but I am better off adding each one separately.

I am also coming to the conclusion that the flight controls suck. I am looking for suggestions on what to do instead of what I have. I do plan on adding a 'semi-auto' pilot function that will allow you to enter orbit around the planet, lock onto asteroids for mining or whatever, etc. Hopefully this will ease some of the control issues.

I am trying to decide where to go next. Part of me says to write a server that will allow multiple connections, the other part of me wants to start working on the piloting and mining functions, as well as building a space port and adding a docking function.

Any votes? Anyone reading?

--Joe

PS: Use the same download zip as before. I have updated it to include the collision routines.

Monday, April 20, 2009

Storyline.....

Some fiction to help set the mood. Written by Sean Crane...

Not for the first time since he took this job, George Walton caught himself wondering what exactly he had been thinking in accepting this contract. George swore softly as he slapped down his engine throttles and masked his ships emission signatures. a slight sigh was the only noise that alerted him to the arrival of his passenger on the flight deck.

"Do we have a problem captain?" asked the neatly dressed humanoid that had just crowded (his? her? it's?) huge bulk into HIS bridge. George thought 'why can't cargo just stay fracking below' to himself for a second before replying. "Not at the moment, but if you will notice, that just happens to be a big hunk of Ta'ren patrol cruiser sniffin' around out there, and I'm pretty sure that YOU really really do NOT want to meet it's commander." 'Personally all I want to do is survive this run, get paid, and then get the hell outta this sector' thought George.

"Well, remember our deal captain, you transport me safely to haven, and your debt to the u'theran consortium is wiped clean. Fail, and there will be NO safe place for you in the universe.... if.. you .. survive"

.......CRAP! "Grab something quick ya overgrown toad. it's gonna get a might bumpy.. those fat cows have spotted us." George's hands flew over the controls as he spun the engines up to max power and prepared to RUN LIKE HELL!

Not for the first time, George wondered just how interesting things could possibly get...

Sunday, April 19, 2009

Asteroid Belt

So I got the file generation and file parsing working! Woot!

There is now an asteroid belt forming a ring 750 units out from the origin point (0,0,0). I also have a program that will regenerate the location file if I need. The good thing is that now they are always in consistent locations, and it is repeatable. If we were to tie in networking for multi-players right now, I could create the same environment for both players. Also, since I maintain an index of pointers to all asteroids, if one gets destroyed, I can pass the index number back to the server with a "destroy" code, and that index then gets passed to all clients, with the command to run the "destroy" animation, and then stop drawing that unit until it respawns.

Good times. I have updated the zip file with a program called AsteroidBelt. Run it and let me know what you think. According to my last post, it is time to do some software engineering work to layout the modules and keep the code efficient. May be a day or two before anything interesting happens.

Thanks for looking!

Debris Field

SpaceFlight.zip

New download. This will be the cumulative package from now on, until it starts to get too large.

The planet is now appropriately larger.

I have accepted the flight controls for now, and have moved on to other things. One of the things I didn't like was that when you were simply flying along, without doing any steering, the painted starfield doesn't move. To try to compensate for that, I have added 10,000 pieces of floating debris. These are small objects that are there to help indicate motion.

Next, I changed the algorithm for asteroid placement. Currently, it is back to being randomly located, clustered around the planet. Also, (if you look at the currently very ugly code) I am maintaining a list of pointers to each asteroid. This allows me to go back during the run loop and update rotational data for each one. If you get a good look at the asteroids you will see that they are all now spinning in space as well. I have no plans on adding rotational vectors to the debris objects, however.

One other thing. If you press the e key, you will be rotated to point in the direction of the planet, and all thrust vectors are zeroed. This allows you to then add a bit of forward thrust, and will fly you back to the planet.

Upcoming plans: Map locations for the planet and asteroids. Read geometry, texture, and locational data from a .csv file and insert them into the scene graph based on this data.

Once I am able to recreate the same system every time based on .csv file entries, it will be time for a refactoring of the code. Get rid of extra crap, and start breaking parts of it out into modules to ease readability.

After that will be collision detection.

If anyone is reading this and wants to help brainstorm ideas for what the user interface should look like, I would certainly love to hear it. I am looking for the 2D overlay on top of the scene graph should look like. Things to include: Simple map of the current system, a radar display of some sort, a simple ship health overview (top view and side view, most likely), some clickable control buttons, and whatever else you may think is needed. Once I get some ideas rolling, I will put something up, even if it starts out as completely non-functional. It will be good to see how the interface "plays" on top of the scene graph.

Friday, April 17, 2009

Flight control test version 2

OK, I got the controls feeling more "floaty", meaning that thrust vectors are cumulative, rather than transitional. Rather than being able to thrust forward at a given speed, then turn left and have your vector change direction, now the speed variable is actually a thrust variable. Currently, if you leave the thrust at a non-zero value, you will accelerate perpetually. That will need to be capped once I have a max speed set for the ship.

Also, If you apply thrust in one direction, then rotate and apply thrust in the new direction, you will have a vector in both directions. As it should be. Q no longer stops motion, but instead only stops thrust application.

Play with it and it will make sense.

Use the same download link as before. If you already installed, it will replace what you had with the new version.


--Joe

And......

I don't like it. It is too abrupt, and doesn't give the feel of weightlessness in space. It flies too much like an airplane, rather than a spaceship.

I will continue to work on the feel of it. let me know what you think of the rest of it, though.

Thursday, April 16, 2009

Flight Control Test

So if you have your C:\SpaceFlight directory created, download and unzip this file:

http://www.jansenphotographyonline.com/SpaceFlight/FlightControlTest.zip

into that directory.

You should have C:\SpaceFlight\models

with several files in it, as well as 2 files in the SpaceFlight directory.

In theory, you can double click "RunFlightControls" and it should fire up.

I did add that steering requires that you click and hold the right mouse button. I also assume that you are using a 3 button mouse.

If you open a Dos prompt, and execute RunFlightControls from there, you will be able to watch some debug info in the dos window while it runs. Good times!

See what ya' think, and let me know.

--Joe

Opening Ceremonies

Ok. For all two of you that may even look here, I decided to give a central location to check for updates, rather than having to look in email all the time.

So. To get started, you will need to install Panda3D. This is the game engine that everything runs against. It is pretty simple. Go to:

http://www.panda3d.org/download.php

I am not using 1.6.0 as it is not entirely stable yet. Instead, scroll down and find version 1.5.4 and download that. it is about 57 MB

Next, run the installer and leave everything as default.

Finally, create a dircetory off of your C: drive called SpaceFlight

This will result in a directory called C:\SpaceFlight

Because I have to create a shortcut to run the file, I need to make sure that everyone uses the same directory to run from. This is where any downloads that you get should go into.

I will have a link to something to download for you pretty soon. The first sample will be nothing more than testing out the flight controls. Currently, I have the following implemented.

Accelerate = a
Decelerate = z
full stop = q
reset position to starting point = x
quit the program = Esc
zoom in and out = mouse wheel

Steering the ship is done by moving the mouse around in the main window. I will probably have it modified to require that the mouse button is held down to steer before I release. The world consists of a planet and a row of 150 asteroids all nicely lined up to provide visual feedback for relative motion.

Once it is posted, test the flight controls and please leave feedback on what you think. This is when I want to work out problems in sensitivity, etc. This version only implements the smallest ship, so it is far more maneuverable than what any upcoming capital ships will end up being.

Thanks again for helping with the testing. I hope that you find something interesting to play with eventually.

--Joe