Car Templates 3

Top  Previous  Next

This month I have added a new set of template files that include:

 

1) A semaphore.

 

aum87_templates1

 

2) A speedometer.

 

aum87_templates2

 

3) A high precision racing timer.

 

aum87_templates3

 

The semaphore was taken from last month's example that came with main.c; this month it was rewritten, it has got more features and (that's the good news) it was removed from main.c, which looks very simple again:

 

#include <acknex.h>

#include "t_car.h" // template car code

#include "t_car_cameras.h" // car camera code

#include "t_car_ai.h" // enemy cars AI code

#include "t_car_props.h" // template car speedometer, racing timer, semaphore - new stuff!

 

var t7car_race_started = 0; // is set to 1 inside t_car.c but it is reset here, so the race doesn't start immediately

 

ENTITY* sky =

{

       type = "skycube+6.tga";

       flags2 = SKY | CUBE | SHOW;

}

 

PANEL* splash_pan =

{

       bmap = "splash.pcx";

       layer = 15;

       pos_x = 0;

       pos_y = 0;

}  

 

function main()

{

       video_screen = 1; // start the game in full screen mode

       video_mode = 8; // run at a 1024x768 pixels resolution

       camera.arc = 100; // set a proper camera arc value

       set (splash_pan, SHOW);

       level_load("car_test.wmb");

       // show the splash screen for 6 seconds

       wait (-6);

       reset (splash_pan, SHOW); // now hide the splash screen

       media_loop("trance.mp3", NULL, 80); // start the soundtrack

}

 

The new template code can be used by simply including t_car_props.h in your projects; let's take a look at its customizable parameters.

 

aum87_templates4

 

The speedometer display in the lower right corner of the screen can be activated (or not) by setting "Speedometer" to 1 (or not). The "Speedometer factor" variable sets the maximum speed that can be displayed by the speedometer while the car is being driven; it's an experimental value, so feel free to play with it.

 

The semaphore can be activated or deactivated just like the speedometer; in addition to that, you can use the desired bitmaps for the red, yellow and green images and you can change the "getready.wav" sound effect.

 

The racing timer uses a high precision timer to count the number of minutes, seconds and milliseconds that are needed in order to finish the race. The racing timer can be enabled or disabled as well. You can also set the offset for the texts that show the racing time (at the end of the race); this feature, coupled with the ability to use your own font, should allow you to change the look of the end-of-race result screen to your liking.

 

More than that, we can change the "race is over" sound effect and we can set our own names for player's car and the enemy cars, like "BMW", "Toyota" and so on. You can't see all the fields for the name of the cars in the picture above but trust me - they're all there.