action hero()
{
var anim_percentage;
pXent_settype(my, PH_CHAR, PH_CAPSULE);
set(my,SHADOW);
wait(1);
my.emask |= ENABLE_SCAN; // make the player sensitive to scanning
player = my; // I'm the player
while(players_health > 0)
{
//player movement//
movement_speed.x = 10 * (key_cuu - key_cud) * time_step; // move the player using "cuu" and "cud"
movement_speed.y = 10 * (key_cul - key_cur) * time_step; // move the player using "cur" and "cul"
pXent_movechar(me, movement_speed, NULL, 0);
///////////////////
//player animation//
if(key_cuu || key_cud)
{
if(movement_speed.x > 0){my.pan = 0;} // turn player to right
if(movement_speed.x < 0){my.pan = 180;} // turn player to left
anim_percentage += 7 * time_step;
ent_animate(my, "walk", anim_percentage, ANM_CYCLE); // play the "walk" animation
}
if(key_cur || key_cul)
{
if(movement_speed.y > 0){my.pan = 90;} // turn player to right
if(movement_speed.y < 0){my.pan = -90;} // turn player to left
anim_percentage += 7 * time_step;
ent_animate(my, "walk", anim_percentage, ANM_CYCLE); // play the "walk" animation
}
if (key_cuu + key_cud + key_cur + key_cul == 0) // none of the movement keys are pressed?
{
anim_percentage += 1.2 * time_step;
ent_animate(my, "idle", anim_percentage, ANM_CYCLE); // play the "stand" animation
}
/////////////////////
on_l = plant_bomb;
wait(1);
}
}