package raiding.engine.model;
import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Input;
import org.newdawn.slick.geom.Vector2f;
import raiding.engine.handler.MotionHandler;
import raiding.engine.handler.PlayerMotionHandler;
public class PlayerStatus {
private MotionHandler motionHandler;
private PlayerAvatar playerAvatar;
public PlayerStatus(String name, Animation avatar, int xPos, int yPos) {
playerAvatar = new PlayerAvatar(avatar, xPos, yPos);
}
public void draw() {
playerAvatar.draw();
}
public void update(GameContainer gc, int delta) {
if (motionHandler != null) {
motionHandler.updateCurrentPosition(delta);
playerAvatar.setPosition(motionHandler.getCurrentPosition());
if (motionHandler.isEnded())
motionHandler = null;
}
Input input = gc.getInput();
if (input.isMousePressed(0)) {
int mouseX = input.getMouseX();
int mouseY = input.getMouseY();
motionHandler = new PlayerMotionHandler(1, playerAvatar.getAvatar(), new Vector2f(mouseX, mouseY), 0);
motionHandler.isActivating(playerAvatar.getPosition(), delta);
}
}
}