cheat code protect in pacman app (#1945)

This commit is contained in:
not tre mann 2024-03-07 14:49:17 +08:00 committed by GitHub
parent 9e9dd3a521
commit c28087ac44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -43,6 +43,16 @@ boolean but_DOWN = false; // 50
boolean but_LEFT = false; // 48 boolean but_LEFT = false; // 48
boolean but_RIGHT = false; // 46 boolean but_RIGHT = false; // 46
enum cheat_code_keymap {
UP,
DOWN,
LEFT,
RIGHT
};
enum cheat_code_keymap cheat_code[] = {UP, DOWN, UP, DOWN, RIGHT, LEFT, RIGHT, LEFT};
byte cheat_code_index = 0;
/******************************************************************************/ /******************************************************************************/
/* GAME VARIABLES AND DEFINITIONS */ /* GAME VARIABLES AND DEFINITIONS */
/******************************************************************************/ /******************************************************************************/
@ -1280,30 +1290,65 @@ class Playfield {
but_A = false; but_A = false;
GAMEPAUSED = 1; GAMEPAUSED = 1;
} else if (but_LEFT && DEMO == 1 && GAMEPAUSED == 0) { // -level } else if (but_LEFT && DEMO == 1 && GAMEPAUSED == 0) { // -level
if ((cheat_code[cheat_code_index] == 2) && (cheat_code_index <= 8)) {
cheat_code_index++;
}
if (cheat_code_index == 8) {
cheat_level = true; cheat_level = true;
but_LEFT = false;
if (LEVEL > 1) { if (LEVEL > 1) {
LEVEL--; LEVEL--;
} }
Init(); Init();
}
but_LEFT = false;
} else if (but_RIGHT && DEMO == 1 && GAMEPAUSED == 0) { // +level } else if (but_RIGHT && DEMO == 1 && GAMEPAUSED == 0) { // +level
if ((cheat_code[cheat_code_index] == 3) && (cheat_code_index <= 8)) {
cheat_code_index++;
}
if (cheat_code_index == 8) {
cheat_level = true; cheat_level = true;
but_RIGHT = false;
if (LEVEL < 255) { if (LEVEL < 255) {
LEVEL++; LEVEL++;
} }
Init(); Init();
}
but_RIGHT = false;
} else if (but_UP && DEMO == 1 && GAMEPAUSED == 0) { // full of lifes } else if (but_UP && DEMO == 1 && GAMEPAUSED == 0) { // full of lifes
if ((cheat_code[cheat_code_index] == 0) && (cheat_code_index <= 8)) {
cheat_code_index++;
}
if (cheat_code_index == 8) {
cheat_lifes = true; cheat_lifes = true;
but_UP = false;
Init(); Init();
}
but_UP = false;
} else if (but_DOWN && DEMO == 1 && GAMEPAUSED == 0) { // reset } else if (but_DOWN && DEMO == 1 && GAMEPAUSED == 0) { // reset
if ((cheat_code[cheat_code_index] == 1) && (cheat_code_index <= 8)) {
cheat_code_index++;
}
if (cheat_code_index == 8) {
cheat_level = false; cheat_level = false;
cheat_lifes = false; cheat_lifes = false;
but_DOWN = false; but_DOWN = false;
LIFES = START_LIFES; LIFES = START_LIFES;
cheat_code_index = 0;
Init(); Init();
} }
}
if (GAMEPAUSED && but_A && DEMO == 0) { if (GAMEPAUSED && but_A && DEMO == 0) {
but_A = false; but_A = false;