import javax.swing.*; public class player extends Sprite{ private int hp; private Vector2 pos, force, clamp; //private ImageIcon image; public player(ImageIcon image, Vector2 pos){ super(image); hp = 5; force = new Vector2(); this.pos = pos; } public float getPosX(){ return pos.getX(); } public float getPosY(){ return pos.getY(); } public void forceChange(Vector2 other){ force.add(other); if(force.getX()< -5) force.setX(-5); if(force.getX()> 5) force.setX(5); if(force.getY() < -5) force.setY(-5); if(force.getY() > 5) force.setY(5); } public void moveShip(){ this.setBounds((int)pos.getX(), (int)pos.getY(), this.getWidth(), this.getHeight()); } @Override public void Update(){ pos.add(force); moveShip(); } }