-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWarrior.java
45 lines (32 loc) · 1.05 KB
/
Warrior.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
//medium health
//high damage
//medium speed
//special is?
public class Warrior extends Player{
Warrior() {
setHealth(100);
setAttackDamage(20);
setMana(100);
loadSprites();
setHealth(100);
setMana(100);
setHud(new PlayerHud(getHealth(),getMana(), "warrior")); //base hp/mp
}
/**
* loadSprites
* this method loads the sprite sheet into the game
* @return Boolean, true if the operation was a success, false otherwise.
*/
public void loadSprites(){
try {
BufferedImage sheet = ImageIO.read(new File("resource/warrior.png"));
this.sprites = new BufferedImage[spriteRowNum* spriteColumnNum];
for (int j = 0; j < spriteRowNum; j++)
for (int i = 0; i < spriteColumnNum; i++)
this.sprites[(j * spriteColumnNum) + i] = sheet.getSubimage(i * spriteWidth,j * spriteLength, spriteWidth, spriteLength);
} catch(Exception e) { System.out.println("error loading sheet");}; //set width and stuff
}
}