So, my switch code is this one:
switch(gamestate) {
case 0 :
arduboy.drawBitmap(0, 0, titlescreen, 68, 58, WHITE);
arduboy.setCursor(70, 30);
arduboy.print("Press A ");
if(arduboy.pressed(A_BUTTON)) {
gamestate = 1;
};
break;
//TITLU
case 1:
//JOC
if (arduboy.pressed(UP_BUTTON)) {
playery = playery - 1;
};
if (arduboy.pressed(DOWN_BUTTON)) {
playery = playery + 1;
};
if (arduboy.pressed(RIGHT_BUTTON)) {
playerx = playerx + 1;
};
if (arduboy.pressed(LEFT_BUTTON)) {
playerx = playerx - 1;
};
for ( int backgroundx = 0; backgroundx < 128; backgroundx = backgroundx + 8 ) {
for ( int backgroundy = 0; backgroundy < 64; backgroundy = backgroundy +8 ){
arduboy.drawBitmap(backgroundx, backgroundy, background, 8, 8, WHITE);
};
};
arduboy.fillRect(playerx ,playery, 16, 16, BLACK);
arduboy.drawBitmap(playerx, playery, player, 16, 16, WHITE);
if (playerx == 0) {
gamestate = 4;
}
if(playerx == 127) {
gamestate = 2;
}
if(playery == 0) {
gamestate = 4;
}
if (playery == 63) {
gamestate = 4;
}
arduboy.fillRect(0, 0, 128, 2, WHITE);
arduboy.fillRect(0, 0, 2, 64, WHITE);
arduboy.fillRect(0, 62, 128, 2, WHITE);
arduboy.fillRect(126, 0, 2, 64, WHITE);
//MARGINE JOS
//MARGINE DREAPTA
break;
case 2:
//NIVEL2
break;
case 3:
//AI CASTIGAT
break;
case 4:
** arduboy.setCursor(30, 15);**
** arduboy.print(“You lost! :(”);**
** arduboy.setCursor(5, 50);**
** arduboy.print(“Press A to try again”);**
** if(arduboy.pressed(A_BUTTON)) {**
** gamestate = 1;**
** }**
** //AI PIERDUT**
break;
}
So, if i press the A button while in the 4th case, it will get me in the first case, but the problem is that by pressing the A button, it gets me in the place that I “died”. Is there anyway to like “reset” the case and make it like it was the first time i ran it? Thanks for the help anyway. If you need the whole code, let me know in the comments. I will be more than pleased to leave it in the comments.