var hausx= -150;
var hausy = -400;
var anzahlwasser = 1;
var wasserx = 200;
var wassery = 300;
var anzahlwasserschl = 0;
var anzahlwasserschl2 = 0;
var zielx1 = 0;
var ziely1 = 0;
var zielx2 = 0;
var ziely2 = 0;
action player_walk()
{
// if necessary, adjust the bounding box to give the entity 'floor room' (see remarks)
// my.min_z *= 0.5;
var speed_down = 0; // downward speed by gravity
var anim_percent = 0; // animation percentage
VECTOR vFeet;
vec_for_min(vFeet,me); // vFeet.z = distance from player origin to lowest vertex
var dist_ahead = 5*time_step;
while (1)
{
// rotate the player using the [A] and [D] keys
//my.pan += 5*(key_a-key_d)*time_step;
my.pan = 0;
// determine the ground distance by a downwards trace
var dist_down;
if (c_trace(my.x,vector(my.x,my.y,my.z-5000),IGNORE_ME | IGNORE_PASSABLE | USE_BOX) > 0)
dist_down = my.z + vFeet.z - target.z; // get distance between player's feet and the ground
else
dist_down = 0;
// apply gravity when the player is in the air
if (dist_down > 0) // above floor, fall down with increasing speed
dist_down = clamp(dist_down,0,accelerate(speed_down,5,0.1));
else // on or below floor, set downward speed to zero
speed_down = 0;
// move the player using the [W] and [S] keys
//var dist_ahead = 5*(key_w-key_s)*time_step;
var dist_ahead = 5*time_step;
dist_ahead = sign(dist_ahead)*(abs(dist_ahead) + 0.5*dist_down); // adapt the speed on slopes
if(anzahlwasser > 0){
zielx1 = wasserx;
ziely1 = wassery;
if (anzahlwasserschl == 0)
{
if(me.x < zielx1)
{
c_move(me,vector(1,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
}
if(me.x > zielx1)
{
c_move(me,vector(-1,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
}
if(me.y < ziely1){
c_move(me,vector(0,1,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
}
if(me.y > ziely1){
c_move(me,vector(0,-1,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
}
}
if(me.x == zielx1 && me.y == ziely1){
anzahlwasserschl2 = 1;
}
if(anzahlwasserschl2 == 1){
anzahlwasserschl = 1;
zielx2 = hausx;
ziely2 = hausy;
if(me.x < zielx2)
{
c_move(me,vector(1,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
}
if(me.x > zielx2)
{
c_move(me,vector(0,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
}
if(me.y < ziely2){
c_move(me,vector(0,1,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
}
if(me.y > ziely2){
c_move(me,vector(0,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE | GLIDE); // move the player
}
if(me.x == zielx2 && me.y == ziely2){
printf("fertig:",(double)anzahlwasser);
anzahlwasser = anzahlwasser - 1;
anzahlwasserschl = 0;
anzahlwasserschl2 = 0;
}
}
}
//c_move(me,vector(100,0,0),vector(0,0,0),IGNORE_PASSABLE | GLIDE); // move the player
// animate the player according to its moved distance
if (dist_ahead != 0) // player is moving ahead
{
anim_percent += 1.3*dist_ahead; // 1.3 = walk cycle percentage per quant
ent_animate(me,"walk",anim_percent,ANM_CYCLE); // play the "walk" animation
}
else // player stands still
{
anim_percent += 5*time_step;
ent_animate(me,"stand",anim_percent,ANM_CYCLE); // play the "stand" animation
}
wait(1);
}
}