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 🙂

h1

Gameplay and Mathematics

March 22, 2009

Well I have a very good idea of gamelay.  I want to merge the “defending your humans” in their houses, with the prevention of virus spreading through the landscape.  Evidently these 2 ideas come from Zarch and Defender.  I think Defender married the whole level based schmup thing with objectives and the differing types of attackers, really well.  What I want to do is have an infected landscape (say above a basic percentage) then explode, as per Defender, with all the aliens turning nasty and going after you, rather than your houses.  Evidently this would still occur if the aliens got your humans from their houses too.

I like to think the Lighthouse looks so cool on my small planet, that I will feature it specially somehow.  Don’t know how yet.

Oh, another cool thing, when a “lander” for want of a better name at the moment, takes a human from a house/windmill, and reaches an arbitrary orbit level, it will “mutate” as per defender, but also shoot a laser bolt down to the house below, desroying it, “independence day” stylee 🙂

Now the maths for this is all getting pretty hairy, but I will make a future blog about the use of Quaternions in all this.   Heavy going, trust me…..

To give you some kind of idea of how far behind, the blog of the game is, behind actual development, I was writing a particle object last night for the explosions 🙂  Everything is coming along very very nicely !  Have I mentioned how much I love Objective-C yet ?   very sweet.  Damn shame I will have to re-write all this game to be able to port it …

h1

Algorithms for GeoSphere generation and random planet surface

March 12, 2009

OK, so there are a number of ways of generating a geosphere, but I found this article very useful indeed.

http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/sphere_cylinder/

Basically start with a simple shape like an octohedron, and start subdividing the surfaces.  Before you know it, one GeoSphere – great !

Now there are millions of pages about random planet surface generation.  Generating something unique though took some digging.  This algorithm was perfect for my needs

http://freespace.virgin.net/hugo.elias/models/m_landsp.htm

sweet 🙂

h1

Planet surface features

March 12, 2009

OK, so I needed some items to go on the surface of my small planet.  It’s off to the 3d modelling package we go ….  Everything needs to be pretty low poly, as its anticipated that the game will whizz along at a pretty swift rate, and I don’t need things to be particularly detailed.

Here is what I came up with for the moment

windmilllighthouseturbinelanderhouse1

When shown on the iPhone, the windmill blades all spin around, and the light coming from the Lighthouse is nicely see through, and spins around, and the wind turbines are nicely painted red and white, and also zoom around 🙂  All looks very funky actually !

h1

Generating a small planet …

March 7, 2009

So the first step in this game is that the whole thing will take place around a small planet.  Now I don’t want textures.  There are going to be loads of polygons flying around as it is, and I don’t want to push the iPhone too much.  Plus going for Zarch styling means that I get a cool looking effect without texture mapping.

However, a small planet in graphical terms can be drawn in two ways, using a latitude and longitude approach, or what is called a geosphere.  Now a geosphere is much more interesting to me, as the lat long approach means you get tiny triangles at the poles, and large ones at the equator.  The geosphere is something that can be colored using triangles of equal size over its surface.  Perfect for zarch style graphics.  Heres a pic to show the difference.

spheres1