Skip to content

Commit

Permalink
Move minions to their own directory, refactor constructor for easier
Browse files Browse the repository at this point in the history
readability
Refactor takeDamage method for towers and minion bar formatting
  • Loading branch information
dwm10005 committed Apr 17, 2015
1 parent 4a5c19b commit 02fb847
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 28 deletions.
24 changes: 12 additions & 12 deletions src/MinionTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
import javax.imageio.ImageIO;

public enum MinionTypes {
//NAME (Health, Attack, Speed, goldValue)
WEAKLING(100, 1, 1, "Weakling Minion.png", 1),
BASIC (255, 1, 1, "Basic Minion.png", 2),
SPEEDO (100, 1, 4, "Speedo Minion.png", 3),
SUPERSPEEDO (255, 1, 4, "Superspeedo Minion.png", 5),
JUGGERNAUT (1000, 1, 1, "Juggernaut Minion.png", 10),
UNKILLABLE (10000,1,1, "Unkillable Minion.png", 100),
DOUBLEBASIC(255, 2, 1, "Double Basic Minion.png", 12),
SUPERKILLER(10, 20, 8, "Superkiller Minion.png", 100),
MONEYBAGS(350, 1, 2, "Moneybags Minion.png", 50);
//NAME (Health, Attack, Speed, goldValue, sprite file name)
WEAKLING (100, 1, 1, 1, "Weakling Minion.png"),
BASIC (255, 1, 1, 2, "Basic Minion.png"),
SPEEDO (100, 1, 4, 3, "Speedo Minion.png"),
SUPERSPEEDO (255, 1, 4, 5, "Superspeedo Minion.png"),
JUGGERNAUT (1000, 1, 1, 10, "Juggernaut Minion.png"),
UNKILLABLE (10000, 1, 1, 100, "Unkillable Minion.png"),
DOUBLEBASIC (255, 2, 1, 12, "Double Basic Minion.png"),
SUPERKILLER (10, 20, 8, 100, "Superkiller Minion.png"),
MONEYBAGS (350, 1, 2, 50, "Moneybags Minion.png");


private int health, attackDamage, movementSpeed, value;
private BufferedImage sprite;
private static final String SPRITE_FILE_DIR = "src/";
private static final String SPRITE_FILE_DIR = "src/resources/images/"; //Make sure that the directory name ends in a forward slash

MinionTypes(int health, int attackDamage, int movementSpeed, String spriteFileName, int value) {
MinionTypes(int health, int attackDamage, int movementSpeed, int value, String spriteFileName) {
this.health = health;
this.attackDamage = attackDamage;
this.movementSpeed = movementSpeed;
Expand Down
4 changes: 2 additions & 2 deletions src/MockGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ public void drawMinion(int x, int y, int health, Graphics g) {
public void drawMinion(MinionMock m, Graphics g)
{
g.drawImage(m.getSprite(), m.getX(), m.getY(), null);
String h = "[" + m.getHealth() + "/" + m.getMaxHealth() +"]";
String healthBar = String.format("[%s/%s]", m.getHealth(), m.getMaxHealth());
g.setColor(Color.RED);
g.drawString(h, m.getX()-15, m.getY()-10);
g.drawString(healthBar, m.getX()-15, m.getY()-10);
//g.drawString(m.getName(), m.getX()-15, m.getY()+45);
//g.drawString(("V: " + m.getValue() + "\nD: " + m.getAttackDamage()), m.getX(), m.getY()+46);
}
Expand Down
26 changes: 12 additions & 14 deletions src/TowerMock.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,22 @@ public int dealDamage(int x, int y) {
}

}
public boolean takeDamage(int i) {
if (i > 1) {
takeDamage();
return takeDamage(i-1);
} else {
return takeDamage();
public boolean takeDamage(int damage) {
if (this.health <= damage)
{
health = 0;
return true; //gameover
}
else
{
health -= damage;
System.out.println(health);
return false;
}
}

public boolean takeDamage() {
health--;
System.out.println(health);
if (health <= 0) {
return true;
// LOSE GAME TERMINATE
} else {
return false;
}
return takeDamage(1);
}
public int getHealth() {
return health;
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes

0 comments on commit 02fb847

Please sign in to comment.