This is just a basic foundation for building upon yourself, and creating your own version of a space exploration game .It allows for full freedom in
exploring solar systems and planets with your rocket ship in real time. You'll just have to create them first! It contains all the code necessary for flying
through space and flying above planets, and this document will provide some additional ideas and instruction about other features you might like to
include.
Flight instructions...
The rocket ship can be found on the RIVET CITY FLIGHT DECK, and the key will be inside a nearby AMMUNITION BOX. To enter and take off stand
near the door of the rocket ship, set walk/run toggle to walk and drop the key. During flight the walk/run toggle is used to control the speed, and the
direction is controlled by looking left and right. To ascend and descend you will need to look up and down further. To land
SET SPEED TO SLOW and descend into the ground. You will occasionally experience turbulence during flight, especially after re-entry. Fly the rocket
ship over water to return to smooth flight. And be careful not to fly off the edge of the map!
If you fly high enough you will take the rocket ship into space, where it is controlled by buttons and levers. There are four directional controls, the lever on the right switches the engine on and off and the left buttons increase speed. Each button multiplies the speed by 10, so both together will be 100 times faster. This speed is for interplanetary travel, so use it sparingly or you may lose the Earth forever! If you "double click" buttons too quickly they may not set correctly. Simply operate them too quickly again to get back to normal. To get back to atmosphere flight just fly back towards the Earth. The precise position you enter would normally determine your location on the planet, but in the demonstration there is only one location: The Capital wasteland.
The demonstration just has one object and one planet to show how each type works, and the control scripts have detailed explanations about what they do. The object is a stationary rocket ship which starts off directly in front of you, but so far away you may need a telescope to see it clearly, and the planet is a very poor model of the Earth. The space is much smaller than it appears; a reduction in scale for distant objects and planets is used to simulate enormous distance within a small space.
You may want to use your own models and textures instead of the standard ones. The sky dome isn't very good and leaves a large empty space around the central band of sky. So an additional dome was added to fill this space, which doesn't rotate quite right when you dive and climb, though it's not too noticeable, but it rotates completely out of view if you turn upside down. The left/right controls will also be reversed if you are flying upside down.
The Earth model is terrible: It is a sphere on a long stick and the centre of the object is the end of the stick, and as the scale increases the stick gets longer. But it had to be something large and heavy and this was the best thing I could find. You'll definitely need big sphere models if you want to create your own planets and suns.
Since solar systems are mainly flat planes the rocket ship moves relative to this plane. So if you are parallel with the plane of the solar system you will rotate left and right, but if you are perpendicular to the plane you will roll clockwise and anticlockwise. Either way the plane of the solar system will always rotate around you when you spin left/right.
The rocket ship was supposed to have a pilot's seat, but activating switches while you are sitting causes you to stand up, so you will have to crouch to get a good view out of the window. Alternatively you may prefer to have the ship be operated by sitting in a chair, and then looking left, right, up and down causes the ship to turn, while the engine and speed is controlled by hotkeys or whatever. But ideally if using switches you should create new ones, to avoid conflict with other modifications which may also use the same switches for other things.
The interior of the rocket ship can only be accessed while flying through space, but if you wanted it to be accessible while on the ground as well then you could have a ladder or door appear next to you when you are near the ship, which when activated moves you inside, and then activating the door moves you back to the ladder. There should be shutters over the windows which are enabled when you enter and are disabled when you leave, to prevent you from seeing outside, and any space enemies should be disabled, as well as the ship controls. Obviously activating the door while you are flying through space should do nothing, unless you wanted to be able to open the door and go outside, but then you would need a matching exterior model of the rocket ship with an open doorway.
If you wanted space combat you could add a turret to the front to shoot at nearby enemies, or alternatively just shoot directly out of the window. The plan with enemy ships would be to have them only rotate left and right, and move up and down while moving forwards at a constant speed. Thus they are simpler to control and provide a flat (virtual) platform for NPCs inside the ships to stand on and shoot at you, while from the outside it will look like the ship is shooting. Enemies should only be able to shoot when their ship is approximately facing you, so should be restrained from shooting at other times. They would alternate randomly between three behaviours...
Attack: If not too close and facing angle is not 0, turn one degree. If height is not equal to player, move one unit.
Evade: If facing angle is not 90 (or randomly -90), turn one degree. Randomly move up or down one unit, or stay level.
Flee: If not too far away and facing angle is not 180, turn one degree. Randomly move up or down one unit, or stay level.
One idea for planet generation was to divide the planet into a 360x360 grid of locations, which are determined by the angle the planet was at when you entered the atmosphere, and the Z coordinate height you were at divided down to a value of 0-359. These two numbers could then be used to procedurally enable and disable objects like rocks, change their angles, height or size, etc. so that every location looks different, while you are in fact using the same location repeatedly. If you fly or walk to the edge of this zone then you are moved to the opposite edge and the objects are all reset with the values of the next zone.
Presumably if the area you are moving to has already been loaded then you could travel around an entire planet without any loading screens, and travelling through space between planets also requires no loading of new areas. Even travelling to a new solar system would just require resetting a few variables with new values.
A random number could be generated the first time you play, which is added to all the values you are using for procedural generation, so that every time you play you may be getting a whole new universe of stuff. There are no limits to how far you could go, creating multiple solar systems...Of course you can add fixed things in certain locations, which could also be enabled and disabled by your original random number, so you never know what you're going to get, and since they move you can have creatures and people appear randomly anywhere.