Tuesday 21 August 2007

Player and bots .. cont..


To give more exciting feeling to the game play, more bots are rendered. For this purpose, the track matrix data is taken from replay.cs which contains the position and rotation of the bot at the specific time. The following code (Source code 3‑2) shows how to extract the data.

Matrix bestReplayCarMatrix =

RacingGameManager.Landscape.BestReplay.GetCarMatrixAtTime(

RacingGameManager.Player.GameTimeMilliseconds / 1300.0f);

Source code 32: Matrix data used from best replay

Before rendering the car, the rotation of the car is created to make sure the car stay correctly on the road. (Refer Source code 3‑3):

bestReplayCarMatrix =

Matrix.CreateRotationX(MathHelper.Pi / 2.0f) *

Matrix.CreateRotationZ(MathHelper.Pi) *

bestReplayCarMatrix;

Source code 33: Rotate the car to stay correctly on the road.

Finally, the car is rendered with a specific texture, colour and matrix to the world. (Refer Source code 3‑4). Please noted that false in the code indicate the car is not a ghost car, therefore, it can be rendered with a texture and colours.

RacingGameManager.CarModel.RenderCar(

1, RacingGameManager.CarColors[5],

false, bestReplayCarMatrix);

Source code 34: Rendering the bot

To have more bots, the process is repeated but with unique matrix. This can be done by dividing each matrix with different variable, so that the bots is rendered at a point at different time.

each bot is given unique matrix:

Matrix bestReplayCarMatrix =

RacingGameManager.Landscape.BestReplay.GetCarMatrixAtTime(

RacingGameManager.Player.GameTimeMilliseconds / 1300.0f);

Matrix bestReplayCarMatrix2 =

RacingGameManager.Landscape.BestReplay.GetCarMatrixAtTime(

RacingGameManager.Player.GameTimeMilliseconds / 1200.0f);

Matrix bestReplayCarMatrix3 =

RacingGameManager.Landscape.BestReplay.GetCarMatrixAtTime(

RacingGameManager.Player.GameTimeMilliseconds / 1500.0f);

Sunday 19 August 2007

Player and bots


The initial prototype has one player and one ghost car. Since the ghost car is hard to see and not suitable in implementing the concept of this game, it has been replaced with other visible car model. The model taken from the player’s car model itself, but this time, the bots are rendered with unique skins to represent itself and different from player and other bots.

Thursday 16 August 2007

More Shader's Effect


Shader is useful to change the game to have darker or brighter screens. It also helps the developer to control the colour mixtures and intensity. It means that the game can be developed to a variety of weather and environment such as cyber world or cloudy weather.

This shader effect is very useful and available to be applied in the future game development. The shader file is a file with an extension .fx so that not only programmers can edit it; artist or designers also can be assigned to change and edit the code. In fact, Nvidia Corp. provides a tool named FX Composer to easily create or edit shader files. They even provides with some shaders template that can freely used or manipulated and it support many formats such as DirectX and OpenGL, HLSL, COLLADA FX, and CgFX, as well as .fbx, .x, .3ds, .obj, and .dae

Wednesday 15 August 2007

Game Play Screens & Shaders


Some tuning in game play screen also has been made. These include the changes on dashboard, the figures indicator and shaders as well. PostScreenGlow shader is eliminated to get a better view but less realism. This shader is used previously to give some glow and motion blur effect to the environment to give a furious mood to the player, so that the player feels that he is driving fast. However, this shader is not well implemented because the shader’s effect not suppose to start as soon the game is rendered but it should start when the car is moving. Moreover, many users who participate in this game testing including myself don’t like the effect because it is like showing an old fashion graphic is being used in the game.

Monday 13 August 2007

Game Physics & Collision Detection


There are many racing game physics that can be implemented such as gravity, friction, engine physics, car dynamics and springs physics. These physics are important to achieve realism in game play. For this project, the basic law of motion and collision detection will be implemented as shown in Figure 39. These include:

  1. Car moves towards as the accelerate key is pushed or moves backwards if the reverse key is pushed.
  2. Some elements may pull the car back or slow it down such as friction or braking.
  3. Gravity pulls the car down and keeps the car on the road.

Objects that are moving through the world need to be checked against the geometry and all other objects in the world to see that it does not pass through or get too close to any of them. For instance, I would check if any of the four wheels collide with the guard rail by checking the four wheel positions (or at least the most outer parts of the car) still allow you to do the basic collision detection. If the car is crashing into the right guard rail, it means collision happens at the front right side of the car and vice-versa. Collision response is to rotate the car to opposite direction and slow it down due to the crash. Collision between cars also must be calculated to reduce the car’s defence status bar so that the game will over when the car’s defence equal or less than zero. The following Source code shows the pseudo code for checking the collision with the guard rails.

Check all 4 corner points of the car.

For all 4 corners {

Determine the distance between the corner to the rail.

If it less than or equal 0 then

{

Collision happens.

Bring out the collision event

{

I. 2nd law of motion, force the car back on the road and reduce speed.

II. Determine the collision impulse and show collision effects.

III. Play collision sound

IV. Shake camera.

}

}

}

Saturday 11 August 2007

Content Creation for Racing Game

When talk about racing game, the idea of the racing game is simple which is stay on course and be the fastest to the finish line to be a winner. However, that concept can be twisted to get more exciting racing game. According to Nitschke, racing game can be categorised into multiple types which are realistic racers, street racers and fun racers (Nitschke, 2007). Realistic racers focusing on realism aspects like Gran Tourismo and Colin McRae. Realism aspects is not important in street racers but it’s more like watching cool movies that broad to other aspects like able to tuning cars or listening to cool music while racing on the tracks like Need for Speed Underground. Fun racers like Trackmania and Carmageddon are more to fantasy racing with crazy tracks and able to jump high. Furthermore, the mission is more on achieving goal in limited of time.

In developing content for racing game, there are 3 approaches that can be applied to computational intelligence in the game. There are optimisation approach, innovation approach and imitation approach (Togelius, Nardi, & Lucas, 2007). In optimisation approach, the optimisation algorithm is used to change values of some particular aspects to get good and realistic game strategies. To implement a racing game, developers have to make an experiment to gather racing data especially the car physics and “make sense” tracks that can be built. The data gathered then can be applied to build the realistic game. Therefore, the fun racers category is exclusive in this approach.

To achieve realism in racing game, several physics concepts can be applied to the game such as gravitation, speed and inertia, friction and car’s engine torque. For instance, to enhance a game visual realism and realistic vehicle performance, multi-body vehicle suspension theory can be applied which is composed of springs, dampers and linkage through the wheels stay connected. “The suspension is what allows the wheels to have some range of freedom to move in the vertical direction without instantly lifting the corners of the vehicle. This enables the wheels to move in relative to the surface bumps and transfer less force to the vehicle body absorbing most of the shock” (Sharif & Brindle, 2007). This concept is matter much in game simulation because it has direct effect to the acceleration, handling and breaking performance of a vehicle due to the torque generated at its centre of gravity, the body tends to roll and pitch while accelerating or cornering at high speed (Sharif & Brindle, 2007). Unfortunately, very few of racing games implement this kind of physic concept.

Innovation approach is focusing on generating interests. The street racers and fun racers are examples that inclusive in this approach. In other words, this approach sees games as environments for the development of complex intelligence rather than computational intelligence techniques as means of achieving particular results as games.

The imitation approach is based on numerous of supervised learning. Symbolically, what is imitated is a human player, but a game agent can possibly imitate another agent. A good example of this approach to computational intelligence in racing games is the Microsoft Game Studio Xbox game Forza Motorsport. In this game, the player can train his avatar to play just like himself, and then virtual copy of him is used to get ranked on tracks, or test his skill against other players’ avatar (Togelius et al., 2007). In fact, this approach is used in my project to generate a “virtual bot” to the game. This implementation will be discussed in the next post.

Friday 10 August 2007

Project Methodology


Since the game is derived from the starter kit, the project methodology being used is the “prototyping” because analysis, design and implementation phases can be performed concurrently and these three phases are performed repeatedly in a cycle until the system is completed (Dennis, Wixom, & Roth, 2006). Realise or not, the starter kit is also known as a prototype. Therefore, with this methodology, the prototype can be used and tested repeatedly to get the ideas and feedback. These ideas and feedback are analysed, redesigned and re-implemented, so that a better prototype with better features can be developed. This process may continue repeatedly until a good game is produced (refer Figure 3‑3). In other words, this methodology is used to ensure that the game can be developed quickly with some modification and customisation to the prototype due to dissertation period of time.