/* * Created on Apr 14, 2005 * */ /** * @author Terry Arnold * * All children must implement CollisionMap interface * */ public abstract class Player extends Entity implements CollisionMap{ protected int health; protected int lives; protected boolean isalive; public Player() { location = new Point2d(); speed = new Vector2d(); scale = new Vector2d(); spin = 0; setInvisible(); health = 0; lives = 0; isalive = false; BoundaryBox = new Boundary(); } public Player(int x,int y) { location = new Point2d(x,y); speed = new Vector2d(); scale = new Vector2d(); spin = 0; setInvisible(); health = 0; lives = 0; isalive = false; BoundaryBox = new Boundary(); } public abstract void OnPlayerCollision(Player p); public abstract void OnEnemyCollision(Enemy e); public abstract void OnItemCollision(Item i); public abstract void OnBorderCollision(Border b); public boolean isAlive() { return isalive; } public void setdead() { isalive = false; } public void setalive() { isalive = true; } public int gethealth() { return health; } public void move(String direction){ if(direction.equals("Left")){ setx(getx()-10); } if(direction.equals("Right")){ setx(getx()+10); } } public void sethealth(int amount) { health = amount; } public void addhealth(int amount) { health+=amount; } public void subhealth(int amount) { health-=amount; } public int getlives() { return lives; } public void setlives(int amount) { lives = amount; } public void addlives(int amount) { lives+=amount; } public void sublives(int amount) { lives-=amount; } }