Space Prisoner 1.4

Space Prisoner 1.4
Work on Space Prisoner has ceased.
However, I will continue to update the high score list as scores come in.

Wednesday, May 28, 2008

Upgraded text display - I use a bitmap font now instead of OpenGL's stroke font
Revised data display - horizontal energy bar, layout updated
Crosshairs when viewing from player ship, improves aim noticeably
"Laser" style shots now instead of sphere shots
High score is now saved to disk in user's preferences folder
Many small improvements to data structures

Thursday, May 15, 2008

Added rudimentary artificial intelligence to the enemy ships; they are now "aware" of the player ship, and will actively attempt to shoot the player down.

A minor problem that I had to solve was: how to take the delta vector between the enemy ship and the player ship, and translate that into a target body attitude for the enemy ship. This was solved by a quick trip to Mathematica, and their excellent page on spherical coordinates. The conversion is as follows:

theta (swivel) angle = arctan(dy/dx)
phi (tilt) angle = arccos(dz)

where dx, dy and dz are the attributes of a vector d describing the distance and direction from the enemy ship to the player ship. This vector must first be normalized.

Tuesday, May 13, 2008

As I knew would happen eventually, I've run into the well-known 3d spatial orientation problem of Gimbal Lock. When the player's ship is at extremely high (or low) angles of attack, that is, the z-angle is at or near +90 or -90 degrees, the normal left-right swiveling movement of the spaceship becomes indistinguishable from movement about the y axis (in this case, roll).

It's not a huge problem, because the player can either tilt further (through the deficient z-angles) or back the tilt off into a more usable range. Initially, though, it can be confusing.

If I really want to solve the problem (and I should, since in the heat of a game you don't want unexpected reaction to your keyboard commands), I may have to use Quaternions instead of Euler Angles to describe the player's orientation in 3D space.

Items added:
- Energy bar showing player energy
- Levels: a level ends when all of the enemy ships are destroyed. When the new level starts, new enemies (and asteroids) spawn.
- Lives: the player is no longer invincible, and has a limited number of lives (3 for now).
- Action screen display: informs player of important state changes (eg: "Level 1", "Level Complete", "Ship Destroyed", "Game Over"

The project is now an actual game, with a start and finish.

The graphics are all still extremely basic for now; essentially they are placeholders until I finish working on gameplay basics and start concentrating on the "look" of the game. This won't be for a while yet as there are still many basic elements in need of attention, such as enemy AI, screen information, level loading parameters etc.

Thursday, May 08, 2008

Added flexibility to the arena structure; it can now be any rectangle (not just a cube).

Reorganized the code files. The current list is now as follows:
asteroid.h, asteroid.c
glm.h, glm.c
globals.h, globals.c
holodeck.h, holodeck.c
objectInits.h, objectInits.c
simpleShip.h, simpleShip.c
sounds.h, sounds.c
splash.h, splash.c

Changed the keyboard input routines: an array of bytes now represents the on/off state of each key. A key down event turns the key's byte on, and a key up turns it off. This allows much smoother, faster and more fluid player inputs without relying on the key repeat feature of the hardware.

Added a very skeletal "Splash Screen" state in which the program is running, but there is no game playing. This screen will allow conveyance of such information high scores, settings, and info on how to play.

Added a basic scoring scheme; found and fixed some bugs and issues dealing with such questions as: if a ship gets blown up by a shot, how do we track which object actually *fired* the shot? That is, who gets credit for the kill?
Finally got the movement and shot-firing directional vectors working properly.
The ship's orientation is represented by two angles, which I call "tilt" and "swivel". Extracting a cartesian vector from these 3D spherical coordinates (i.e. a radius and two angles) is as follows:
x = cos(swivel) * sin(tilt)
y = sin(swivel) * sin(tilt)
z = cos(tilt)
Then, the radius r is simply the magnitude of the vector; that is, how fast the object is going.

Tuesday, May 06, 2008

Many more additions to the basic structure this weekend:

- Sounds are now implemented using OpenAL and .wav files. I've got various shot and explosion sound effects as well as a background theme that a friend wrote some years ago.

- The computer ships now have the ability to fire shots. They are still "dumb", mostly just thrusting around randomly, but I want to make sure all of the ship functionality works perfectly before concentrating too hard on AI.

- Added an external spectator view option, and found (after looking at the player ship from an external viewpoint) some bugs with my orientation routines. I've managed to largely fix the bugs after some hours of frustration.

Saturday, May 03, 2008

- A major internal change (and surprisingly difficult to make happen), is that the user's ship, instead of being a unique, specialized (and therefore wasteful) data construct, is now identical to all of the computer controlled ships. Instead of computer-generated inputs to direction and thrust, however, the player directly manipulates the controls. But the ship itself is identical to the others. This ensures that the player's ship and the computer ships are subject to the exact same physics laws, and it also automatically makes the player ship vulnerable to pulverization by shots, asteroids and other ships, without a lot of extra code.
- An added nice side effect to the above change is that it's now trivial to change the camera view to show the viewpoint of any object in the game.

- There are now 3 different kinds of asteroids: small, medium and large size. The large and medium ones take damage when hit, and eventually crack apart into smaller asteroids.

- The asteroids "tumble" through space now instead of drifting without any rotation.

- Added more performance diagnostic text to the text bar. A "maxObj" display shows the maximum number of active objects seen during the game. This will help me to determine an optimal size for the object array.