Computer Science Canada

Randomization problem

Author:  von5leyz [ Fri Dec 09, 2011 11:54 pm ]
Post subject:  Randomization problem

im having problems because i need to change the code below and turn it to a code that randomizes:

this.maze = new Maze("/turtlemaze/Level"+level+".txt");

the code above calls the level of my game in this order.(NOTE: "level1" is the names(variable) on the level)
-level1
-level2
-level3
-level4
-level5

this is my problem, its in order!,
can you help me in finding the code to make this radom like this:
-level4 -level3
-level2 -level5
-level1 or -level2
-level5 -level1
-level3 -level4


if you guys want the complete code:


public GameManager(MyGameCanvas canvas, int level, int playerCycle)
{
this.canvas = canvas;
//this.maze = new Maze("/turtlemaze/Level.txt");
this.maze = new Maze("/turtlemaze/Level"+level+".txt");
this.playerInfo = new PlayerInfo("Player_"+playerCycle);

this.turtlemaze = new Turtlemaze(maze);

this.clyde = new Clyde(Maze.MAZE_TURTLE4, maze);
this.blinky = new Blinky(Maze.MAZE_TURTLE3, maze);
this.inky = new Inky(Maze.MAZE_TURTLE2, maze);
this.pinky = new Pinky(Maze.MAZE_TURTLE1, maze);
ghosts.addElement(turtle4);
ghosts.addElement(turtle3);
ghosts.addElement(turtle2);
ghosts.addElement(turtle1);

this.foods = maze.getFoods();
}


: