Add tower sprites

This commit is contained in:
Yohann D'ANELLO 2020-02-25 10:54:40 +01:00
parent 6ebc761ee3
commit 7200c3e5e4
9 changed files with 39 additions and 4 deletions

View File

@ -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;

View File

@ -9,6 +9,11 @@ public class BasicTower extends Tower {
super(x, y);
}
@Override
public String getName() {
return "basictower";
}
@Override
public int getDamagePerShot() {
return 1;

View File

@ -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();

View File

@ -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;

View File

@ -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();

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

View File

@ -327,5 +327,14 @@
],
"mobcancer": [
[0, 0]
],
"simpletower": [
[0, 0]
],
"nulltower": [
[0, 0]
],
"autotower": [
[0, 0]
]
}