////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
VECTOR dist;
VECTOR absdist;
VECTOR cam_set;
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
var my_height;
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
#define health skill1
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
function main()
{
video_set(800,600,32,0);
fps_max = 60;
level_load("1.WMB");
wait(1);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
function handle_size(ENTITY* ent,var scale)
{
ent.scale_x = scale;
ent.scale_y = scale;
ent.scale_z = scale;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
function handle_camera()
{
camera.tilt += 10 * mouse_force.y * time_step; // turn it TILT, play with 10 for speed
camera.tilt = clamp(camera.tilt,-80,80); // limit cameras TILT
vec_set(camera.x,vector(-100,-25,70)); // place camera near right shoulder
vec_rotate(camera.x,my.pan); // turn camera with player
vec_add(camera.x,my.x); // add camera to player
if(!key_alt) // if ALT isn't pressed
{
camera.pan %= 360;
camera.pan += (my.pan - camera.pan) * 1 * time_step; // turn PAN after player (play with 1)
my.pan -= 10 * mouse_force.x * time_step; // turn players PAN
}
else
{
camera.pan %= 360;
camera.pan -= 10 * key_force.x * time_step; // turn cameras PAN with cursors
}
}
function handle_gravity()
{
my_height = c_trace(my.x,vector(my.x,my.y,my.z - 1000),IGNORE_PASSABLE|IGNORE_MODELS|USE_BOX);
if(my_height > 10)
{
absdist.z -= 1 * time_step;
}
else
{
absdist.z = 0;
}
}
function handle_animation()
{
if(key_w || key_s || key_a || key_d)
{
if(key_shift)
{
ent_animate(my,"run",my.skill48,ANM_CYCLE);
my.skill48 += 10 * time_step;
}
else
{
ent_animate(my,"walk",my.skill48,ANM_CYCLE);
my.skill48 += 6 * time_step;
}
}
else
{
ent_animate(my,"stand",my.skill48,ANM_CYCLE);
my.skill48 += 2 * time_step;
}
}
function handle_movement()
{
if(key_shift)
{
dist.x = 20 * (key_w - key_s) * time_step;
dist.y = 20 * (key_a - key_d) * time_step;
}
else
{
dist.x = 10 * (key_w - key_s) * time_step;
dist.y = 10 * (key_a - key_d) * time_step;
}
}
action hero_()
{
player = my;
handle_size(my,1);
my.eflags |= FAT | NARROW;
vec_set(my.min_x,vector(-25,-25,-60));
vec_set(my.max_x,vector(25,25,60));
my.health = 100;
while(my.health > 0)
{
handle_movement();
handle_gravity();
handle_animation();
c_move(my,dist,absdist,IGNORE_PASSABLE|GLIDE);
handle_camera();
wait(1);
}
error("YOU ARE DEAD!"); // DEATH HERE
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
PANEL* gui_ =
{
layer = 4;
digits(10,0,4,"Arial#24bi",1,player.skill1);
flags = SHOW;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////