Compare commits
15 Commits
f386ef49f6
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
865b5e0c52 | ||
|
|
d28a29df45 | ||
|
|
b85a36bf14 | ||
|
|
66d36c4ea2 | ||
|
|
d46d25115e | ||
|
|
5f0b827fab | ||
|
|
ca40e4c01a | ||
|
|
21790ecd7a | ||
|
|
da5c5571b2 | ||
|
|
af51d3776e | ||
| e818037d75 | |||
|
|
3e99a2ebc2 | ||
|
|
dc9a08c9ee | ||
|
|
58a41725eb | ||
|
|
d440ad8f67 |
BIN
Zoelda/lib/Dokumentation.zip
Normal file
@@ -28,7 +28,9 @@ public class DoorTile extends Tile implements Ticker {
|
|||||||
float dist = player.dist(posX + 0.5f, posY + 0.5f);
|
float dist = player.dist(posX + 0.5f, posY + 0.5f);
|
||||||
if (dist < 0.5f) {
|
if (dist < 0.5f) {
|
||||||
if (!waitForLeave) {
|
if (!waitForLeave) {
|
||||||
Main.instance.getWorld().changeMap(this);
|
if (connected != null) {
|
||||||
|
Main.instance.getWorld().changeMap(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
waitForLeave = false;
|
waitForLeave = false;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package main.HUD;
|
package main.HUD;
|
||||||
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@@ -8,26 +8,44 @@ import javax.imageio.ImageIO;
|
|||||||
|
|
||||||
import ea.Knoten;
|
import ea.Knoten;
|
||||||
import ea.Ticker;
|
import ea.Ticker;
|
||||||
|
import main.Main;
|
||||||
|
import main.entities.player.PlayerInventory;
|
||||||
|
import main.worlds.World;
|
||||||
|
|
||||||
public class Inventory extends Knoten implements Ticker {
|
public class Inventory extends Knoten implements Ticker {
|
||||||
|
|
||||||
private static final int SCALE = 50;
|
private static final int SCALE = 50;
|
||||||
private BufferedImage inventory;
|
private BufferedImage inventoryFrame;
|
||||||
|
private BufferedImage coinCounterIcon;
|
||||||
|
private PlayerInventory inventory;
|
||||||
|
|
||||||
public Inventory() {
|
public Inventory() {
|
||||||
|
inventory = Main.instance.getWorld().getPlayer().getInventory();
|
||||||
try {
|
try {
|
||||||
inventory = ImageIO.read(HUD.class.getResourceAsStream("/res/images/inventory.png"));
|
inventoryFrame = ImageIO.read(HUD.class.getResourceAsStream("/res/images/inventory.png"));
|
||||||
|
coinCounterIcon = ImageIO.read(HUD.class.getResourceAsStream("/res/images/coins.png"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
coinCounterIcon = coinCounterIcon.getSubimage(0, 20, 7, 4);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void style(Graphics2D g) {
|
||||||
|
Font currentFont = g.getFont();
|
||||||
|
Font newFont = currentFont.deriveFont(Font.BOLD, 20);
|
||||||
|
g.setFont(newFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void zeichnen(Graphics2D g) {
|
public void zeichnen(Graphics2D g) {
|
||||||
g.drawImage(inventory, 0, 0, SCALE * 2, SCALE * 2, null);
|
style(g);
|
||||||
|
g.drawImage(inventoryFrame, 0, 0, SCALE * 2, SCALE * 2, null);
|
||||||
|
g.drawString(String.valueOf(inventory.getCoins()), SCALE + 10, 145);
|
||||||
|
g.drawImage(coinCounterIcon, 0, 125, coinCounterIcon.getWidth() * World.SCALE_FACTOR,
|
||||||
|
coinCounterIcon.getHeight() * World.SCALE_FACTOR, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// wird alle 50ms ausgeführt:
|
// wird alle 50ms ausgef<EFBFBD>hrt:
|
||||||
public void tick() {
|
public void tick() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,12 @@ public class Tile extends Knoten {
|
|||||||
public static final int STONE_WALL_BOTTOM = 4;
|
public static final int STONE_WALL_BOTTOM = 4;
|
||||||
public static final int STONE_FLOOR = 5;
|
public static final int STONE_FLOOR = 5;
|
||||||
public static final int STONE_FLOOR_SHADOW_LEFT = 6;
|
public static final int STONE_FLOOR_SHADOW_LEFT = 6;
|
||||||
public static final int DOOR_LEFT_BOTTOM = 7;
|
public static final int DOOR_LEFT = 7;
|
||||||
public static final int DOOR_LEFT_TOP = 8;
|
public static final int DOOR_RIGHT_LEFT_TOP = 8;
|
||||||
public static final int DISCO = 9;
|
public static final int DISCO = 9;
|
||||||
|
public static final int DOOR_RIGHT = 10;
|
||||||
|
public static final int DOOR_TOP = 11;
|
||||||
|
public static final int DOOR_BOTTOM = 12;
|
||||||
|
|
||||||
private Bild img; // Bild, das gerendert wird
|
private Bild img; // Bild, das gerendert wird
|
||||||
private int id; // Die id dises Tiles//
|
private int id; // Die id dises Tiles//
|
||||||
@@ -51,17 +54,17 @@ public class Tile extends Knoten {
|
|||||||
if (id != VOID) {
|
if (id != VOID) {
|
||||||
img = images[id].clone();
|
img = images[id].clone();
|
||||||
img.positionSetzen(posX * World.SCALE, posY * World.SCALE);
|
img.positionSetzen(posX * World.SCALE, posY * World.SCALE);
|
||||||
// Bild zu EA hinzufügen.
|
// Bild zu EA hinzuf<EFBFBD>gen.
|
||||||
add(img);
|
add(img);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadImages() {
|
private static void loadImages() {
|
||||||
images = new Bild[9];
|
images = new Bild[13];
|
||||||
for (int i = 0; i < images.length; i++) {
|
for (int i = 0; i < images.length; i++) {
|
||||||
try {
|
try {
|
||||||
BufferedImage buff = ImageIO.read(Tile.class.getResourceAsStream(getPathFromId(i)));
|
BufferedImage buff = ImageIO.read(Tile.class.getResourceAsStream(getPathFromId(i)));
|
||||||
// Gras hat 8 verschiedene Texturen von denen eine zufällig ausgewählt werden
|
// Gras hat 8 verschiedene Texturen von denen eine zufaellig ausgewaehlt werden
|
||||||
// muss.
|
// muss.
|
||||||
if (i == GRASS) {
|
if (i == GRASS) {
|
||||||
buff = buff.getSubimage(16 * (int) (Math.random() * 8), 0, 16, 16);
|
buff = buff.getSubimage(16 * (int) (Math.random() * 8), 0, 16, 16);
|
||||||
@@ -77,7 +80,7 @@ public class Tile extends Knoten {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return den Pfad der zu der Id gehört.
|
* @return den Pfad der zu der Id gehoert.
|
||||||
*/
|
*/
|
||||||
private static String getPathFromId(int id) {
|
private static String getPathFromId(int id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
@@ -88,25 +91,31 @@ public class Tile extends Knoten {
|
|||||||
case WALL_BOTTOM:
|
case WALL_BOTTOM:
|
||||||
return "/res/images/tiles/wall_bottom.png";
|
return "/res/images/tiles/wall_bottom.png";
|
||||||
case STONE_WALL:
|
case STONE_WALL:
|
||||||
return "/res/images/tiles/test.png";
|
return "/res/images/tiles/stone_wall.png";
|
||||||
case STONE_WALL_BOTTOM:
|
case STONE_WALL_BOTTOM:
|
||||||
return "/res/images/tiles/stone_wall_bottom.png";
|
return "/res/images/tiles/stone_wall_bottom.png";
|
||||||
case STONE_FLOOR:
|
case STONE_FLOOR:
|
||||||
return "/res/images/tiles/TestTest.png";
|
return "/res/images/tiles/stone_floor.png";
|
||||||
case STONE_FLOOR_SHADOW_LEFT:
|
case STONE_FLOOR_SHADOW_LEFT:
|
||||||
return "/res/images/tiles/stone_floor_shadow_left.png";
|
return "/res/images/tiles/stone_floor_shadow_left.png";
|
||||||
case DOOR_LEFT_BOTTOM:
|
case DOOR_LEFT:
|
||||||
return "/res/images/tiles/door_left_bottom.png";
|
return "/res/images/tiles/door_left.png";
|
||||||
case DOOR_LEFT_TOP:
|
case DOOR_RIGHT_LEFT_TOP:
|
||||||
return "/res/images/tiles/door_left_top.png";
|
return "/res/images/tiles/door_right_left_top.png";
|
||||||
case DISCO:
|
case DISCO:
|
||||||
return "/res/images/tiles/disco_sprite_sheet.png";
|
return "/res/images/tiles/disco_sprite_sheet.png";
|
||||||
|
case DOOR_RIGHT:
|
||||||
|
return "/res/images/tiles/door_right.png";
|
||||||
|
case DOOR_TOP:
|
||||||
|
return "/res/images/tiles/door_top.png";
|
||||||
|
case DOOR_BOTTOM:
|
||||||
|
return "/res/images/tiles/door_bottom.png";
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return die Größe der Textur
|
* @return die Groesse der Textur
|
||||||
*/
|
*/
|
||||||
private static int getSize() {
|
private static int getSize() {
|
||||||
return 16;
|
return 16;
|
||||||
@@ -116,34 +125,34 @@ public class Tile extends Knoten {
|
|||||||
* @return ob man durch das Tile durchgehen kann
|
* @return ob man durch das Tile durchgehen kann
|
||||||
*/
|
*/
|
||||||
public boolean isCollidable() {
|
public boolean isCollidable() {
|
||||||
// Alle Tiles durch die man nicht laufen soll müssen hier true zurückgeben,
|
// Alle Tiles durch die man nicht laufen soll muessen hier true zurueckgeben,
|
||||||
// sonst werden sie bei der Collisiondetection nicht berücksichtigt.
|
// sonst werden sie bei der Collisiondetection nicht ber<EFBFBD>cksichtigt.
|
||||||
return id == WALL_TOP || id == STONE_WALL;
|
return id == WALL_TOP || id == STONE_WALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kleine Hifsmethode un die koordinate der Top-Kante rurückzugenben.
|
* Kleine Hifsmethode um die Koordinate der Top-Kante zurueckzugenben.
|
||||||
*/
|
*/
|
||||||
public int getTop() {
|
public int getTop() {
|
||||||
return positionY();
|
return positionY();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kleine Hifsmethode un die koordinate der Bottom-Kante rurückzugenben.
|
* Kleine Hifsmethode um die Koordinate der Bottom-Kante zurueckzugenben.
|
||||||
*/
|
*/
|
||||||
public int getBottom() {
|
public int getBottom() {
|
||||||
return positionY() + getSize();
|
return positionY() + getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kleine Hifsmethode un die koordinate der Left-Kante rurückzugenben.
|
* Kleine Hifsmethode um die Koordinate der Left-Kante zurueckzugenben.
|
||||||
*/
|
*/
|
||||||
public int getLeft() {
|
public int getLeft() {
|
||||||
return positionX();
|
return positionX();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kleine Hifsmethode un die koordinate der Right-Kante rurückzugenben.
|
* Kleine Hifsmethode um die Koordinate der Right-Kante zurueckzugenben.
|
||||||
*/
|
*/
|
||||||
public int getRight() {
|
public int getRight() {
|
||||||
return positionX() + getSize();
|
return positionX() + getSize();
|
||||||
|
|||||||
@@ -1,27 +1,57 @@
|
|||||||
package main.entities;
|
package main.entities;
|
||||||
|
|
||||||
|
import main.Main;
|
||||||
import main.SheetLoader;
|
import main.SheetLoader;
|
||||||
|
import main.entities.player.Player;
|
||||||
|
|
||||||
public class Coin extends AnimatedEntity {
|
public class Coin extends AnimatedEntity {
|
||||||
|
|
||||||
private static SheetLoader loader = new SheetLoader("/res/images/coins.png");
|
private static SheetLoader loader = new SheetLoader("/res/images/coins.png");
|
||||||
|
private boolean moveToCounterAnimation;
|
||||||
|
private float animationDestX = 0.2f;
|
||||||
|
private float animationDestY = 2.0f;
|
||||||
|
|
||||||
public Coin() {
|
public Coin() {
|
||||||
loader.generateFigures(8, 8, new int[] {8, 8, 1});
|
loader.generateFigures(8, 8, new int[] { 8, 8, 1 });
|
||||||
|
|
||||||
|
loader.getFigur(0).animationsGeschwindigkeitSetzen(100);
|
||||||
|
loader.getFigur(1).animationsGeschwindigkeitSetzen(100);
|
||||||
|
loader.getFigur(2).animationsGeschwindigkeitSetzen(100);
|
||||||
|
|
||||||
actionFigur.neuerZustand(loader.getFigur(0), "gold");
|
actionFigur.neuerZustand(loader.getFigur(0), "gold");
|
||||||
actionFigur.neuerZustand(loader.getFigur(1), "silver");
|
actionFigur.neuerZustand(loader.getFigur(1), "silver");
|
||||||
actionFigur.neuerZustand(loader.getFigur(2), "bronze");
|
actionFigur.neuerZustand(loader.getFigur(2), "bronze");
|
||||||
zustandSetzen("gold");
|
zustandSetzen("bronze");
|
||||||
|
|
||||||
posX = 4f;
|
posX = 4f;
|
||||||
posY = 4f;
|
posY = 4f;
|
||||||
width = 0.375f;
|
width = 0.375f;
|
||||||
height = 0.25f;
|
height = 0.25f;
|
||||||
spriteOffsetY = -0.1f;
|
spriteOffsetY = -0.1f;
|
||||||
|
enablePushBack = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void update() {
|
protected void update() {
|
||||||
super.update();
|
super.update();
|
||||||
|
|
||||||
|
if (moveToCounterAnimation) {
|
||||||
|
float distX = animationDestX - posX;
|
||||||
|
float distY = animationDestY - posY;
|
||||||
|
posX += distX / 10f;
|
||||||
|
posY += distY / 10f;
|
||||||
|
if (distX < 0.05f && distX > -0.05f && distY < 0.05f && distY > -0.05f) {
|
||||||
|
deleteEntity();
|
||||||
|
Main.instance.getWorld().getPlayer().getInventory().addCoins(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEntityCollision(Entity e) {
|
||||||
|
if (e instanceof Player && !moveToCounterAnimation) {
|
||||||
|
moveToCounterAnimation = true;
|
||||||
|
enableTileCollisions = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ public abstract class Entity implements Ticker {
|
|||||||
protected float friction = 0.2f; // Entschleunigung des entities in gameunits pro frame.
|
protected float friction = 0.2f; // Entschleunigung des entities in gameunits pro frame.
|
||||||
protected float width = 1f, height = 1f; // Breite und Höhe der Hitbox.
|
protected float width = 1f, height = 1f; // Breite und Höhe der Hitbox.
|
||||||
private boolean deleteEntity; // Wenn true wird dieses Entity von der map gelöscht
|
private boolean deleteEntity; // Wenn true wird dieses Entity von der map gelöscht
|
||||||
|
protected boolean enablePushBack = true; // Ob das Entity von anderen Entities weggedrückt werden kann.
|
||||||
|
protected boolean enableTileCollisions = true; // Ob das Entity von Wänden abprallen soll
|
||||||
|
|
||||||
// Das ist die Ticker-Methode von ea; wird jeden frame ausgeführt (frameloop)
|
// Das ist die Ticker-Methode von ea; wird jeden frame ausgeführt (frameloop)
|
||||||
@Override
|
@Override
|
||||||
@@ -50,6 +52,9 @@ public abstract class Entity implements Ticker {
|
|||||||
* Checkt collision mit tiles von der map. Fertig, clean, nie wieder ändern.
|
* Checkt collision mit tiles von der map. Fertig, clean, nie wieder ändern.
|
||||||
*/
|
*/
|
||||||
public void checkTileCollision(Map map) {
|
public void checkTileCollision(Map map) {
|
||||||
|
if (!enableTileCollisions) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (int x = (int) (posX - 2); x < posX + 2; x++) {
|
for (int x = (int) (posX - 2); x < posX + 2; x++) {
|
||||||
for (int y = (int) (posY - 2); y < posY + 2; y++) {
|
for (int y = (int) (posY - 2); y < posY + 2; y++) {
|
||||||
if (x >= 0 && x < map.getWidth() && y >= 0 && y < map.getHeight()) {
|
if (x >= 0 && x < map.getWidth() && y >= 0 && y < map.getHeight()) {
|
||||||
@@ -85,14 +90,28 @@ public abstract class Entity implements Ticker {
|
|||||||
float dist = dist(e);
|
float dist = dist(e);
|
||||||
float sizes = esize / 2 + size / 2;
|
float sizes = esize / 2 + size / 2;
|
||||||
if (dist < sizes) {
|
if (dist < sizes) {
|
||||||
float overlap = dist - sizes;
|
if (enablePushBack && e.enablePushBack) {
|
||||||
posX += (overlap * (e.posX - posX));
|
float overlap = dist - sizes;
|
||||||
posY += (overlap * (e.posY - posY));
|
float xDist = e.posX - posX;
|
||||||
|
float yDist = e.posY - posY;
|
||||||
|
if (xDist == 0f) {
|
||||||
|
xDist = (float) (Math.random() - 0.5f) * 0.01f;
|
||||||
|
}
|
||||||
|
if (yDist == 0f) {
|
||||||
|
yDist = (float) (Math.random() - 0.5f) * 0.01f;
|
||||||
|
}
|
||||||
|
posX += (overlap * xDist);
|
||||||
|
posY += (overlap * yDist);
|
||||||
|
}
|
||||||
|
onEntityCollision(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onEntityCollision(Entity e) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gehört mit zur collision detection. Hier werden kollisionen aufgelöst.
|
* Gehört mit zur collision detection. Hier werden kollisionen aufgelöst.
|
||||||
*/
|
*/
|
||||||
@@ -144,7 +163,7 @@ public abstract class Entity implements Ticker {
|
|||||||
Vektor v = new Vektor(e.posX - posX, e.posY - posY);
|
Vektor v = new Vektor(e.posX - posX, e.posY - posY);
|
||||||
;
|
;
|
||||||
if (v.x == 0 && v.y == 0) {
|
if (v.x == 0 && v.y == 0) {
|
||||||
return new Vektor(0.0000001f, 0.0000001f);
|
return new Vektor(0.001f, 0.001f);
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
@@ -218,6 +237,14 @@ public abstract class Entity implements Ticker {
|
|||||||
posY = y;
|
posY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getPosX() {
|
||||||
|
return posX;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getPosY() {
|
||||||
|
return posY;
|
||||||
|
}
|
||||||
|
|
||||||
public void deleteEntity() {
|
public void deleteEntity() {
|
||||||
deleteEntity = true;
|
deleteEntity = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ public abstract class LivingEntity extends AnimatedEntity {
|
|||||||
actionFigur.zustandSetzen(getDeathAnimationName());
|
actionFigur.zustandSetzen(getDeathAnimationName());
|
||||||
velX = 0;
|
velX = 0;
|
||||||
velY = 0;
|
velY = 0;
|
||||||
if (actionFigur.aktuelleFigur().aktuellesBild() == actionFigur.aktuelleFigur().animation().length - 1) {
|
if (actionFigur.aktuelleFigur().aktuellesBild() == actionFigur.aktuelleFigur().animation().length - 1 && !isReadyToDelete()) {
|
||||||
deleteEntity();
|
deleteEntity();
|
||||||
|
onDeath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.update();
|
super.update();
|
||||||
@@ -40,4 +41,7 @@ public abstract class LivingEntity extends AnimatedEntity {
|
|||||||
|
|
||||||
public abstract String getDeathAnimationName();
|
public abstract String getDeathAnimationName();
|
||||||
public abstract String getDamageAnimationName();
|
public abstract String getDamageAnimationName();
|
||||||
|
|
||||||
|
protected void onDeath() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
36
Zoelda/src/main/entities/Rick.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package main.entities;
|
||||||
|
|
||||||
|
import main.SheetLoader;
|
||||||
|
|
||||||
|
public class Rick extends LivingEntity{
|
||||||
|
|
||||||
|
private static SheetLoader loader = new SheetLoader("/res/images/rick_sprite_sheet.png");
|
||||||
|
|
||||||
|
public Rick() {
|
||||||
|
loader.generateFigures(24, 24, new int[] {4});
|
||||||
|
|
||||||
|
width = 0.7f;
|
||||||
|
height = 0.8f;
|
||||||
|
spriteOffsetY = -0.14f;
|
||||||
|
spriteScale = 0.8f;
|
||||||
|
posX = 4f;
|
||||||
|
posY = 4f;
|
||||||
|
mirrored = true;
|
||||||
|
|
||||||
|
loader.getFigur(0).animationsGeschwindigkeitSetzen(265);
|
||||||
|
actionFigur.neuerZustand(loader.getFigur(0), "dancin");
|
||||||
|
zustandSetzen("dancin");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDeathAnimationName() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDamageAnimationName() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -80,4 +80,16 @@ public class Snake extends LivingEntity {
|
|||||||
public String getDamageAnimationName() {
|
public String getDamageAnimationName() {
|
||||||
return "damage";
|
return "damage";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDeath() {
|
||||||
|
int count = (int) (Math.random() * 3);
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
Coin c = new Coin();
|
||||||
|
float x = posX + (float) Math.random() * width - width / 2;
|
||||||
|
float y = posY + (float) Math.random() * height - height / 2;
|
||||||
|
c.setPos(x, y);
|
||||||
|
Main.instance.getWorld().getCurrentMap().addAnimatedEntity(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public class Player extends LivingEntity {
|
|||||||
private static SheetLoader loader = new SheetLoader("/res/images/player_sprite_sheet.png");
|
private static SheetLoader loader = new SheetLoader("/res/images/player_sprite_sheet.png");
|
||||||
private boolean onlyAttackOnceTrigger;
|
private boolean onlyAttackOnceTrigger;
|
||||||
private float range = 1.2f; // die reichweite der Attacke
|
private float range = 1.2f; // die reichweite der Attacke
|
||||||
|
private PlayerInventory inventory;
|
||||||
|
|
||||||
public Player() {
|
public Player() {
|
||||||
loader.generateFigures(64, 32, new int[] { 5, 8, 7, 6, 2, 5, 4, 7 });
|
loader.generateFigures(64, 32, new int[] { 5, 8, 7, 6, 2, 5, 4, 7 });
|
||||||
@@ -27,18 +28,21 @@ public class Player extends LivingEntity {
|
|||||||
posY = 5.5f;
|
posY = 5.5f;
|
||||||
|
|
||||||
// unterschiedliche Animationsgeschwindigkeiten
|
// unterschiedliche Animationsgeschwindigkeiten
|
||||||
// für idle
|
// f<EFBFBD>r idle
|
||||||
loader.getFigur(0).animationsGeschwindigkeitSetzen(200);
|
loader.getFigur(0).animationsGeschwindigkeitSetzen(200);
|
||||||
// fürs laufen
|
// f<EFBFBD>rs laufen
|
||||||
loader.getFigur(1).animationsGeschwindigkeitSetzen(50);
|
loader.getFigur(1).animationsGeschwindigkeitSetzen(50);
|
||||||
|
|
||||||
// Zustände werden hinzugefügt
|
// Zust<EFBFBD>nde werden hinzugef<EFBFBD>gt
|
||||||
actionFigur.neuerZustand(loader.getFigur(0), "idle");
|
actionFigur.neuerZustand(loader.getFigur(0), "idle");
|
||||||
actionFigur.neuerZustand(loader.getFigur(1), "walk");
|
actionFigur.neuerZustand(loader.getFigur(1), "walk");
|
||||||
actionFigur.neuerZustand(loader.getFigur(2), "strike");
|
actionFigur.neuerZustand(loader.getFigur(2), "strike");
|
||||||
actionFigur.neuerZustand(loader.getFigur(3), "swipe");
|
actionFigur.neuerZustand(loader.getFigur(3), "swipe");
|
||||||
actionFigur.neuerZustand(loader.getFigur(6), getDamageAnimationName());
|
actionFigur.neuerZustand(loader.getFigur(6), getDamageAnimationName());
|
||||||
actionFigur.neuerZustand(loader.getFigur(7), getDeathAnimationName());
|
actionFigur.neuerZustand(loader.getFigur(7), getDeathAnimationName());
|
||||||
|
|
||||||
|
//Spieler Inventar
|
||||||
|
inventory = new PlayerInventory(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -46,7 +50,7 @@ public class Player extends LivingEntity {
|
|||||||
// Bei dieser animation bleibt man sofort stehen.
|
// Bei dieser animation bleibt man sofort stehen.
|
||||||
if (!((actionFigur.aktuellesVerhalten().equals("strike"))
|
if (!((actionFigur.aktuellesVerhalten().equals("strike"))
|
||||||
&& actionFigur.aktuelleFigur().aktuellesBild() < actionFigur.aktuelleFigur().animation().length - 1)) {
|
&& actionFigur.aktuelleFigur().aktuellesBild() < actionFigur.aktuelleFigur().animation().length - 1)) {
|
||||||
// Bei diser soll man sich nicht bewegen können aber weiter rutschen
|
// Bei diser soll man sich nicht bewegen k<EFBFBD>nnen aber weiter rutschen
|
||||||
if (!((actionFigur.aktuellesVerhalten().equals("swipe")) && actionFigur.aktuelleFigur()
|
if (!((actionFigur.aktuellesVerhalten().equals("swipe")) && actionFigur.aktuelleFigur()
|
||||||
.aktuellesBild() < actionFigur.aktuelleFigur().animation().length - 1)) {
|
.aktuellesBild() < actionFigur.aktuelleFigur().animation().length - 1)) {
|
||||||
|
|
||||||
@@ -113,6 +117,10 @@ public class Player extends LivingEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlayerInventory getInventory() {
|
||||||
|
return inventory;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDeathAnimationName() {
|
public String getDeathAnimationName() {
|
||||||
return "die";
|
return "die";
|
||||||
|
|||||||
@@ -11,12 +11,16 @@ import main.Tile;
|
|||||||
|
|
||||||
public class ImageMap extends Map {
|
public class ImageMap extends Map {
|
||||||
|
|
||||||
// Erstellung der abzulesenden Tiles (einem Tile wird eine farbe zugewiesen)
|
// Erstellung der abzulesenden Tiles (einem Tile wird eine Farbe zugewiesen)
|
||||||
|
|
||||||
private static PixelTile[] pixels = { new PixelTile(Tile.STONE_WALL, new Color(100, 100, 100)),
|
private static PixelTile[] pixels = {
|
||||||
new PixelTile(Tile.STONE_FLOOR, new Color(127, 127, 127)), new PixelTile(Tile.VOID, new Color(0, 0, 0)),
|
new PixelTile(Tile.STONE_WALL, new Color(100, 100, 100)),
|
||||||
new PixelTile(Tile.DOOR_LEFT_TOP, new Color(255, 150, 0)),
|
new PixelTile(Tile.STONE_FLOOR, new Color(127, 127, 127)),
|
||||||
new PixelTile(Tile.DOOR_LEFT_BOTTOM, new Color(69, 150, 0)),
|
new PixelTile(Tile.VOID, new Color(0, 0, 0)),
|
||||||
|
new PixelTile(Tile.DOOR_LEFT, new Color(255, 150, 0)),
|
||||||
|
new PixelTile(Tile.DOOR_RIGHT, new Color(69, 150, 0)),
|
||||||
|
new PixelTile(Tile.DOOR_BOTTOM, new Color(150, 150, 0)),
|
||||||
|
new PixelTile(Tile.DOOR_TOP, new Color(0, 147, 150)),
|
||||||
new PixelTile(Tile.STONE_WALL_BOTTOM, new Color(145, 145, 145)),
|
new PixelTile(Tile.STONE_WALL_BOTTOM, new Color(145, 145, 145)),
|
||||||
new PixelTile(Tile.STONE_FLOOR_SHADOW_LEFT, new Color(251, 251, 129)) };
|
new PixelTile(Tile.STONE_FLOOR_SHADOW_LEFT, new Color(251, 251, 129)) };
|
||||||
|
|
||||||
@@ -38,7 +42,7 @@ public class ImageMap extends Map {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (id == Tile.DOOR_LEFT_BOTTOM) {
|
if (id == Tile.DOOR_LEFT) {
|
||||||
DoorTile door = new DoorTile(id, x, y, this);
|
DoorTile door = new DoorTile(id, x, y, this);
|
||||||
leftDoor = door;
|
leftDoor = door;
|
||||||
door.setSide(DoorTile.LEFT);
|
door.setSide(DoorTile.LEFT);
|
||||||
@@ -46,6 +50,30 @@ public class ImageMap extends Map {
|
|||||||
add(tiles[x][y]);
|
add(tiles[x][y]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (id == Tile.DOOR_RIGHT ) {
|
||||||
|
DoorTile door = new DoorTile(id, x, y, this);
|
||||||
|
rightDoor = door;
|
||||||
|
door.setSide(DoorTile.RIGHT);
|
||||||
|
tiles[x][y] = door;
|
||||||
|
add(tiles[x][y]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (id == Tile.DOOR_TOP) {
|
||||||
|
DoorTile door = new DoorTile(id, x, y, this);
|
||||||
|
topDoor = door;
|
||||||
|
door.setSide(DoorTile.TOP);
|
||||||
|
tiles[x][y] = door;
|
||||||
|
add(tiles[x][y]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (id == Tile.DOOR_BOTTOM) {
|
||||||
|
DoorTile door = new DoorTile(id, x, y, this);
|
||||||
|
bottomDoor = door;
|
||||||
|
door.setSide(DoorTile.BOTTOM);
|
||||||
|
tiles[x][y] = door;
|
||||||
|
add(tiles[x][y]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
tiles[x][y] = new Tile(id, x, y);
|
tiles[x][y] = new Tile(id, x, y);
|
||||||
add(tiles[x][y]);
|
add(tiles[x][y]);
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import main.Main;
|
|||||||
import main.Tile;
|
import main.Tile;
|
||||||
import main.entities.AnimatedEntity;
|
import main.entities.AnimatedEntity;
|
||||||
import main.entities.Entity;
|
import main.entities.Entity;
|
||||||
import main.entities.LivingEntity;
|
|
||||||
import main.entities.player.Player;
|
import main.entities.player.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,6 +18,7 @@ public abstract class Map extends Knoten implements Ticker {
|
|||||||
|
|
||||||
protected Tile[][] tiles; // Die Tiles der map in einem 2D Array.
|
protected Tile[][] tiles; // Die Tiles der map in einem 2D Array.
|
||||||
private ArrayList<Entity> entities;
|
private ArrayList<Entity> entities;
|
||||||
|
private boolean started;
|
||||||
|
|
||||||
public DoorTile topDoor;
|
public DoorTile topDoor;
|
||||||
public DoorTile leftDoor;
|
public DoorTile leftDoor;
|
||||||
@@ -49,8 +49,8 @@ public abstract class Map extends Knoten implements Ticker {
|
|||||||
for (int i = 0; i < entities.size(); i++) {
|
for (int i = 0; i < entities.size(); i++) {
|
||||||
Entity e = entities.get(i);
|
Entity e = entities.get(i);
|
||||||
if (e.isReadyToDelete()) {
|
if (e.isReadyToDelete()) {
|
||||||
if (e instanceof LivingEntity) {
|
if (e instanceof AnimatedEntity) {
|
||||||
entfernen(((LivingEntity) e).actionFigur);
|
entfernen(((AnimatedEntity) e).actionFigur);
|
||||||
}
|
}
|
||||||
Main.instance.manager.abmelden(e);
|
Main.instance.manager.abmelden(e);
|
||||||
entities.remove(e);
|
entities.remove(e);
|
||||||
@@ -73,6 +73,9 @@ public abstract class Map extends Knoten implements Ticker {
|
|||||||
public void addAnimatedEntity(AnimatedEntity e) {
|
public void addAnimatedEntity(AnimatedEntity e) {
|
||||||
entities.add(e);
|
entities.add(e);
|
||||||
add(e.actionFigur);
|
add(e.actionFigur);
|
||||||
|
if (started) {
|
||||||
|
Main.instance.manager.anmelden(e, 20);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Map clone();
|
public abstract Map clone();
|
||||||
@@ -123,6 +126,7 @@ public abstract class Map extends Knoten implements Ticker {
|
|||||||
Main.instance.manager.anmelden(e, 20);
|
Main.instance.manager.anmelden(e, 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
@@ -143,6 +147,7 @@ public abstract class Map extends Knoten implements Ticker {
|
|||||||
Main.instance.manager.abmelden(e);
|
Main.instance.manager.abmelden(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
started = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connectDoors(DoorTile door, DoorTile door2) {
|
public void connectDoors(DoorTile door, DoorTile door2) {
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package main.worlds;
|
package main.worlds;
|
||||||
|
|
||||||
import main.entities.Coin;
|
import main.entities.Coin;
|
||||||
|
import main.entities.Rick;
|
||||||
import main.entities.Snake;
|
import main.entities.Snake;
|
||||||
|
import main.entities.Spider;
|
||||||
import main.maps.Map;
|
import main.maps.Map;
|
||||||
|
|
||||||
public class TestWorld extends World {
|
public class TestWorld extends World {
|
||||||
@@ -10,15 +12,30 @@ public class TestWorld extends World {
|
|||||||
super(4);
|
super(4);
|
||||||
|
|
||||||
Map m2 = maps[3].clone();
|
Map m2 = maps[3].clone();
|
||||||
getCurrentMap().connectDoors(getCurrentMap().leftDoor, m2.leftDoor);
|
getCurrentMap().connectDoors(getCurrentMap().bottomDoor, m2.topDoor);
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 15; i++) {
|
||||||
|
Coin c = new Coin();
|
||||||
|
c.setPosX(i * 0.5f + 4);
|
||||||
|
getCurrentMap().addAnimatedEntity(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
Snake s = new Snake();
|
Snake s = new Snake();
|
||||||
s.setPosX((float) (Math.random() * 5 + 2));
|
s.setPosX((float) (Math.random() * 5 + 2));
|
||||||
getCurrentMap().addAnimatedEntity(s);
|
getCurrentMap().addAnimatedEntity(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
getCurrentMap().addAnimatedEntity(new Coin());
|
for (int i = 0; i < 3; i++) {
|
||||||
}
|
Spider spooda = new Spider();
|
||||||
|
spooda.setPosX((float) (Math.random() * 5 + 2));
|
||||||
|
getCurrentMap().addAnimatedEntity(spooda);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 1; i++) {
|
||||||
|
Rick astley = new Rick();
|
||||||
|
astley.setPosX((float) (Math.random() * 5 + 2));
|
||||||
|
getCurrentMap().addAnimatedEntity(astley);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Zoelda/src/res/images/coinUpscaled.png
Normal file
|
After Width: | Height: | Size: 250 B |
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 183 B |
|
Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 180 B |
|
Before Width: | Height: | Size: 232 B |
|
Before Width: | Height: | Size: 194 B After Width: | Height: | Size: 174 B |
|
Before Width: | Height: | Size: 248 B After Width: | Height: | Size: 292 B |
|
Before Width: | Height: | Size: 174 B After Width: | Height: | Size: 162 B |
|
Before Width: | Height: | Size: 181 B After Width: | Height: | Size: 161 B |
|
Before Width: | Height: | Size: 186 B After Width: | Height: | Size: 163 B |
BIN
Zoelda/src/res/images/maps/mapdrei.png
Normal file
|
After Width: | Height: | Size: 248 B |
BIN
Zoelda/src/res/images/rick_sprite_sheet.png
Normal file
|
After Width: | Height: | Size: 444 B |
|
Before Width: | Height: | Size: 545 B |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
BIN
Zoelda/src/res/images/tiles/door_bottom.png
Normal file
|
After Width: | Height: | Size: 262 B |
|
Before Width: | Height: | Size: 523 B After Width: | Height: | Size: 245 B |
|
Before Width: | Height: | Size: 351 B |
|
Before Width: | Height: | Size: 535 B After Width: | Height: | Size: 243 B |
|
Before Width: | Height: | Size: 502 B After Width: | Height: | Size: 502 B |
|
Before Width: | Height: | Size: 137 B After Width: | Height: | Size: 137 B |
|
Before Width: | Height: | Size: 230 B After Width: | Height: | Size: 230 B |