From ff6807dabd1e76cddeee8208ba41d107a02193ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20L=C3=B6wenstrom?= Date: Sun, 5 Apr 2020 14:07:24 +0200 Subject: [PATCH] spawn start of antgame constant --- src/main/java/evironment/antGame/Constants.java | 2 ++ src/main/java/evironment/antGame/Grid.java | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/evironment/antGame/Constants.java b/src/main/java/evironment/antGame/Constants.java index 2394491..cdc8040 100644 --- a/src/main/java/evironment/antGame/Constants.java +++ b/src/main/java/evironment/antGame/Constants.java @@ -3,4 +3,6 @@ package evironment.antGame; public class Constants { public static final int DEFAULT_GRID_WIDTH = 5; public static final int DEFAULT_GRID_HEIGHT = 5; + public static final int START_X = 5; + public static final int START_Y = 2; } diff --git a/src/main/java/evironment/antGame/Grid.java b/src/main/java/evironment/antGame/Grid.java index 0393b93..c1d03f1 100644 --- a/src/main/java/evironment/antGame/Grid.java +++ b/src/main/java/evironment/antGame/Grid.java @@ -16,6 +16,7 @@ public class Grid { this.height = height; grid = new Cell[width][height]; initialGrid = new Cell[width][height]; + start = new Point(Constants.START_X, Constants.START_Y); initRandomWorld(); } @@ -29,10 +30,11 @@ public class Grid { initialGrid[x][y] = new Cell(new Point(x, y), CellType.FREE); } } - start = new Point(RNG.getRandomEnv().nextInt(width), RNG.getRandomEnv().nextInt(height)); - initialGrid[start.x][start.y] = new Cell(new Point(start.x, start.y), CellType.START); spawnNewFood(initialGrid); spawnObstacles(); + initialGrid[start.x][start.y] = new Cell(new Point(start.x, start.y), CellType.START); + ; + } //TODO @@ -53,7 +55,7 @@ public class Grid { /** * Spawns one additional food on a random field EXCEPT for the starting position */ - public void spawnNewFood(Cell[][] grid) { + private void spawnNewFood(Cell[][] grid) { boolean foodSpawned = false; Point potFood = new Point(0, 0); CellType potFieldType;