Fix player 3 starting direction for CrossSlice map

This commit is contained in:
Andrew Guibert 2018-05-11 16:56:53 -05:00
parent 47726aa90b
commit 5fc3b9325d
2 changed files with 8 additions and 5 deletions

View File

@ -2,9 +2,9 @@ package org.libertybikes.game.maps;
import org.libertybikes.game.core.DIRECTION;
import org.libertybikes.game.core.GameBoard;
import org.libertybikes.game.core.GameBoard.Point;
import org.libertybikes.game.core.MovingObstacle;
import org.libertybikes.game.core.Obstacle;
import org.libertybikes.game.core.GameBoard.Point;
public class CrossSlice extends GameMap {
@ -21,8 +21,8 @@ public class CrossSlice extends GameMap {
startingPoints = new Point[] {
new Point(GameBoard.BOARD_SIZE / 2 - 15, GameBoard.BOARD_SIZE / 2 - 15),
new Point(GameBoard.BOARD_SIZE / 2 + 15, GameBoard.BOARD_SIZE / 2 - 15),
new Point(GameBoard.BOARD_SIZE / 2 - 15, GameBoard.BOARD_SIZE / 2 + 15),
new Point(GameBoard.BOARD_SIZE / 2 + 15, GameBoard.BOARD_SIZE / 2 + 15)
new Point(GameBoard.BOARD_SIZE / 2 + 15, GameBoard.BOARD_SIZE / 2 + 15),
new Point(GameBoard.BOARD_SIZE / 2 - 15, GameBoard.BOARD_SIZE / 2 + 15)
};
startingDirections = new DIRECTION[] { DIRECTION.UP, DIRECTION.RIGHT, DIRECTION.DOWN, DIRECTION.LEFT };
}

View File

@ -2,7 +2,7 @@ package org.libertybikes.game.maps;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import java.util.Random;
import org.libertybikes.game.core.DIRECTION;
import org.libertybikes.game.core.GameBoard;
@ -12,13 +12,16 @@ import org.libertybikes.game.core.Obstacle;
public class GameMap {
public static final int NUM_MAPS = 4; // Not including empty map
private static final Random r = new Random();
/**
* @param map -1=random, 0=empty, >0=specific map
*/
public static GameMap create(int map) {
switch (map) {
case -1:
return create(ThreadLocalRandom.current().nextInt(1, 5));
return create(r.nextInt(NUM_MAPS) + 1);
case 0:
return new EmptyMap();
case 1: