added better speed mechanic

This commit is contained in:
2025-10-04 14:03:44 +02:00
parent a49b3b20cc
commit 382d850605
2 changed files with 9 additions and 7 deletions

View File

@@ -28,12 +28,14 @@ class TurtleGame extends StatelessGame {
private final Map<Player, Integer> scoreMap = new WeakHashMap<>(); private final Map<Player, Integer> scoreMap = new WeakHashMap<>();
private final ArrayList<Entity> snacks = new ArrayList<>(); private final ArrayList<Entity> snacks = new ArrayList<>();
private final ArrayList<Entity> bombs = new ArrayList<>(); private final ArrayList<Entity> bombs = new ArrayList<>();
private double speed = 2; private double speed;
private double maxSpeed = 10; private final double maxSpeedIncrease;
public TurtleGame(int radius) { public TurtleGame(int radius, int startSpeed) {
super(Dimension.OVERWORLD.key, "Turtle Game", new PointsWinScore()); super(Dimension.OVERWORLD.key, "Turtle Game", new PointsWinScore());
this.radius = radius; this.radius = radius;
this.speed = startSpeed;
this.maxSpeedIncrease = (double) this.radius / 4;
this.eventNode() this.eventNode()
.addListener(PlayerTickEvent.class, this::onPlayerTick); .addListener(PlayerTickEvent.class, this::onPlayerTick);
@@ -93,8 +95,7 @@ class TurtleGame extends StatelessGame {
bomb.remove(); bomb.remove();
this.generateNewBomb(2); this.generateNewBomb(2);
this.getScore().insertResult(p, this.scoreMap.get(p)); this.getScore().insertResult(p, this.scoreMap.get(p));
// TODO: Speed in Einstellungen anpassbar machen und je nach Spieleranzahl erhöhen this.speed += this.maxSpeedIncrease / this.getPlayers().size();
this.speed += 0.5;
}); });
} }
} }

View File

@@ -26,12 +26,13 @@ public class TurtleGameFactory implements GameFactory {
@Override @Override
public ConfigManager configuration() { public ConfigManager configuration() {
return new ConfigManager() 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 @Override
public Game manufacture(Room parent, Map<String, Option<?>> configuration) throws Exception { 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 @Override