///////////////////////////////
#include <acknex.h>
#include <default.c>
var camera_height;
var cheburek = 0;
var mouse[3];
BMAP cursor_pcx = "cursor.pcx";
///////////////////////////////
function main()
{
level_load ("mouse.wmb");
wait (2);
mouse_mode = 1;
mouse_map = cursor_pcx;
vec_set(camera.x,vector(0,0,1000)); // set a static position for the camera
vec_set(camera.pan,vector(0,-90,0)); // set the correct orientation for the camera
while(1)
{
mouse_pos.x = mouse_cursor.x;//*sin(90-my.tilt);
mouse_pos.y = mouse_cursor.y;
wait(1);
}
}
action my_car()
{
//rel_for_screen(mouse_pos.x, camera);
while (1)
{
IF (mouse_left) //EVENT_TYPE == EVENT_CLICK)
{
cheburek = 0;
WHILE (cheburek == 0) // wait for the target to be set (lmb click)
{
IF (MOUSE_LEFT == 1)
{
cheburek = 1; // target has been set
camera_height = vec_dist(camera.x, my.x);
temp.X = MOUSE_POS.x;
temp.Y = MOUSE_POS.Y;
temp.Z = camera.z - my.z;
vec_for_screen (temp, camera); // temp holds pointer's coords now
vec_sub (temp, vector(my.x, my.y, my.z));
vec_to_angle (mouse, temp); // rotate unit towards mouse
vec_set(my.pan, vector(mouse.x, mouse.y - mouse.y, mouse.z - mouse.z));
MY.SKILL15 = 500 ; // maximum path length = fuel :)
WHILE (abs(MY.X - mouse_pos.x) + abs(MY.Y - mouse.y) > 5 && MY.SKILL15>0) // stops near the mouse pointer
{
c_move(my, vector(15*time_step, 0, 0), vector(0,0,0), GLIDE);
MY.SKILL15 -= 500*time_step; // burn fuel
WAIT (1);
}
}
WAIT (1);
}
}
// move the car using relative_speed
if (key_a)
{my.pan += 3*time_step;} // increase the pan angle of the car
if (key_s)
{
my.pan -= 3*time_step;
} // decrease the pan angle of the car
if (key_space ) // press and hold the "Space" key to move the car
{
c_move (my, vector(15*time_step, 0, 0), vector(0,0,0), GLIDE);
}
wait (1);
}
}