Add tower sprites
This commit is contained in:
parent
6ebc761ee3
commit
7200c3e5e4
|
@ -2,11 +2,16 @@ package fr.ynerant.leveleditor.game;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public class SuperTower extends Tower {
|
public class AutoTower extends Tower {
|
||||||
public SuperTower(int x, int y) {
|
public AutoTower(int x, int y) {
|
||||||
super(x, y);
|
super(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "autotower";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDamagePerShot() {
|
public int getDamagePerShot() {
|
||||||
return 20;
|
return 20;
|
|
@ -9,6 +9,11 @@ public class BasicTower extends Tower {
|
||||||
super(x, y);
|
super(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "basictower";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDamagePerShot() {
|
public int getDamagePerShot() {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -168,8 +168,8 @@ public class GameFrame extends JFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Tower tower : towers) {
|
for (Tower tower : towers) {
|
||||||
g.setColor(Color.blue);
|
Sprite s = tower.getSprite();
|
||||||
g.fillRect(SPRITE_SIZE * tower.getX(), SPRITE_SIZE * tower.getY(), SPRITE_SIZE, SPRITE_SIZE);
|
g.drawImage(s.getImage(), SPRITE_SIZE * tower.getX(), SPRITE_SIZE * tower.getY(), SPRITE_SIZE, SPRITE_SIZE, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
repaint();
|
repaint();
|
||||||
|
|
|
@ -8,6 +8,11 @@ public class NullTower extends Tower {
|
||||||
super(x, y);
|
super(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "nulltower";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDamagePerShot() {
|
public int getDamagePerShot() {
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
|
|
|
@ -1,21 +1,32 @@
|
||||||
package fr.ynerant.leveleditor.game;
|
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.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public abstract class Tower {
|
public abstract class Tower {
|
||||||
|
private Sprite sprite;
|
||||||
private final int x;
|
private final int x;
|
||||||
private final int y;
|
private final int y;
|
||||||
private long remainingTicks;
|
private long remainingTicks;
|
||||||
|
|
||||||
public Tower(int x, int y) {
|
public Tower(int x, int y) {
|
||||||
|
this.sprite = SpriteRegister.getCategory(getName()).getSprites().get(0);
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Random RANDOM = new Random();
|
private static final Random RANDOM = new Random();
|
||||||
|
|
||||||
|
public Sprite getSprite() {
|
||||||
|
return sprite;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract String getName();
|
||||||
|
|
||||||
public abstract int getDamagePerShot();
|
public abstract int getDamagePerShot();
|
||||||
|
|
||||||
public abstract long getPeriod();
|
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 |
|
@ -327,5 +327,14 @@
|
||||||
],
|
],
|
||||||
"mobcancer": [
|
"mobcancer": [
|
||||||
[0, 0]
|
[0, 0]
|
||||||
|
],
|
||||||
|
"simpletower": [
|
||||||
|
[0, 0]
|
||||||
|
],
|
||||||
|
"nulltower": [
|
||||||
|
[0, 0]
|
||||||
|
],
|
||||||
|
"autotower": [
|
||||||
|
[0, 0]
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
Reference in New Issue