Hello,
I use this code to create an Level in my game:
When you start the game, everything is working, but sometimes the world creates another player so that there are actually two! Only if you turn back to point (1|1) (where the "2" is), one of them is deleted.
I really don't know whythis is happening, so is there anyone who could help me?
Thanks. :)
/*
* 1 = Tree
* 2 = Player
* 3 = another Actor called 'Donator' (he places cherrys on the map)
*
*
*/
int [][] newlvl_1 = {
{ 3,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
{ 1,2,0,0,0,0,0,0,0,0,0,0,0,0,1 },
{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
{ 1,0,0,0,0,0,0,0,0,0,0,0,0,3,1 },
{ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
};
for (int y = 0; y < newlvl_1[0].length; y++) {
for(int x = 0; x < newlvl_1.length; x++) {
int ID = newlvl_1[x][y];
switch(ID) {
case 1: addObject(new Tree(),x,y);
case 2: addObject(new Player(),1,1);
}
}
}
