diff --git a/src/main/java/fr/ynerant/leveleditor/game/SuperTower.java b/src/main/java/fr/ynerant/leveleditor/game/AutoTower.java similarity index 72% rename from src/main/java/fr/ynerant/leveleditor/game/SuperTower.java rename to src/main/java/fr/ynerant/leveleditor/game/AutoTower.java index bd48827..6eb3e1f 100644 --- a/src/main/java/fr/ynerant/leveleditor/game/SuperTower.java +++ b/src/main/java/fr/ynerant/leveleditor/game/AutoTower.java @@ -2,11 +2,16 @@ package fr.ynerant.leveleditor.game; import java.util.Collection; -public class SuperTower extends Tower { - public SuperTower(int x, int y) { +public class AutoTower extends Tower { + public AutoTower(int x, int y) { super(x, y); } + @Override + public String getName() { + return "autotower"; + } + @Override public int getDamagePerShot() { return 20; diff --git a/src/main/java/fr/ynerant/leveleditor/game/BasicTower.java b/src/main/java/fr/ynerant/leveleditor/game/BasicTower.java index 3ce72bc..0f377f9 100644 --- a/src/main/java/fr/ynerant/leveleditor/game/BasicTower.java +++ b/src/main/java/fr/ynerant/leveleditor/game/BasicTower.java @@ -9,6 +9,11 @@ public class BasicTower extends Tower { super(x, y); } + @Override + public String getName() { + return "basictower"; + } + @Override public int getDamagePerShot() { return 1; diff --git a/src/main/java/fr/ynerant/leveleditor/game/GameFrame.java b/src/main/java/fr/ynerant/leveleditor/game/GameFrame.java index 8d49fb1..c4e853e 100644 --- a/src/main/java/fr/ynerant/leveleditor/game/GameFrame.java +++ b/src/main/java/fr/ynerant/leveleditor/game/GameFrame.java @@ -168,8 +168,8 @@ public class GameFrame extends JFrame { } for (Tower tower : towers) { - g.setColor(Color.blue); - g.fillRect(SPRITE_SIZE * tower.getX(), SPRITE_SIZE * tower.getY(), SPRITE_SIZE, SPRITE_SIZE); + Sprite s = tower.getSprite(); + g.drawImage(s.getImage(), SPRITE_SIZE * tower.getX(), SPRITE_SIZE * tower.getY(), SPRITE_SIZE, SPRITE_SIZE, null, null); } repaint(); diff --git a/src/main/java/fr/ynerant/leveleditor/game/NullTower.java b/src/main/java/fr/ynerant/leveleditor/game/NullTower.java index 3ea628e..798b924 100644 --- a/src/main/java/fr/ynerant/leveleditor/game/NullTower.java +++ b/src/main/java/fr/ynerant/leveleditor/game/NullTower.java @@ -8,6 +8,11 @@ public class NullTower extends Tower { super(x, y); } + @Override + public String getName() { + return "nulltower"; + } + @Override public int getDamagePerShot() { return Integer.MAX_VALUE; diff --git a/src/main/java/fr/ynerant/leveleditor/game/Tower.java b/src/main/java/fr/ynerant/leveleditor/game/Tower.java index 305949c..59ebfd1 100644 --- a/src/main/java/fr/ynerant/leveleditor/game/Tower.java +++ b/src/main/java/fr/ynerant/leveleditor/game/Tower.java @@ -1,21 +1,32 @@ package fr.ynerant.leveleditor.game; +import fr.ynerant.leveleditor.api.editor.sprites.Sprite; +import fr.ynerant.leveleditor.api.editor.sprites.SpriteRegister; + import java.util.ArrayList; import java.util.Collection; import java.util.Random; public abstract class Tower { + private Sprite sprite; private final int x; private final int y; private long remainingTicks; public Tower(int x, int y) { + this.sprite = SpriteRegister.getCategory(getName()).getSprites().get(0); this.x = x; this.y = y; } private static final Random RANDOM = new Random(); + public Sprite getSprite() { + return sprite; + } + + public abstract String getName(); + public abstract int getDamagePerShot(); public abstract long getPeriod(); diff --git a/src/main/resources/assets/leveleditor/textures/sprites/autotower.png b/src/main/resources/assets/leveleditor/textures/sprites/autotower.png new file mode 100644 index 0000000..3177412 Binary files /dev/null and b/src/main/resources/assets/leveleditor/textures/sprites/autotower.png differ diff --git a/src/main/resources/assets/leveleditor/textures/sprites/nulltower.png b/src/main/resources/assets/leveleditor/textures/sprites/nulltower.png new file mode 100644 index 0000000..c44a960 Binary files /dev/null and b/src/main/resources/assets/leveleditor/textures/sprites/nulltower.png differ diff --git a/src/main/resources/assets/leveleditor/textures/sprites/simpletower.png b/src/main/resources/assets/leveleditor/textures/sprites/simpletower.png new file mode 100644 index 0000000..89f32ad Binary files /dev/null and b/src/main/resources/assets/leveleditor/textures/sprites/simpletower.png differ diff --git a/src/main/resources/assets/leveleditor/textures/sprites/sprites.json b/src/main/resources/assets/leveleditor/textures/sprites/sprites.json index 7f2ac5d..fa7ab4d 100644 --- a/src/main/resources/assets/leveleditor/textures/sprites/sprites.json +++ b/src/main/resources/assets/leveleditor/textures/sprites/sprites.json @@ -327,5 +327,14 @@ ], "mobcancer": [ [0, 0] + ], + "simpletower": [ + [0, 0] + ], + "nulltower": [ + [0, 0] + ], + "autotower": [ + [0, 0] ] } \ No newline at end of file