action player_code() // attach this action to your player
{
var movement_speed = 10; // movement speed
var anim_percentage;
VECTOR temp;
player = my; // I'm the player
while (1)
{
vec_set (temp.x, my.x); // trace 10,000 quants below the player
temp.z -= 3000;
temp.z = -c_trace (my.x, temp.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX) + 4; // play with 20
temp.x = movement_speed * (key_w - key_s) * time_step;
temp.y = 0;
c_move (my, temp.x, nullvector, IGNORE_PASSABLE | GLIDE);
if (!key_w && !key_s) // the player isn't moving?
{
ent_animate(my, "idle", anim_percentage, ANM_CYCLE); // play the "stand" animation
anim_percentage += 2 * time_step; // 5 = animation speed
}
else // the player is moving?
{
ent_animate(my, "walkr", anim_percentage, ANM_CYCLE); // play the "walk" animation
anim_percentage += 4 * time_step * (key_w - key_s);
}
{
if (key_c ==1 )
{
ent_animate(my, "attack", anim_percentage, ANM_CYCLE); // play the "walk" animation
anim_percentage += 3 * time_step; // 8 = animation speed
}
if (key_v ==1 )
{
ent_animate(my, "attackk", anim_percentage, ANM_CYCLE); // play the "walk" animation
anim_percentage += 3 * time_step; // 8 = animation speed
}
if (key_b ==1 )
{
ent_animate(my, "atackkk", anim_percentage, ANM_CYCLE); // play the "walk" animation
anim_percentage += 3 * time_step; // 8 = animation speed
}
if (key_f ==1 )
{
ent_animate(my, "attackkkk", anim_percentage, ANM_CYCLE); // play the "walk" animation
anim_percentage += 3 * time_step; // 8 = animation speed
}
if (key_g ==1 )
{
ent_animate(my, "attackkkkk", anim_percentage, ANM_CYCLE); // play the "walk" animation
anim_percentage += 1 * time_step; // 8 = animation speed
}
if (key_g ==1 )
{
ent_animate(my, "attackkkkkk", anim_percentage, ANM_CYCLE); // play the "walk" animation
anim_percentage += 1 * time_step; // 8 = animation speed
}
if (key_u ==1)
{
ent_animate(my, "jump", anim_percentage, ANM_CYCLE); // play the "walk" animation
anim_percentage += 1 * time_step; // 8 = animation speed
}
wait(1);
}
}
}