Feeds:
Posts
Comments

Cavemen VS Aliens

I know that this blog has been due for a long post; but as you would imagine I have been very busy with many other things, including my new job which I started in June at a newly found independent game development team.

We Are Colin specialises in XBLA titles and IPhone titles. Currently I have been working on a new Real Time Strategy game; I have not always been a fan of RTS’ until recently, and creating this game has really helped me to love the genre even more. The RTS I have been programming on is Cavemen VS Aliens. Yes, the name of the game and the two opposing teams may seem like an odd combination, but when you view our media gallery we have distributed for your viewing pleasure I hope you will see its potential.

In a nutshell, this game is aimed at everyone; which means anyone should be able to master the game’s ‘pick up and play’ gameplay and dive into the game’s action straight away. Don’t worry; this doesn’t mean the game is entirely easier than your standard game. It just means that its easier to pick up and play but has a good learning curve to follow through the game’s duration. Instead of me trying to sell the game to to you, why not just view the following trailer and see what you think.

Thankyou for watching and reading and I will be adding more updates on the game’s progress up to its release on October 30th which isn’t far away at all.

W7: Walking over terrain

Walking on Terrain

Walking on Terrain

I finally fixed the issue I was having with getting the camera walking over the terrain. I ‘think’ the error was that I wasn’t translating onto the x-z plane at the beginning of my GetHeight(float x, float x) function properly. I said ‘think’ because I redid all of my functions that got the height of the terrain. Sometimes its best to start over again instead of continuously trying to re-edit something that doesn’t work. It’s a relief finally getting this fixed, as I have wasted a lot of time trying to get this to work.

In addition I managed to add a zombie into my engine by doing this untidily within one class. I am now trying to implement this the proper way to ensure that it is easier to add other assets to the engine. However I am currently having problems constructing my WorldObject class (that manages all objects within the world; i.e. their position, orientation) and my ResourceManager class (checks to see if a mesh or texture has already been loaded, to stop it from being loaded again when these resources are used on multiple objects for example).

As you can see I have added a texture to my terrain. All that was required at the time for this to work was one simple line.

D3DXCreateTextureFromFile(gd3dDevice, “grass.jpg”, &mTexture);

Within my time of frustration trying to get the camera to walk over the terrain I cleaned up a lot of the code and removed unnecessary parts of my engine. This should make it easier for me to implement future additions.

There are different number types, such as natural numbers (positive numbers), integer (positive and negative), rational (1/2, 1/3, 1/4), irrational (sqrt(2), e, PI), real numbers and complex numbers.

In my code I constantly use floats, without considering how it works. This week was spent making our own floating point calculator to add, multiply, subtract and divide floating point numbers using the IEEE 754 Standard.

There are different ways of representing numbers the same way. For example…

93 x 10^ 6 is the same as
0.00093 x 10^10 

This is a problem as one number can be expressed  in different ways. Normalised form is a way of dealing with this problem for example 9.3 x 10^7 is the normalised form of the above examples. This can be evaluated into the following:

(sign) mantissa x base ^ exponent

In IEEE 754 the normalised form expressed earlier is incorrect, since this standard uses base 2. So…

9.3 x 10^7  = 1.386 x 2^26

The IEEE 754 standard is expressed in the following form:

(-1)S x (1 + F) x 2^(E – bias)
S = Sign; F = Fraction; E = Exponent

 Single Precision (in this standard) is 32 bits and is expressed as:

0|10110101|11010101001010101011010
1 Sign | 8 Exponent | 23 Mantissa

Multiplication is the easiest arithmetic to do with floating point numbers. To do this you add the exponents and multiply the mantissas. Afterwards the result is rounded and normalised. Division is similar but is a lot more complicated.

Addition is quite tricky. If you have two different exponents you must first make them equal. Afterwards you then add the mantissas and multiply them by the same base^exponent. Subtraction is done identically, however you must subtract the mantissas instead of adding them.

W5: De Blob

Walking on Terrain

Walking on Terrain

I successfully created user input with the camera. However, I have been having some troubles making the camera walk across the terrain. For some stange reason, my camera appears to go up invisible hills when moving around. I’m guessing that the camera’s position hasn’t been set to the terrain’s position, so when the camera is supposed to go up a certain part of the terrain (that is visible) it would; instead of going up terrain a mile away from the hill.

I have added statistics in the top left of the screen which was quite an easy task to do.

I created a state manager for my application, which makes it a lot easier to handle my application. Currently there are only two states; the loading state and terrain state. I have also made start on implementing a resource manager, which will make it easier to handle resources loaded into the application. Currently I have no resources in my engine.

De Blob

De Blob

Our lecturer has given us details on our assignment task. For my assignment I must recreate ‘De Blob’. This will be a very tedious task. Hopefully I can recreate De Blob to a good standard in the time I have left for this semester.

W3: New Framework

Height-based Lighting

Height-based Lighting

This week I managed to implement a camera system; allow input with the mouse, keyboard and Xbox 360 controller and I managed to implement height-based lighting.

However, to begin with I had to put everything I had into a new framework. To be precise I placed my code within Frank Luna’s framework (from his Introduction to 3D Game Programming with DirectX 9.0 book). This framework was well structured since it made it easier to handle the device; for example when my program is running, if a user changes program, my program will still be running in the background. This becomes a lost device and once the user goes back to re-open the program the program must be reset.

To implement this I performed a SAFE_RELEASE() on all of the buffers I was declaring such as the vertices buffer and the index buffer. This stopped the program from crashing when the user tried to resize the window or changed the main application being used to another one.

The book helped me understand how to implement a camera for my terrain. However setting up a camera would be quite useless, without some form of input so this was tested using the mouse and keyboard first. I created my own class to handle input from the mouse and keyboard which was quite a tedious task. Then I assigned keys and mouse movements to the camera movement.

Afterwards I did the same for the xbox 360 Controller. It took me a while to get the control system I wanted within my engine and I think it still needs some tweaks to be perfect. The left control stick moves the camera left, right, forward and back; whilst the right thumbstick rotates the camera’s position. Deadzones had to be applied to the thumbsticks so that when the thumbstick was still, it wouldn’t apply any input into the engine.

I then attemped height based lighting. Which simply changes the intensity of the colour depending on the height of the vert on the terrain. Higher areas are lighter and lower areas are darker, which is not exactly an accurate way of lighting for terrain.

  1. This involved getting the heights (y value) of the verts. 
  2. Comparing the heights to the max and min values; so changing the max and min values if the vertices height was higher or smaller than the current max and min values
  3. Finding the difference between the max and min height value
  4. Storing a colour for each vert by taking away the height of the vert by the min value and dividing this result by the difference in step 3

W2: Terrain

For this week, I had to create terrain and implement different terrain types and lighting.

Firstly I rendered a large grid on screen and then created a list of vectors to store the y value of the terrains height map at different positions. I loaded a RAW file (which are typically used to store height maps) into the program and this was the result.

RAW file

RAW file

Afterwards I implemented Fault Formation. Fault Formation involves the following steps:

  1. Compute a random line to split the map into two sides
  2. Add a height value to the elements of one side and subtract this value to the elements on the other side
  3. Repeat this process with a set number of iterations

This is the end product…

Fault Formation

Fault Formation

Midpoint Displacement is another type of terrain generation. Here are the steps:

  1. Divide a grid into regions
  2. Change the height of each corner to a random amount
  3. Divide each region into smaller regions and change the height by a smaller random amount
  4. Repeat this process with a set number of iterations

Here is the end product:

Midpoint Displacement

Midpoint Displacement

I also added lighting to the terrain. This is hardware-based lighting and currently only has a white Directional Light.

Hardware-based lighting

Hardware-based lighting

This was achieved by converting the grid into a mesh. By doing this I was able to use the D3DXComputeNormals function, which computed the normals of the mesh for me.

W2: MIDlets

I produced an insurance form which could be filled in by a user on the mobile phone as part of this week’s exercise.

Entering the details

Entering the details

When the user entered their details and pressed Save it would show the details they entered.

Sent Details

Saved Details

This was created using TextFields (textboxes), StringItems (labels), ChoiceGroups (checkboxes and radiobuttons), Commands and two different forms. The general setup involved creating a new form and then appending any textboxes, labels, etc… that I wanted to appear on that specific form; i.e. form.append(textbox);.

There are three specific functions within the application:

  • startApp – what is done at the opening of the application whether starting the app or resuming after a pauseApp
  • pauseApp – what to do when the application is interrupted (e.g. phone call)
  • destroyApp – how to destroy the application safely

Those functions are used on MIDlet applications. This program is an application using  MIDlet, which is a Java Application Framework for MIDPs (Mobile Information Device Profile) typically used on mobile devices.

This week has really been a starter into getting grips with DirectX. It amuses me how easy small tasks are to do; the same “small” tasks I found very tedious last semester within the Introduction to 3D Graphics module. It has taken me a little time to adjust to the way DirectX works; but I’m hopefully getting to grips with it.

3 Triangles rotating in X, Y, Z

This simply shows 3 triangles rotating in individual axis; x, y and z. The only problem I came across here was simply translating the triangles before rotating them; so they were rotating around the origin, rather than rotating around themselves.

Wireframe cube

 We were told to set up a cube using vertices and not indices. It was a bit tedious as declaring the vertices of the cube in a wrong order would only make some triangles appear. To set the cube in wireframe mode I simply used this line of code.

g_pd3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME );

This just shows the simplicity of tasks such as these.

Lighting on a cube

This is the same cube, but with shading  and lighting enabled. White Directional Light is coming from the left of the cube and a red Point Light shines directly above the cube. 

These are the different settings and customisations that can be made to a light in DirectX.


Portfolio

A portfolio page has been added which will showcase all programming work I have done. Currently only videos are being shown; but the page will soon have download-able content, so you will be able to try out the games I have created. To view my website portfolio please visit JTA Designs.

W1: Java

Java feels very similar to C#, with the odd annoying differences such as String instead of string as an example.  I have been using NetBeans which is quite a nice Java Environment. It does come annoying, however when the environment specifies errors instantly when typing out code. Such as when declaring an int it will instantly say; “this int is not declared”.

This week I had to create a simple Drop Dead dice game, which I also created in C# last year as part of an exercise in Software Development. For those who don’t know, Drop Dead is a game where you roll a set number of dice (5 – 10). If you get a 2 or 5 on the dice thrown, those dice become dead so you cannot use them again. For all alive dice, the numbers rolled are added up to the player’s score.

I will have to create an application using Java that can be used on mobile phones. There isn’t a set application to make; I have to decide myself. More than likely I will create a puzzle game. Within the lecture, our lecturer stressed the importance of memory and how it must be managed importantly, since we’re now building applications for mobile phones (with significantly less memory than computers obviously).

The lecture also stated the importance of making the application playable on older CLDC (Connected Limited Device Configuration – Java framework) versions (and not just 1.1), since the application should allow a better majority of people to use the application; rather than restricting the amount of users. Obviously, this is important from a business perspective.

I have found out that my mobile phone has CLDC 1.1 and MIDP-2.0 so I should be able to test out some of my applications on the phone.

Older Posts »