public void Bewegung() {
boolean move_right = true;
boolean move_left = true;
if (Greenfoot.isKeyDown("D")){
if (velocity_x >= 0)
velocity_x += 0.2f;
else
if (velocity_x < 0)
velocity_x += 0.5f;
if (velocity_x+0.3f > velocity_move_MAX)
velocity_x = velocity_move_MAX;
else
if (velocity_x > velocity_move_MAX)
velocity_x -= 0.4f;
}
else
move_left = false;
if (Greenfoot.isKeyDown("A"))
{
if (velocity_x <= 0)
velocity_x -= 0.2f;
else
if (velocity_x > 0)
velocity_x -= 0.5f;
if (velocity_x-0.3f < -velocity_move_MAX)
velocity_x = -velocity_move_MAX;
else
if (velocity_x < -velocity_move_MAX)
velocity_x += 0.4f;
}
else
move_right = false;
if (Greenfoot.isKeyDown("space") && !Sprunglock)
{
if (Sprunghigh == 0)
Sprunghigh = getY() - SprungMAX;
if (getY() <= Sprunghigh)
{
Sprunghigh = 0;
Sprunglock = true;
}
velocity_y -= 0.4f;
if (velocity_y < -velocity_jump_MAX)
velocity_y = -velocity_jump_MAX;
}
else
if (!Greenfoot.isKeyDown("space") && velocity_y < 0 && !Sprunglock)
{
Sprunglock = true;
}
if (Sprunglock)
{
velocity_y += 0.3f;
if (velocity_y > velocity_fall_MAX)
velocity_y = velocity_fall_MAX;
}
if (!move_left && !move_right)
{
if (velocity_x < 0)
velocity_x += 0.75f;
else
if (velocity_x > 0)
velocity_x -= 0.75f;
if (velocity_x <= 1.1f && velocity_x >= -1.1f)
velocity_x = 0;
}
if (Greenfoot.isKeyDown("r"))
Tod();
}
