Here is the complete code. Maybe it helps

#include <acknex.h>
#include <default.c>


ENTITY* player1;
var counter_timer = 300;

function camera_follow(ENTITY* ent){
while(1){
vec_set(camera.x, vector(-130 ,0 , 110));
vec_rotate(camera.x,ent.pan);
vec_add(camera.x,ent.x);
wait(1);
}
}


void count_down(){
my.ambient = 100;
my.lightrange = 150;
// while we still have to count down:
while(counter_timer > 0){


// count down each second:
counter_timer -= time_step / 16;

wait(1);
}
my.ambient = 0;
my.lightrange = 0;

}

function battery(){
counter_timer = 300;
}




action drive(){
player1 = me;

while(1){ // ALLES SOLL FORTLAUFEND PASSIEREN
camera_follow(me);
if(key_f) count_down();
// Neige die Kamera nach unten
if(key_b) battery();

if(key_w){ //Wenn die W-Taste gedrückt wird, bewegt sich das Auto eine Einheit nach vorne
c_move(me, vector(6*time_step, 0, 0), nullvector, GLIDE);
}
if(key_a){ //Wenn die A-Taste gedrückt wird, neigt sich das Auto nach links
camera.pan += 0.5;
}
if(key_d){ //Wenn die D-Taste gedrückt wird, neigt sich das Auto nach rechts
camera.pan -= 0.5;
}
if(key_s){ //Wenn die S-Taste gedrückt wird, bewegt sich das Auto rückwärts
my.x -= 20 * time_step;
}
wait(1);
}
}


function main(){
// video_screen = 1;
level_load ("testlevel.wmb"); // Lade das Level "Testlevel"
camera.tilt = -34;
}

Without commentaries

Last edited by Saschaw04; 04/04/15 16:41.

-- started with programming on march 2015 --
-- living in Germany near Dortmund --