added better speed mechanic
This commit is contained in:
@@ -28,12 +28,14 @@ class TurtleGame extends StatelessGame {
|
||||
private final Map<Player, Integer> scoreMap = new WeakHashMap<>();
|
||||
private final ArrayList<Entity> snacks = new ArrayList<>();
|
||||
private final ArrayList<Entity> bombs = new ArrayList<>();
|
||||
private double speed = 2;
|
||||
private double maxSpeed = 10;
|
||||
private double speed;
|
||||
private final double maxSpeedIncrease;
|
||||
|
||||
public TurtleGame(int radius) {
|
||||
public TurtleGame(int radius, int startSpeed) {
|
||||
super(Dimension.OVERWORLD.key, "Turtle Game", new PointsWinScore());
|
||||
this.radius = radius;
|
||||
this.speed = startSpeed;
|
||||
this.maxSpeedIncrease = (double) this.radius / 4;
|
||||
|
||||
this.eventNode()
|
||||
.addListener(PlayerTickEvent.class, this::onPlayerTick);
|
||||
@@ -93,8 +95,7 @@ class TurtleGame extends StatelessGame {
|
||||
bomb.remove();
|
||||
this.generateNewBomb(2);
|
||||
this.getScore().insertResult(p, this.scoreMap.get(p));
|
||||
// TODO: Speed in Einstellungen anpassbar machen und je nach Spieleranzahl erhöhen
|
||||
this.speed += 0.5;
|
||||
this.speed += this.maxSpeedIncrease / this.getPlayers().size();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -26,12 +26,13 @@ public class TurtleGameFactory implements GameFactory {
|
||||
@Override
|
||||
public ConfigManager configuration() {
|
||||
return new ConfigManager()
|
||||
.addOption(new NumericOption("radius", Material.HEART_OF_THE_SEA, TranslatedComponent.byId("optionCommon#radius"), 10, 20, 30, 40));
|
||||
.addOption(new NumericOption("radius", Material.HEART_OF_THE_SEA, TranslatedComponent.byId("optionCommon#radius"), 10, 20, 30, 40))
|
||||
.addOption(new NumericOption("startSpeed", Material.LEATHER_BOOTS, TranslatedComponent.byId("game_TurtleGame#startSpeed"), 2, 4, 6));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Game manufacture(Room parent, Map<String, Option<?>> configuration) throws Exception {
|
||||
return new TurtleGame(configuration.get("radius").getAsInt()).setParent(parent);
|
||||
return new TurtleGame(configuration.get("radius").getAsInt(), configuration.get("startSpeed").getAsInt()).setParent(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user