mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 16:58:47 +00:00
deps: Refactor dependencies (#3224)
* remove spring dep move junit, logging, mockito under dep mgmt * upgrade anti-corruption-layer deps * async method invocation * balking, bloc * bridge to bytecode * caching * callback - cqrs * component - health check * hexagonal - metadata mapping * rest of the patterns * remove checkstyle, take spotless into use
This commit is contained in:
@@ -28,9 +28,7 @@ import java.security.SecureRandom;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Abstract class for GameLoop implementation class.
|
||||
*/
|
||||
/** Abstract class for GameLoop implementation class. */
|
||||
public abstract class GameLoop {
|
||||
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
@@ -39,26 +37,20 @@ public abstract class GameLoop {
|
||||
|
||||
protected final GameController controller;
|
||||
|
||||
/**
|
||||
* Initialize game status to be stopped.
|
||||
*/
|
||||
/** Initialize game status to be stopped. */
|
||||
protected GameLoop() {
|
||||
controller = new GameController();
|
||||
status = GameStatus.STOPPED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run game loop.
|
||||
*/
|
||||
/** Run game loop. */
|
||||
public void run() {
|
||||
status = GameStatus.RUNNING;
|
||||
Thread gameThread = new Thread(this::processGameLoop);
|
||||
gameThread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop game loop.
|
||||
*/
|
||||
/** Stop game loop. */
|
||||
public void stop() {
|
||||
status = GameStatus.STOPPED;
|
||||
}
|
||||
@@ -73,9 +65,8 @@ public abstract class GameLoop {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle any user input that has happened since the last call. In order to
|
||||
* simulate the situation in real-life game, here we add a random time lag.
|
||||
* The time lag ranges from 50 ms to 250 ms.
|
||||
* Handle any user input that has happened since the last call. In order to simulate the situation
|
||||
* in real-life game, here we add a random time lag. The time lag ranges from 50 ms to 250 ms.
|
||||
*/
|
||||
protected void processInput() {
|
||||
try {
|
||||
@@ -88,18 +79,12 @@ public abstract class GameLoop {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render game frames to screen. Here we print bullet position to simulate
|
||||
* this process.
|
||||
*/
|
||||
/** Render game frames to screen. Here we print bullet position to simulate this process. */
|
||||
protected void render() {
|
||||
var position = controller.getBulletPosition();
|
||||
logger.info("Current bullet position: {}", position);
|
||||
}
|
||||
|
||||
/**
|
||||
* execute game loop logic.
|
||||
*/
|
||||
/** execute game loop logic. */
|
||||
protected abstract void processGameLoop();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user