ColorRunner/core/src/de/samdev/colorrunner/game/world/entities/gameentities/controller/FlyPlayerController.java

33 lines
898 B
Java

package de.samdev.colorrunner.game.world.entities.gameentities.controller;
import de.samdev.colorrunner.game.world.entities.gameentities.ControllingType;
import de.samdev.colorrunner.game.world.entities.gameentities.PlayerEntity;
public class FlyPlayerController extends AbstractPlayerController {
public FlyPlayerController(PlayerEntity e) {
super(e);
}
@Override
public void update(float delta) {
Player.velocity.y -= GRAVITY_FORCE * delta;
if (Player.velocity.y < -TERMINAL_VELOCITY) {
Player.velocity.y = -TERMINAL_VELOCITY;
}
if (Player.isTouching_BOTTOM() && Player.velocity.y < 0) Player.velocity.y = 0;
if (Player.isTouching_TOP() && Player.velocity.y > 0) Player.velocity.y = 0;
}
@Override
public ControllingType getControllerType() {
return ControllingType.FLY;
}
@Override
public void jumpPressed() {
Player.velocity.y = PLAYER_FLY_UP_FORCE;
}
}