///////////////////////////////
#include <acknex.h>
#include <default.c>
#define v_mass 16
///////////////////////////////
var checkpoints_max = 8;
var checkpoints_x[8] = { 185, -1390, 1000, -2000, 500, -800, 700 ,1 };
var checkpoints_y[8] = { -1327, -1207, -1000, 2000, -500, 800, -700 ,-1 };
var checkpoint_number = 0;
var checkpoints_treshold = 150;
var checkpoint_distance;
var time;
var time2;
SOUND* snd_checkpoint = "mousesnd.wav";
SOUND* snd_car = "car_idle.wav";
var camera_max = 3;
var camera_number = 0;
var speed_max = 99;
BMAP* panelkmh_pcx = "panelkmh.pcx"; // meine erste bmap
PANEL* first_pan = //mein erstes panel
{
pos_x = 500;
pos_y = 420;
layer = 2;
bmap = panelkmh_pcx;
flags = OVERLAY | VISIBLE;
}
PANEL* first_pan =
{
digits (110, 10, 2, "Calibri#18bi", 1, checkpoint_number);
flags = VISIBLE;
}
PANEL* second_pan =
{
digits (135, 10, 2, "Calibri#18bi", 1, checkpoints_max);
flags = VISIBLE;
}
PANEL* third_pan =
{
digits (130, 10, "/", "Calibri#18bi", 1, 0);
flags = VISIBLE;
}
PANEL* fourth_pan =
{
digits (10, 10, "Checkpoints:", "Calibri#18bi", 1, 0);
flags = VISIBLE;
}
PANEL* time_pan =
{
digits (70, 30, "%.2f", "Calibri#24bi", 1, time);
flags = VISIBLE;
}
PANEL* time1_pan =
{
digits (10, 30, "Time:", "Calibri#24bi", 1, 0);
flags = VISIBLE;
}
PANEL* speed_pan =
{
digits (580, 450, 2, "Calibri#30bi", 1, car_v);
flags = VISIBLE;
layer = 10;
}
PANEL* speed_pan2 =
{
digits (500, 450, "km/h", "Calibri#30bi", 1, 0);
flags = OVERLAY | VISIBLE;
}
ENTITY* car_cam=
{
layer = 10;
x = 20;
y = -10;
z = -10;
}
var cameradistance = 300;
ENTITY* car;
var car_v = 0;
var car_a = 0;
action my_car()
{
car = my;
var c_down = 0;
while (1)
{ // move the car using relative_speed
car_a = 0;
if (key_cul){
if (car_v>=-1){
my.pan += 4*time_step; // increase the pan angle of the car
} else{
my.pan -= 4*time_step; // decrease the pan angle of the car
}
}
if (key_cur){
if (car_v>=-1){
my.pan -= 4*time_step; // increase the pan angle of the car
} else{
my.pan += 4*time_step; // decrease the pan angle of the car
}
}
if (key_cuu){// press and hold the "Space" key to move the car
car_a = 1.15;
}
if (key_cud){ // ruckwärts fahre
car_a = -1.75;
}
if (key_c && !c_down){
c_down=1;
camera_number++;
if (camera_number == camera_max){
camera_number = 0;
}
}
if (!key_c){
c_down = 0;
}
wait (1);
}
}
function main()
{
fps_max = 40;
level_load("NeedforSpeedGB.wmb");
car = ent_create ("car2.mdl", vector(300, -3400, 20), my_car); // erstelle den Ball
var snd_carhandle = ent_playloop (car, snd_car, 100);
screen_color.blue = 150;
video_mode = 7;
while (1)
{
if (camera_number == 0){
camera.z = 200; // and place it at z = 1000 quants
camera.tilt = -20; // make it look downwards
cameradistance = 300;
}
if (camera_number == 1){
camera.z = 80; //d place it at z = 1000 quants
camera.tilt = -10; // make it look downwards
cameradistance = 25;
}
if (camera_number ==2){
camera.z = 350; //d place it at z = 1000 quants
camera.tilt = -30; // make it look downwards
cameradistance = 300;
}
car_cam.pan -= (car_cam.pan-car.pan)/2.5*time_step;
car_cam.x -= (car_cam.x - car.x)/2.5*time_step;
car_cam.y -= (car_cam.y - car.y)/2.5*time_step;
camera.x = car_cam.x - cos(car_cam.pan)*cameradistance; // keep the camera 300 quants behind the ball
camera.y = car_cam.y - sin(car_cam.pan)*cameradistance; // using the same y with the ball
camera.pan = car_cam.pan;
if (car_a==0){
car_v*=50-(0.03*time_step);
}
wait(3);
car_v += car_a * time_step *3;
if (car_v>speed_max){
car_v=speed_max;
}
if (car_v<-15){
car_v=-15;
}
snd_tune(snd_carhandle, 40+abs(car_v)/speed_max*60, 100+abs(car_v)/speed_max*60, 0);
if (checkpoint_number>0){
time += timer()/1000000;
}
var car_distance = c_move(car, vector(car_v * time_step, 0, 0), nullvector, GLIDE);
var direction = 1;
if (abs(car_v)>0) { direction = car_v / abs(car_v); }
car_v = direction * car_distance / time_step;
checkpoint_distance = sqrt(pow(car.x - checkpoints_x[checkpoint_number], 2)+ pow(car.y - checkpoints_y[checkpoint_number], 2));
if (checkpoint_distance < checkpoints_treshold){
snd_play(snd_checkpoint,100,0);
if (checkpoint_number==0){
time = 0;
timer();
}
checkpoint_number++;
if (checkpoint_number == checkpoints_max){
checkpoint_number=0;
}
wait (1);
}
}
}