diff --git a/assets/npc/bigrock.png b/assets/npc/bigrock.png new file mode 100644 index 0000000..42db00d Binary files /dev/null and b/assets/npc/bigrock.png differ diff --git a/assets/npc/merchant_down_1.png b/assets/npc/merchant_down_1.png new file mode 100644 index 0000000..2e6950b Binary files /dev/null and b/assets/npc/merchant_down_1.png differ diff --git a/assets/npc/merchant_down_2.png b/assets/npc/merchant_down_2.png new file mode 100644 index 0000000..6515ba3 Binary files /dev/null and b/assets/npc/merchant_down_2.png differ diff --git a/assets/npc/oldman_down_1.png b/assets/npc/oldman_down_1.png new file mode 100644 index 0000000..1d1ebef Binary files /dev/null and b/assets/npc/oldman_down_1.png differ diff --git a/assets/npc/oldman_down_2.png b/assets/npc/oldman_down_2.png new file mode 100644 index 0000000..a3c16ab Binary files /dev/null and b/assets/npc/oldman_down_2.png differ diff --git a/assets/npc/oldman_left_1.png b/assets/npc/oldman_left_1.png new file mode 100644 index 0000000..c5a0aad Binary files /dev/null and b/assets/npc/oldman_left_1.png differ diff --git a/assets/npc/oldman_left_2.png b/assets/npc/oldman_left_2.png new file mode 100644 index 0000000..d8012c0 Binary files /dev/null and b/assets/npc/oldman_left_2.png differ diff --git a/assets/npc/oldman_right_1.png b/assets/npc/oldman_right_1.png new file mode 100644 index 0000000..87873c7 Binary files /dev/null and b/assets/npc/oldman_right_1.png differ diff --git a/assets/npc/oldman_right_2.png b/assets/npc/oldman_right_2.png new file mode 100644 index 0000000..7f9aa78 Binary files /dev/null and b/assets/npc/oldman_right_2.png differ diff --git a/assets/npc/oldman_up_1.png b/assets/npc/oldman_up_1.png new file mode 100644 index 0000000..6fd8c05 Binary files /dev/null and b/assets/npc/oldman_up_1.png differ diff --git a/assets/npc/oldman_up_2.png b/assets/npc/oldman_up_2.png new file mode 100644 index 0000000..c3a6dbd Binary files /dev/null and b/assets/npc/oldman_up_2.png differ diff --git a/src/de/miaurizius/jgame2d/entity/Entity.java b/src/de/miaurizius/jgame2d/entity/Entity.java index cbb1c8d..d00863f 100644 --- a/src/de/miaurizius/jgame2d/entity/Entity.java +++ b/src/de/miaurizius/jgame2d/entity/Entity.java @@ -1,23 +1,41 @@ package de.miaurizius.jgame2d.entity; +import de.miaurizius.jgame2d.core.Boot; import de.miaurizius.jgame2d.core.Direction; +import de.miaurizius.jgame2d.core.GamePanel; +import de.miaurizius.jgame2d.core.Utility; +import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.logging.Level; public class Entity { + GamePanel panel; public int worldX, worldY; public int speed; - public BufferedImage up1, up2, down1, down2, left1, left2, right1, right2; public Direction direction; - public int spriteCounter = 0; public int spriteNum = 1; - - public Rectangle solidArea; + public Rectangle solidArea = new Rectangle(0, 0, 48, 48); public int solidAreaDefaultX, solidAreaDefaultY; public boolean collisionOn = false; + public Entity(GamePanel panel) { + this.panel = panel; + } + + public BufferedImage initEntitySprites(String name) { + try { + return Utility.scaleImage(ImageIO.read(new FileInputStream("assets/" + name + ".png")), panel.tileSize, panel.tileSize); + } catch (IOException e) { + Boot.logger.log(Level.SEVERE, "Could not load entity-image", e); + } + return null; + } + } diff --git a/src/de/miaurizius/jgame2d/entity/OldManNPC.java b/src/de/miaurizius/jgame2d/entity/OldManNPC.java new file mode 100644 index 0000000..9fe7483 --- /dev/null +++ b/src/de/miaurizius/jgame2d/entity/OldManNPC.java @@ -0,0 +1,26 @@ +package de.miaurizius.jgame2d.entity; + +import de.miaurizius.jgame2d.core.Direction; +import de.miaurizius.jgame2d.core.GamePanel; + +public class OldManNPC extends Entity { + + public OldManNPC(GamePanel panel) { + super(panel); + + direction = Direction.DOWN; + speed = 1; + } + + public void getPlayerImage() { + up1 = initEntitySprites("boy_up_1"); + up2 = initEntitySprites("boy_up_2"); + down1 = initEntitySprites("boy_down_1"); + down2 = initEntitySprites("boy_down_2"); + left1 = initEntitySprites("boy_left_1"); + left2 = initEntitySprites("boy_left_2"); + right1 = initEntitySprites("boy_right_1"); + right2 = initEntitySprites("boy_right_2"); + } + +} diff --git a/src/de/miaurizius/jgame2d/entity/Player.java b/src/de/miaurizius/jgame2d/entity/Player.java index c662bd3..e940c86 100644 --- a/src/de/miaurizius/jgame2d/entity/Player.java +++ b/src/de/miaurizius/jgame2d/entity/Player.java @@ -2,22 +2,19 @@ package de.miaurizius.jgame2d.entity; import de.miaurizius.jgame2d.core.*; -import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; -import java.util.logging.Level; public class Player extends Entity { - GamePanel panel; KeyHandler keyH; public final int screenX; public final int screenY; public Player(GamePanel panel, KeyHandler keyH) { - this.panel = panel; + super(panel); this.keyH = keyH; screenX = panel.screenWidth/2 - panel.tileSize/2; @@ -43,23 +40,14 @@ public class Player extends Entity { } public void getPlayerImage() { - up1 = initPlayerImage("boy_up_1"); - up2 = initPlayerImage("boy_up_2"); - down1 = initPlayerImage("boy_down_1"); - down2 = initPlayerImage("boy_down_2"); - left1 = initPlayerImage("boy_left_1"); - left2 = initPlayerImage(("boy_left_2")); - right1 = initPlayerImage(("boy_right_1")); - right2 = initPlayerImage(("boy_right_2")); - } - - public BufferedImage initPlayerImage(String name) { - try { - return Utility.scaleImage(ImageIO.read(new FileInputStream("assets/player/" + name + ".png")), panel.tileSize, panel.tileSize); - } catch (IOException e) { - Boot.logger.log(Level.SEVERE, "Could not load player-image", e); - } - return null; + 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() {