#include<default.c>
#include<acknex.h>
var cam_distance = -300;
ENTITY* tank_box;
VECTOR NULLVECTOR;
VECTOR vAhead;
vAhead.y = 0;
vAhead.x = 0;
VECTOR torque;
torque.x = 0;
torque.y = 0;
action tank_controls()
{
player = me;
c_setminmax(me);
phent_settype(my,PH_RIGID,PH_BOX);
phent_setmass(my,100,PH_BOX);
phent_setfriction(my,77);
phent_setelasticity(my,1,25);
phent_setdamping(my,7,100);
phent_setgroup(me,2);
while(1)
{
camera.x = player.x + cam_distance * cos (camera.pan) * cos (camera.tilt);
camera.y = player.y + cam_distance * sin (camera.pan) * cos (camera.tilt);
camera.z = player.z + 50 * cos (camera.tilt);
camera.tilt = player.tilt;
camera.pan = player.pan;
while(key_cuu || key_cud)
{
vec_set(vAhead,vector((key_cuu-key_cud)*50000,0,0)); //feed keyboard into engine.
vec_rotate(vAhead, player.pan); //rotates by pan,tilt,roll ALL at the same time...
phent_addforcelocal(player,vAhead,NULLVECTOR,my.x); // Now apply physics force in the directions it is facing....
camera.x = player.x + cam_distance * cos (camera.pan) * cos (camera.tilt);
camera.y = player.y + cam_distance * sin (camera.pan) * cos (camera.tilt);
camera.z = player.z + 10 * cos (camera.tilt);
camera.tilt = player.tilt;
camera.pan = player.pan;
if(!key_cul || !key_cur)
{
torque.z = (key_cul - key_cur) * 50;
phent_addtorquelocal(player,torque);
}
wait(1);
}
if(!key_cul || !key_cur)
{
torque.z = (key_cul - key_cur) * 50;
phent_addtorquelocal(player,torque);
}
wait(1);
}
}
function main()
{
video_mode = 8;
shadow_stencil= ON;
video_screen = 1;
mouse_mode = 0;
wait(1);
fps_min = 30;
fps_max = 120;
//load level "Das Sandbox"...
level_load("whywontwork.wmb");
wait(2);
// Gravity
//ph_setgravity(vector(0,0,-500));
wait(2);
// Create sky
ent_createlayer("skycube+6.tga", SKY | CUBE | VISIBLE, 0); // Create a black backdrop for the level.
wait(2);
// create player/tank entity
//tank_box = ent_create("tankbox.mdl", vector(-225,-848,700), tank_controls);
wait(3);
wait(1);
}