Package raiding.engine.model

Source Code of raiding.engine.model.PlayerStatus

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);
    }
  }
}
TOP

Related Classes of raiding.engine.model.PlayerStatus

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.