Added base for general entities and characters (sub-class of entity)

This commit is contained in:
no 2021-05-27 01:11:59 +02:00
parent 296ec9c821
commit 4719b3e9f2
2 changed files with 70 additions and 1 deletions

View File

@ -0,0 +1,31 @@
package Entities;
import Frames.Frame;
/**
* Character class, which is a sub-class of an entity
* @author Victor
*
*/
public class Character extends Entity {
private static int maxHP;
/**
* Main constructor for a character. By default its max health is 1000 if not specified
*/
public Character() {
super();
this.maxHP = 1000;
}
public Character(int posx, int posy, Frame f, int maxHP) {
super(posx, posy, f);
this.maxHP = maxHP;
}
public void setMaxHP(int HP) {
this.maxHP = HP;
}
public int getMaxHP() { return this.getMaxHP();}
}

View File

@ -1,5 +1,7 @@
package Entities;
import Frames.Frame;
/**
* Entity class, which is the main class regrouping characters and projectiles
* @author Victor
@ -8,5 +10,41 @@ package Entities;
public class Entity {
private int posx;
private int posy;
private .Frame currentFrame = new Entityframe();
private Frame currentFrame;
/**
* base constructor of the entity class
*/
public Entity() {
this.posx = 0;
this.posy = 0;
this.currentFrame = new Frame();
}
/**
* constructor of the entity class with parameters
* @param posx the position of the entity on the x axis
* @param posy the position of the entity on the y axis
* @param f the current frame of the new entity
*/
public Entity(int posx, int posy, Frame f) {
this.posx = posx;
this.posy = posy;
this.currentFrame = f;
}
public void setPos(int x, int y) {
this.posx = x;
this.posy = y;
}
public void setCurrentFrame(Frame f) {
this.currentFrame = f;
}
public int getPosX() {return this.posx;}
public int getPosY() {return this.posy;}
public Frame getCurrentframe() {return this.currentFrame;}
}