Archive for April, 2009

h1

FIRST SCREEN SHOT OF NEW GAME

April 23, 2009

OK, everyone, here it is, a very very early screenshot of me playing my new game.  Everything is subject to change, of course, but the fundamentals are there.  The flying around my retro-styled planet, all the aliens moving as they should, the scanner working, the targeting working, you can fly, shoot and destroy everything, in a shower of particle engine loveliness 🙂

photo111

I will talk more about the gameplay in a later post.  Not going to publish a video yet, as that will come when things are nearer completion.  There will be a single player mode to start with, but I am already conceiving of a multiplayer mayhem dogfight over wifi.  You won’t believe how fast everthing zips along.  Love it !

h1

Moving around a sphere

April 23, 2009

I said I would come back to the maths so here is a quick overview…

Moving an object around a sphere sounded very simple. However when I came to do it I wanted to be able to turn objects, left or right, relative to their current heading. It then became a bit more complicated. I started off using angles, theta and phi, to represent position but this has problems with Gimbal lock when converting to Cartesian Coordinates. Trying to move was also difficult, determining which angle to change is dependent on current position. i.e. When travelling North (decreasing phi) and you cross the North Poll you are now heading South (increasing phi) and theta has increased by 180 degrees. The result of which was to go to Quaternion maths.

There is a lot of stuff out there about the use of Quaternions in 3D games, and whether they are necessary, so I won’t try and repeat any of it here. I found that I could use this method of storing position and heading very efficiently. So now, all objects have their position held as a quaternion, with their current heading held as two further quaternions. Simple multiplication of these quaternions moves the object along its current heading. Changing heading simply means recalculating the two heading quaternions. There is no Gimbal lock and all objects can move relative to their position and not the underlying coordinate system.

h1

Hitting the target

April 22, 2009

Aiming and shooting was one thing, but checking if the target was actually hit added a new set of problems.  What ever method I decided on it had to be quick.  There’s a lot of information on the web about collision detection using ray plane intersection, but the maths is quite throughput intensive especially if there are a lot of surfaces to check against.

The first method, and still used in some places, was to generate a bounding box around the target and then to see if the shot was within the box.  Remembering that the XYZ of an object is no longer the same as the XYZ of the drawing system.

Having generated the Up, Left and Forward vectors, or Normals, of our object I can now calculate the bounding box.

blog1

To determine if the shot is within the box is a simple dot product of the shot position against the Normals of the each box face.  If the result is positive it is Outside the face, if it is negative then it is Inside the face.  If all faces report Inside then I have hit the target.

After developing all the code to do this I then realised there was an optimisation that further reduced the calculations.

blog2

blog31

The Normals for the box faces were already calculated, these are the Up, Left and Forward vectors used to generate the bounding box.  This was then further simplified by only needing to calculate and check the dot products against two points of the bounding box on opposite sides.  Now one set of dot products has to report Inside the faces and the other set Outside, this saves flipping the Normals.

h1

Aim and Shoot

April 14, 2009

Well, I’m not far away from posting what my new game looks like.  It is very difficult being an iPhone developer, in that if you look on the Appstore, there are loads of examples of copycat apps.  Tower defense games, Match 3 games etc.  This is because you cannot copyright a game, only specific elements in a game such as graphics, names etc.   To that end, I don’t want to give away too much about what my game looks like, or how it plays.  I think its unique.  Also, I dont want to give away its name, as they are also a valuable commodity – I already lost the iZoo name that I had for ages to a zoo sounds app 😦

Anyway, the point of this post is about aiming and shooting.

A lot of 3d games have crosshairs that you place over a target and shoot.  Well those games are not using a 3d missile path for shooting stuff, as evidently if you place cross hairs over something far away and shoot at it, then if something is closer to you on the same diagonal path as the missile is about to follow, then it would also get shot, but the cross hairs can only be over the one target !   My game is true 3d shooting, so I wanted to come up with something different.

I decided that having a HUD style interface that highlighted each enemy on the screen and then indicated to you whether you were either vertically or horizontally displaced from hitting it with a missile would be quite cool.  Having played it, it is still fairly difficult to hit stuff in 3D, but it does seem to work.  Afer all, this is a game, not a simulation.  After playing for a  while, you kind of get your “eye in”, and start shooting stuff naturally.  I am fairly happy that this is the way to go rather than cross hairs.

h1

Startup Video

April 14, 2009

I wanted to add a bit more professionalisim to my apps, so I made a new startup video for my latest game 🙂