diff options
| author | mithe24 <mithe24@student.sdu.dk> | 2025-05-07 17:17:44 +0200 |
|---|---|---|
| committer | mithe24 <mithe24@student.sdu.dk> | 2025-05-07 17:31:53 +0200 |
| commit | aec79e01ba110cc2145d3643fabc0af756c0d7ca (patch) | |
| tree | 09e35571a96265a6d5ba0733a4e8e7411bd19eb5 /pacman | |
| parent | c164daed53574babb26796b05682432709e2c5c1 (diff) | |
| download | pacman-aec79e01ba110cc2145d3643fabc0af756c0d7ca.tar.gz pacman-aec79e01ba110cc2145d3643fabc0af756c0d7ca.zip | |
fix/small-fixes (#14)
* fix(model/entities): entites start in center of tile
* style(pacman): It should be width and height, not height and width.
* refactor(view): Changing setting of background color
Diffstat (limited to 'pacman')
5 files changed, 12 insertions, 11 deletions
diff --git a/pacman/controller/src/main/java/com/gr15/pacman/controller/GameController.java b/pacman/controller/src/main/java/com/gr15/pacman/controller/GameController.java index 075fa5c..a334576 100644 --- a/pacman/controller/src/main/java/com/gr15/pacman/controller/GameController.java +++ b/pacman/controller/src/main/java/com/gr15/pacman/controller/GameController.java @@ -5,7 +5,6 @@ import com.gr15.pacman.model.entities.Entity.Direction; import com.gr15.pacman.view.GameView; import javafx.animation.AnimationTimer; -import javafx.scene.paint.Color; /** * GameController @@ -21,7 +20,6 @@ public class GameController { public GameController(GameState gameState, GameView gameView) { this.gameState = gameState; this.gameView = gameView; - gameView.setFill(Color.BLACK); setupEventHandlers(); gameLoop = new AnimationTimer() { diff --git a/pacman/model/src/main/java/com/gr15/pacman/model/Board.java b/pacman/model/src/main/java/com/gr15/pacman/model/Board.java index 898ec3b..399ddfc 100644 --- a/pacman/model/src/main/java/com/gr15/pacman/model/Board.java +++ b/pacman/model/src/main/java/com/gr15/pacman/model/Board.java @@ -11,13 +11,13 @@ public class Board { public enum TileType { WALL, EMPTY }; - public Board(int height, int width) { + public Board(int width, int height) { this.width = width; this.height = height; } - public Board(int height, int width, TileType[][] tileBoard) { - this(height, width); + public Board(int width, int height, TileType[][] tileBoard) { + this(width, height); this.tileBoard = tileBoard; } diff --git a/pacman/model/src/main/java/com/gr15/pacman/model/GameStateBuilder.java b/pacman/model/src/main/java/com/gr15/pacman/model/GameStateBuilder.java index aab7dd9..b9a64cd 100644 --- a/pacman/model/src/main/java/com/gr15/pacman/model/GameStateBuilder.java +++ b/pacman/model/src/main/java/com/gr15/pacman/model/GameStateBuilder.java @@ -5,6 +5,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.json.JSONArray; @@ -12,7 +13,7 @@ import org.json.JSONException; import org.json.JSONObject; import org.json.JSONTokener; -import com.gr15.pacman.model.Board.Direction; +import com.gr15.pacman.model.entities.Entity.Direction; import com.gr15.pacman.model.Board.TileType; import com.gr15.pacman.model.entities.Entity; import com.gr15.pacman.model.entities.Ghost; @@ -106,7 +107,7 @@ public class GameStateBuilder { pacmanJsonObject.getInt("y")); Pacman pacman = new Pacman(pacmanStartPos, speed, Direction.NONE, radius); - ArrayList<Entity> entities = new ArrayList<>(); + List<Entity> entities = new ArrayList<>(); Map<Position, Items> items = new HashMap<>(); return new GameState(board, pacman, entities, items); diff --git a/pacman/model/src/main/java/com/gr15/pacman/model/entities/Entity.java b/pacman/model/src/main/java/com/gr15/pacman/model/entities/Entity.java index daf0eef..0792219 100644 --- a/pacman/model/src/main/java/com/gr15/pacman/model/entities/Entity.java +++ b/pacman/model/src/main/java/com/gr15/pacman/model/entities/Entity.java @@ -9,8 +9,8 @@ import com.gr15.pacman.model.Position; public abstract class Entity { private Position position; - private float subTileX = 0.0f; - private float subTileY = 0.0f; + private float subTileX = 0.5f; + private float subTileY = 0.5f; private double radius; diff --git a/pacman/view/src/main/java/com/gr15/pacman/view/GameView.java b/pacman/view/src/main/java/com/gr15/pacman/view/GameView.java index d56a1e1..d9235f6 100644 --- a/pacman/view/src/main/java/com/gr15/pacman/view/GameView.java +++ b/pacman/view/src/main/java/com/gr15/pacman/view/GameView.java @@ -12,6 +12,7 @@ import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.image.Image; import javafx.scene.layout.StackPane; +import javafx.scene.paint.Color; import com.gr15.pacman.model.entities.Entity; import com.gr15.pacman.model.entities.Items; @@ -30,8 +31,8 @@ public class GameView private float scaleX = 4.0f; private float scaleY = 4.0f; - private int tileHeight; private int tileWidth; + private int tileHeight; private Map<TileType, Image> tileTextures = new HashMap<>(); private Map<Entity, Image> entityTextures = new HashMap<>(); @@ -41,7 +42,7 @@ public class GameView private Sprite pacmanSprite; public GameView(GameState gameState, - int tileHeight, int tileWidth) { + int tileWidth, int tileHeight) { super(new StackPane()); root = (StackPane)super.getRoot(); @@ -52,6 +53,7 @@ public class GameView this.tileHeight = tileHeight; this.tileWidth = tileWidth; this.gameState = gameState; + this.setFill(Color.BLACK); tileTextures.put(TileType.WALL, new Image( this.getClass().getResourceAsStream("/gameAssets/wall.png"))); |