Skip to content
Snippets Groups Projects
Commit 099cae42 authored by Scherbaum Maximilian's avatar Scherbaum Maximilian
Browse files

add: Enum EntityType.java, update: implements Entity Interface in...

add: Enum EntityType.java, update: implements Entity Interface in EnemyHandler.java, update: implemented EntityFactory.java, update: created player via factory in GameSceneController.java, update: Player.java #6
parent e85dfe2d
No related branches found
No related tags found
4 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development,!3merging player for integration testing
package de.hdm_stuttgart.battlearena.Controller;
import de.hdm_stuttgart.battlearena.Model.Entity.Player;
import de.hdm_stuttgart.battlearena.Model.Entity.EntityFactory;
import de.hdm_stuttgart.battlearena.Model.Entity.EntityType;
import de.hdm_stuttgart.battlearena.Model.Entity.IEntity;
import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler;
import javafx.animation.AnimationTimer;
......@@ -26,14 +28,14 @@ public class GameSceneController implements Initializable {
InputHandler inputHandler = InputHandler.getInstance();
Player player;
IEntity player;
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
graphicsContext2D = canvas2D.getGraphicsContext2D();
player = new Player(graphicsContext2D, inputHandler);
player = EntityFactory.createEntity(EntityType.PLAYER, graphicsContext2D, inputHandler);
AnimationTimer gameLoop = new AnimationTimer() {
@Override
......@@ -44,6 +46,7 @@ public class GameSceneController implements Initializable {
}
};
gameLoop.start();
log.debug("Game loop started");
}
private void updateContent() {
......
package de.hdm_stuttgart.battlearena.Model.Entity;
import javafx.scene.canvas.GraphicsContext;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
public class EnemyHandler {
class EnemyHandler implements IEntity{
private static final Logger log = LogManager.getLogger(EnemyHandler.class);
}
@Override
public void initializeEntity() {
}
@Override
public void loadEntitySprites() {
}
@Override
public void updateEntityMovement() {
}
@Override
public void updateEntityAnimation() {
}
@Override
public void renderEntity(GraphicsContext graphicsContext) {
}
}
\ No newline at end of file
package de.hdm_stuttgart.battlearena.Model.Entity;
import de.hdm_stuttgart.battlearena.Model.Inputs.InputHandler;
import javafx.scene.canvas.GraphicsContext;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
......@@ -7,4 +11,16 @@ public class EntityFactory {
private static final Logger log = LogManager.getLogger(EntityFactory.class);
public static IEntity createEntity(EntityType entityType, GraphicsContext gameScene, InputHandler inputHandler) {
if (entityType == EntityType.PLAYER) {
log.debug("Entity " + entityType + " created");
return new Player(gameScene, inputHandler);
} else if (entityType == EntityType.ENEMY_PLAYER) {
log.debug("Entity " + entityType + " created");
return new EnemyHandler();
}
throw new IllegalArgumentException ("Entity type not supported " + entityType);
}
}
\ No newline at end of file
package de.hdm_stuttgart.battlearena.Model.Entity;
public enum EntityType {
PLAYER,
ENEMY_PLAYER
}
\ No newline at end of file
......@@ -11,7 +11,7 @@ import org.apache.logging.log4j.LogManager;
import java.util.Objects;
public class Player implements IEntity {
class Player implements IEntity {
private static final Logger log = LogManager.getLogger(Player.class);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment