// Gameplay Screen Update logic void UpdateAisle01Screen(void) { // Update doors bounds doorLeft.bound.x = doorLeft.position.x - scroll; doorCenter.bound.x = doorCenter.position.x - scroll; doorRight.bound.x = doorRight.position.x - scroll; if (player.key) { // Door: left if ((CheckCollisionPointRec(GetMousePosition(), doorLeft.bound)) || (CheckCollisionRecs(player.bounds, doorLeft.bound))) doorLeft.selected = true; else doorLeft.selected = false; if ((doorLeft.selected) && (CheckCollisionRecs(player.bounds, doorLeft.bound))) { if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorLeft.bound)) || (IsKeyPressed(KEY_SPACE))) { if (doorLeft.locked) { doorLeft.frameRec.y = 0; doorLeft.locked = false; PlaySound(sndDoor); } else finishScreen = 1; } } // Door: center if ((CheckCollisionPointRec(GetMousePosition(), doorCenter.bound)) || (CheckCollisionRecs(player.bounds, doorCenter.bound))) doorCenter.selected = true; else doorCenter.selected = false; if ((doorCenter.selected) && (CheckCollisionRecs(player.bounds, doorCenter.bound))) { if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorCenter.bound)) || (IsKeyPressed(KEY_SPACE))) { if (doorCenter.locked) { doorCenter.frameRec.y = 0; doorCenter.locked = false; PlaySound(sndDoor); } else finishScreen = 2; } } // Door: right if ((CheckCollisionPointRec(GetMousePosition(), doorRight.bound)) || (CheckCollisionRecs(player.bounds, doorRight.bound))) doorRight.selected = true; else doorRight.selected = false; if ((doorRight.selected) && (CheckCollisionRecs(player.bounds, doorRight.bound))) { if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorRight.bound)) || (IsKeyPressed(KEY_SPACE))) { if (doorRight.locked) { doorRight.frameRec.y = 0; doorRight.locked = false; PlaySound(sndDoor); } else finishScreen = 3; } } } if (msgState > 2) { UpdatePlayer(); // Monsters logic UpdateMonster(&lamp); UpdateMonster(&picture); } // Update monster bounds lamp.bounds.x = lamp.position.x + 20 - scroll; picture.bounds.x = picture.position.x + 44 - scroll; // Check player hover monsters to interact if (((CheckCollisionRecs(player.bounds, lamp.bounds)) && !lamp.active) || ((CheckCollisionRecs(player.bounds, picture.bounds)) && !picture.active)) monsterHover = true; else monsterHover = false; // Monters logic: lamp if ((CheckCollisionRecs(player.bounds, lamp.bounds)) && !lamp.active) { lamp.selected = true; if ((IsKeyPressed(KEY_SPACE)) || ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), lamp.bounds)))) { SearchKeyPlayer(); searching = true; framesCounter = 0; monsterCheck = 1; } } else lamp.selected = false; // Monters logic: picture if ((CheckCollisionRecs(player.bounds, picture.bounds)) && !picture.active) { picture.selected = true; if ((IsKeyPressed(KEY_SPACE)) || ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), picture.bounds)))) { SearchKeyPlayer(); searching = true; framesCounter = 0; monsterCheck = 2; } } else picture.selected = false; if (searching) { framesCounter++; if (framesCounter > 180) { if (monsterCheck == 1) { if (lamp.spooky) { ScarePlayer(); PlaySound(sndScream); } else FindKeyPlayer(); lamp.active = true; lamp.selected = false; } else if (monsterCheck == 2) { if (picture.spooky) { ScarePlayer(); PlaySound(sndScream); } else FindKeyPlayer(); picture.active = true; picture.selected = false; } searching = false; framesCounter = 0; } } // Text animation framesCounter++; if ((framesCounter%2) == 0) lettersCounter++; if (msgState == 0) { if (lettersCounter <= (int)strlen(message)) strncpy(msgBuffer, message, lettersCounter); else { for (int i = 0; i < (int)strlen(msgBuffer); i++) msgBuffer[i] = '\0'; lettersCounter = 0; msgState = 1; } if (IsKeyPressed(KEY_ENTER)) msgState = 1; } else if (msgState == 1) { msgCounter++; if ((IsKeyPressed(KEY_ENTER)) || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) { msgState = 2; msgCounter = 0; } } else if (msgState == 2) { msgCounter++; if (msgCounter > 180) msgState = 3; } else msgCounter++; if (player.position.x > 200) { scroll = player.position.x - 200; if (scroll > 620) scroll = 620; } }
// Gameplay Screen Update logic void UpdateLivingroomScreen(void) { if (player.key) { // Door: left if ((CheckCollisionPointRec(GetMousePosition(), doorLeft.bound)) || (CheckCollisionRecs(player.bounds, doorLeft.bound))) doorLeft.selected = true; else doorLeft.selected = false; if ((doorLeft.selected) && (CheckCollisionRecs(player.bounds, doorLeft.bound))) { if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorLeft.bound)) || (IsKeyPressed(KEY_SPACE))) { if (doorLeft.locked) { doorLeft.frameRec.y = 0; doorLeft.locked = false; PlaySound(sndDoor); } else finishScreen = 1; } } // Door: center if ((CheckCollisionPointRec(GetMousePosition(), doorCenter.bound)) || (CheckCollisionRecs(player.bounds, doorCenter.bound))) doorCenter.selected = true; else doorCenter.selected = false; if ((doorCenter.selected) && (CheckCollisionRecs(player.bounds, doorCenter.bound))) { if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorCenter.bound)) || (IsKeyPressed(KEY_SPACE))) { if (doorCenter.locked) { doorCenter.frameRec.y = 0; doorCenter.locked = false; PlaySound(sndDoor); } else finishScreen = 2; } } } if (msgState > 2) { UpdatePlayer(); // Monsters logic UpdateMonster(&candle); UpdateMonster(&picture); UpdateMonster(&phone); } // Check player hover monsters to interact if (((CheckCollisionRecs(player.bounds, candle.bounds)) && !candle.active) || ((CheckCollisionRecs(player.bounds, picture.bounds)) && !picture.active) || ((CheckCollisionRecs(player.bounds, phone.bounds)) && !phone.active)) monsterHover = true; else monsterHover = false; // Monters logic: candle if ((CheckCollisionRecs(player.bounds, candle.bounds)) && !candle.active) { candle.selected = true; if ((IsKeyPressed(KEY_SPACE)) || ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), candle.bounds)))) { SearchKeyPlayer(); searching = true; framesCounter = 0; monsterCheck = 1; } } else candle.selected = false; // Monters logic: picture if ((CheckCollisionRecs(player.bounds, picture.bounds)) && !picture.active) { picture.selected = true; if ((IsKeyPressed(KEY_SPACE)) || ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), picture.bounds)))) { SearchKeyPlayer(); searching = true; framesCounter = 0; monsterCheck = 2; } } else picture.selected = false; // Monters logic: phone if ((CheckCollisionRecs(player.bounds, phone.bounds)) && !phone.active) { phone.selected = true; if ((IsKeyPressed(KEY_SPACE)) || ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), phone.bounds)))) { SearchKeyPlayer(); searching = true; framesCounter = 0; monsterCheck = 3; } } else phone.selected = false; if (searching) { framesCounter++; if (framesCounter > 180) { if (monsterCheck == 1) { if (candle.spooky) { ScarePlayer(); PlaySound(sndScream); } else FindKeyPlayer(); candle.active = true; candle.selected = false; } else if (monsterCheck == 2) { if (picture.spooky) { ScarePlayer(); PlaySound(sndScream); } else FindKeyPlayer(); picture.active = true; picture.selected = false; } else if (monsterCheck == 3) { if (phone.spooky) { ScarePlayer(); PlaySound(sndScream); } else FindKeyPlayer(); phone.active = true; phone.selected = false; } searching = false; framesCounter = 0; } } // Text animation framesCounter++; if ((framesCounter%2) == 0) lettersCounter++; if (msgState == 0) { if (lettersCounter <= (int)strlen(message)) strncpy(msgBuffer, message, lettersCounter); else { for (int i = 0; i < (int)strlen(msgBuffer); i++) msgBuffer[i] = '\0'; lettersCounter = 0; msgState = 1; } if (IsKeyPressed(KEY_ENTER)) msgState = 1; } else if (msgState == 1) { msgCounter++; if ((IsKeyPressed(KEY_ENTER)) || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) { msgState = 2; msgCounter = 0; } } else if (msgState == 2) { msgCounter++; if (msgCounter > 180) msgState = 3; } else msgCounter++; }
// Gameplay Screen Update logic void UpdateAtticScreen(void) { if (player.key) { // Door: right if ((CheckCollisionPointRec(GetMousePosition(), doorRight.bound)) || (CheckCollisionRecs(player.bounds, doorRight.bound))) doorRight.selected = true; else doorRight.selected = false; if ((doorRight.selected) && (CheckCollisionRecs(player.bounds, doorRight.bound))) { if (((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && CheckCollisionPointRec(GetMousePosition(), doorRight.bound)) || (IsKeyPressed(KEY_SPACE))) { if (doorRight.locked) { doorRight.frameRec.y = 0; doorRight.locked = false; PlaySound(sndDoor); } else finishScreen = 1; } } } if (msgState > 2) { UpdatePlayer(); // Monsters logic UpdateMonster(&lamp); UpdateMonster(&arc); } // Check player hover monsters to interact if (((CheckCollisionRecs(player.bounds, lamp.bounds)) && !lamp.active) || ((CheckCollisionRecs(player.bounds, arc.bounds)) && !arc.active)) monsterHover = true; else monsterHover = false; // Monters logic: lamp if ((CheckCollisionRecs(player.bounds, lamp.bounds)) && !lamp.active) { lamp.selected = true; if ((IsKeyPressed(KEY_SPACE)) || ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), lamp.bounds)))) { SearchKeyPlayer(); searching = true; framesCounter = 0; monsterCheck = 1; } } else lamp.selected = false; // Monters logic: arc if ((CheckCollisionRecs(player.bounds, arc.bounds)) && !arc.active) { arc.selected = true; if ((IsKeyPressed(KEY_SPACE)) || ((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), arc.bounds)))) { SearchKeyPlayer(); searching = true; framesCounter = 0; monsterCheck = 2; } } else arc.selected = false; if (searching) { framesCounter++; if (framesCounter > 180) { if (monsterCheck == 1) { if (lamp.spooky) { ScarePlayer(); PlaySound(sndScream); } else FindKeyPlayer(); lamp.active = true; lamp.selected = false; } else if (monsterCheck == 2) { if (arc.spooky) { ScarePlayer(); PlaySound(sndScream); } else FindKeyPlayer(); arc.active = true; arc.selected = false; } searching = false; framesCounter = 0; } } // Text animation framesCounter++; if ((framesCounter%2) == 0) lettersCounter++; if (msgState == 0) { if (lettersCounter <= (int)strlen(message)) strncpy(msgBuffer, message, lettersCounter); else { for (int i = 0; i < (int)strlen(msgBuffer); i++) msgBuffer[i] = '\0'; lettersCounter = 0; msgState = 1; } if (IsKeyPressed(KEY_ENTER)) msgState = 1; } else if (msgState == 1) { msgCounter++; if ((IsKeyPressed(KEY_ENTER)) || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) { msgState = 2; msgCounter = 0; } } else if (msgState == 2) { msgCounter++; if (msgCounter > 180) msgState = 3; } else msgCounter++; if (IsKeyPressed('M')) { finishScreen = 1; } }