action player1_act()
{
player1=me;
my.material=steel_mat;
set(my,POLYGON|CAST);
my.emask|=ENABLE_SHOOT|ENABLE_BLOCK|ENABLE_IMPACT|ENABLE_ENTITY|ENABLE_SCAN;
....
while(1)
{
if(my.health>0)
{
pXent_kinematic(my, 0); // kinematic object (Disable kinematic)
....
//movement
player1.pan+=5*(key_cul-key_cur)*time_step;
VECTOR* mov = vector(0,0,0);
if(key_cuu) mov.x= 7*time_step;
if(key_cud) mov.x=-7*time_step;
if(key_cuu==1&&key_cud==1){mov.x=0;}
if(key_home) mov.y= 7*time_step;
if(key_pgup) mov.y=-7*time_step;
if(key_home==1&&key_pgup==1){mov.y=0;}
ground_distanz=-100;
c_trace(my.x,ground_distanz,IGNORE_YOU|IGNORE_MODELS|IGNORE_PASSABLE|IGNORE_PUSH|USE_POLYGON);
if(ground_distanz>0)
{
push_force_z =1* time_step; //calculate an fall down
}
else
{
push_force_z=-15 * time_step; //calculate a ground force
}
mov.z=push_force_z*time_step;
vec_rotate(mov,player1.pan); pXent_moveglobal (me,mov,player1.pan);
.....
}
if(my.health<=0)
{
pXent_kinematic(my, 1); // kinematic object (enable kinematic)
wait(1);
pXent_settype(my,PH_RIGID,PH_CAPSULE);
pXent_setmass (my, 3); // and its mass
pXent_setfriction (my, 500); // set the friction
pXent_setdamping (my, 40, 40); // set the damping
pXent_setelasticity (my, 50); // set the elasticity
wait(1);
return;
/* ent_remove(me);
return; */
}
wait(1);
}
}