function down_rob_func();
function right_stand_func();
function left_stand_func();
function right_stand_func();
function left_stand_func();
function right_gun_func();
function left_gun_func();
function main{
level_load("robo01.wmb");fps_max=70;
wait(3);
}
entity* don_rob_ent;
entity* up_rob_ent;
entity* stand_right_rob_ent;
entity* stand_left_rob_ent;
entity* gun_right_rob_ent;
entity* gun_left_rob_ent;
//entity* don_rob_ent;
action robo_player{
var down_point_tmp;
while(me==null){wait(1);}//wait for create me
don_rob_ent=me;
moving_robo_func();
//////////////////////////////
// create up part
vec_for_vertex(down_point_tmp,me,29);
ent_create("up_robo.mdl",down_point_tmp,down_rob_func);
//////////////////////////////
//////////////////////////////
// place camera
camera.tilt = -15; // look down at the player, play with this value
while(1){
wait(time_step);
camera.x = me.x - 350 * cos(me.pan); // 250 = distance between the player and the camera, play with this value
camera.y = me.y - 350 * sin(me.pan); // use the same value here
camera.z = me.z + 150; // place the camera above the player, play with this value
camera.pan = me.pan; // the camera and the player have the same pan angle
}
//////////////////////////////
}
function down_rob_func{
while(me==null){wait(1);}//wait for create me
var right_hand_point_tmp;
var left_hand_point_tmp;
while(me==null){wait(1);}//wait for create me
up_rob_ent=me;
}
function moving_robo_func{
var anim_percentage; // animation percentage
var movement_speed; // player's movement speed
var distance_to_ground; // the distance between player's origin and the ground
// player = my; // I'm the player
while (1)
{
my.pan += 6 * (key_a - key_d) * time; // rotate the player using the "A" and "D" keys
vec_set (temp, my.x); // copy player's position to temp
temp.z -= 5000; // set temp.z 5000 quants below player's origin
distance_to_ground = c_trace (my.x, temp.x, ignore_me | use_box);
movement_speed.x = 5 * (key_w - key_s) * time; // move the player using "W" and "S"
movement_speed.y = 0; // don't move sideways
movement_speed.z = - (distance_to_ground - 100); // 17 = experimental value
movement_speed.z = max (-35 * time, movement_speed.z); // 35 = falling speed
c_move (my, movement_speed.x, nullvector, glide); // move the player
c_move (up_rob_ent, movement_speed.x, nullvector, glide); // move the player
if ((key_w == off) && (key_s == off)) // the player isn't moving?
{
ent_animate(my, "stand", anim_percentage, anm_cycle); // play the "stand" animation
}
else // the player is moving?
{
ent_animate(my, "walk", anim_percentage, anm_cycle); // play the "walk" animation
}
anim_percentage += 5 * time; // 5 = animation speed
wait (1);
}
}