vec_set(temp.x, my.x);
temp.z -= 5000 * time_step;
ground_distance = c_trace(my.x, temp.x, IGNORE_PASSABLE | IGNORE_SPRITES | SCAN_TEXTURE);
if (hit.texname == "ROCK_03.bmp"){
set (mypanel, VISIBLE);
} else {
reset (mypanel, VISIBLE);
}
// JUMPING
if (key_space && jump_key == 0) {
jump_height = minv(120, jump_height + 12 * time_step);
if (jump_height == 120){
jump_height = maxv(120, jump_height - 10 * time_step);
jump_key = 1;
}
} else {
jump_height = maxv(0, jump_height - 10 * time_step);
if (jump_height == 0 && !key_space){
jump_key = 0;
}
}
if (jump_animation < 99 && jump_height > 0){
jump_animation += 4 * time_step;
ent_animate(my, "jump", jump_animation, ANM_CYCLE);
} else {
jump_animation = 0;
}
// NORMAL MOVES
if ((key_w + key_s) && key_shiftl) { //RUNNING
movement_speed.x = 20 * (key_w - key_s) * time_step;
movement_speed.y = 0;
if (jump_height < 1){
anim_percent += 11 * time_step;
ent_animate(my, "run", anim_percent, ANM_CYCLE);
if (step_sound < 1) {
ent_playsound (my, wav_passo_mato, 300);
step_sound = 55;
}
else {
step_sound -= 3;
}
}
} else {
if ((key_w + key_s) || (key_a + key_d)) { //WALKING FRON, BACK, SIDES
movement_speed.x = 3 * (key_w - key_s) * time_step;
movement_speed.y = 3 * (key_a - key_d) * time_step;
if (jump_height < 1) {
anim_percent += 6.5 * time_step;
ent_animate(my, "walk", anim_percent, ANM_CYCLE);
if (step_sound < 1) {
ent_playsound (my, wav_passo_mato, 300);
step_sound = 60;
}
else {
step_sound -= 2;
}
}
} else { //STAND
movement_speed.x = 0;
movement_speed.y = 0;
if (jump_height < 1) {
anim_percent += 2 * time_step;
ent_animate(my, "stand", anim_percent, ANM_CYCLE);
}
}
}
movement_speed.z = -(ground_distance - 28) + jump_height;
movement_speed.z = maxv(-25 * time_step, movement_speed.z);
c_move (my, movement_speed.x, nullvector, IGNORE_PASSABLE | GLIDE);