start of attacking
This commit is contained in:
@@ -31,6 +31,7 @@ public class Entity {
|
||||
int dialogueIndex = 0;
|
||||
public boolean collisionOn = false;
|
||||
public boolean invincible = false;
|
||||
boolean attacking = false; //TODO: https://youtu.be/HL39xRzPpm4?t=551
|
||||
|
||||
// COUNTER
|
||||
public int spriteCounter = 0;
|
||||
@@ -127,4 +128,13 @@ public class Entity {
|
||||
return null;
|
||||
}
|
||||
|
||||
public BufferedImage initEntitySprites(String name, int width, int height) {
|
||||
try {
|
||||
return Utility.scaleImage(ImageIO.read(new FileInputStream("assets/" + name + ".png")), width, height);
|
||||
} catch (IOException e) {
|
||||
Boot.logger.log(Level.SEVERE, "Could not load entity-image", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,13 +31,12 @@ public class Player extends Entity {
|
||||
|
||||
setDefaultValues();
|
||||
getPlayerImage();
|
||||
getPlayerAttackImage();
|
||||
}
|
||||
|
||||
public void setDefaultValues() {
|
||||
worldX = panel.tileSize * 23;
|
||||
worldY = panel.tileSize * 21;
|
||||
// worldX = panel.tileSize * 10;
|
||||
// worldY = panel.tileSize * 13;
|
||||
speed = 4;
|
||||
direction = Direction.DOWN;
|
||||
|
||||
@@ -46,17 +45,6 @@ public class Player extends Entity {
|
||||
life = maxLife;
|
||||
}
|
||||
|
||||
public void getPlayerImage() {
|
||||
up1 = initEntitySprites("player/boy_up_1");
|
||||
up2 = initEntitySprites("player/boy_up_2");
|
||||
down1 = initEntitySprites("player/boy_down_1");
|
||||
down2 = initEntitySprites("player/boy_down_2");
|
||||
left1 = initEntitySprites("player/boy_left_1");
|
||||
left2 = initEntitySprites("player/boy_left_2");
|
||||
right1 = initEntitySprites("player/boy_right_1");
|
||||
right2 = initEntitySprites("player/boy_right_2");
|
||||
}
|
||||
|
||||
public void update() {
|
||||
// MOVEMENT
|
||||
if(keyH.upPressed || keyH.downPressed || keyH.leftPressed || keyH.rightPressed || keyH.spacePressed) {
|
||||
@@ -147,4 +135,26 @@ public class Player extends Entity {
|
||||
super.speak();
|
||||
}
|
||||
|
||||
public void getPlayerImage() {
|
||||
up1 = initEntitySprites("player/boy_up_1");
|
||||
up2 = initEntitySprites("player/boy_up_2");
|
||||
down1 = initEntitySprites("player/boy_down_1");
|
||||
down2 = initEntitySprites("player/boy_down_2");
|
||||
left1 = initEntitySprites("player/boy_left_1");
|
||||
left2 = initEntitySprites("player/boy_left_2");
|
||||
right1 = initEntitySprites("player/boy_right_1");
|
||||
right2 = initEntitySprites("player/boy_right_2");
|
||||
}
|
||||
|
||||
public void getPlayerAttackImage() {
|
||||
attackUp1 = initEntitySprites("player/attack/boy_attack_up_1", panel.tileSize, panel.tileSize*2);
|
||||
attackUp2 = initEntitySprites("player/attack/boy_attack_up_2", panel.tileSize, panel.tileSize*2);
|
||||
attackDown1 = initEntitySprites("player/attack/boy_attack_down_1", panel.tileSize, panel.tileSize*2);
|
||||
attackDown2 = initEntitySprites("player/attack/boy_attack_down_2", panel.tileSize, panel.tileSize*2);
|
||||
attackLeft1 = initEntitySprites("player/attack/boy_attack_left_1", panel.tileSize*2, panel.tileSize);
|
||||
attackLeft2 = initEntitySprites("player/attack/boy_attack_left_2", panel.tileSize*2, panel.tileSize);
|
||||
attackRight1 = initEntitySprites("player/attack/boy_attack_right_1", panel.tileSize*2, panel.tileSize);
|
||||
attackRight2 = initEntitySprites("player/attack/boy_attack_right_2", panel.tileSize*2, panel.tileSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user