Skip to content

Commit

Permalink
Attempt to move everything under the common game loop
Browse files Browse the repository at this point in the history
  • Loading branch information
tonihele committed Jul 10, 2024
1 parent 164aa2c commit 15c60c5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/toniarts/openkeeper/game/controller/GameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import toniarts.openkeeper.game.logic.DeathSystem;
import toniarts.openkeeper.game.logic.DecaySystem;
import toniarts.openkeeper.game.logic.DoorViewSystem;
import toniarts.openkeeper.game.logic.DungeonHeartConstruction;
import toniarts.openkeeper.game.logic.GameLogicManager;
import toniarts.openkeeper.game.logic.HaulingSystem;
import toniarts.openkeeper.game.logic.HealthSystem;
Expand Down Expand Up @@ -251,6 +250,9 @@ public void createNewGame() {
// Game logic
gameLogicThread = new GameLogicManager(
1f / kwdFile.getGameLevel().getTicksPerSec(),
new CreatureFallSystem(entityData),
new MovementSystem(entityData),
positionSystem,
gameWorldController.getMapController(),
new DecaySystem(entityData),
new CreatureExperienceSystem(entityData, kwdFile, gameSettings, gameWorldController.getCreaturesController()),
Expand All @@ -274,19 +276,19 @@ public void createNewGame() {
gameLogicLoop = new GameLoop(gameLogicThread, 1000000000 / kwdFile.getGameLevel().getTicksPerSec(), "GameLogic");

// Animation systems
gameAnimationThread = new GameLogicManager(new DungeonHeartConstruction(entityData, getLevelVariable(Variable.MiscVariable.MiscType.TIME_BEFORE_DUNGEON_HEART_CONSTRUCTION_BEGINS)), new CreatureFallSystem(entityData));
gameAnimationLoop = new GameLoop(gameAnimationThread, GameLoop.INTERVAL_FPS_60, "GameAnimation");
//gameAnimationThread = new GameLogicManager(new DungeonHeartConstruction(entityData, getLevelVariable(Variable.MiscVariable.MiscType.TIME_BEFORE_DUNGEON_HEART_CONSTRUCTION_BEGINS)), new CreatureFallSystem(entityData));
//gameAnimationLoop = new GameLoop(gameAnimationThread, GameLoop.INTERVAL_FPS_60, "GameAnimation");

// Steering
steeringCalculatorLoop = new GameLoop(new GameLogicManager(new MovementSystem(entityData)), GameLoop.INTERVAL_FPS_60, "SteeringCalculator");
//steeringCalculatorLoop = new GameLoop(new GameLogicManager(new MovementSystem(entityData)), GameLoop.INTERVAL_FPS_60, "SteeringCalculator");
}

public void startGame() {

// Game logic thread & movement
gameLogicLoop.start();
gameAnimationLoop.start();
steeringCalculatorLoop.start();
//steeringCalculatorLoop.start();
}

private void setupPlayers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public static EntitySteeringBehavior navigateToPoint(List<Vector2> path, final P

// Navigate
FollowPath<Vector2, LinePath.LinePathParam> followPath = new FollowPath(steerable,
new LinePath<>(SteeringUtils.pathToArray(path), true), 0.2f);
followPath.setDecelerationRadius(0.2f);
followPath.setArrivalTolerance(0.1f);
new LinePath<>(SteeringUtils.pathToArray(path), true), 0.5f);
followPath.setDecelerationRadius(1f);
followPath.setArrivalTolerance(0.25f);
prioritySteering.add(followPath);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public class SteerableEntity implements ISteerableEntity {
private float maxLinearAcceleration = 4;
private float maxAngularSpeed = 20.0f;
private float maxAngularAcceleration = 20.0f;
private float zeroLinearSpeedThreshold = 0.01f;
private float zeroLinearSpeedThreshold = 0.1f;
private final float boundingRadius;

public SteerableEntity(EntityId entityId, float maxSpeed, float boundingRadius, float xPos, float yPos, float orientation) {
this.entityId = entityId;
this.boundingRadius = boundingRadius;
this.maxLinearSpeed = maxSpeed;
// FIXME how calculate acceleration? mass & maxLinearSpeed?
this.maxLinearAcceleration = maxLinearSpeed * 4;
this.maxLinearAcceleration = maxLinearSpeed;
// FIXME how calculate zero linear speed threshold?
//zeroLinearSpeedThreshold = maxLinearSpeed / 3;
this.position.x = xPos;
Expand Down

0 comments on commit 15c60c5

Please sign in to comment.