Added game sources: Skully Escape

This game was developed for King GameJam 2015
This commit is contained in:
raysan5
2016-02-07 11:09:12 +01:00
parent 4fae37bb88
commit 4a3509f06d
48 changed files with 4549 additions and 0 deletions

View File

@ -0,0 +1,409 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#include "raylib.h"
#include "screens.h"
#include "../player.h"
#include "../monster.h"
#include <string.h>
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
// Gameplay screen global variables
static int framesCounter;
static int finishScreen;
static Texture2D background;
// Declare doors
static Door doorRight;
static Door doorCenter;
static Door doorLeft;
// Decalre monsters
static Monster lamp;
static Monster picture;
static bool monsterHover = false;
static int monsterCheck = -1; // Identify checking monster
static const char message[256] = "WHO IS THERE???\nANYBODY IN THE ROOM???";
static int msgPosX = 100;
static int msgState = 0; // 0-writting, 1-wait, 2-choose
static int lettersCounter = 0;
static char msgBuffer[256] = { '\0' };
static int msgCounter = 0;
static bool searching = false;
static int scroll = 0;
//----------------------------------------------------------------------------------
// Gameplay Screen Functions Definition
//----------------------------------------------------------------------------------
// Gameplay Screen Initialization logic
void InitAisle01Screen(void)
{
ResetPlayer();
// Reset Screen variables
monsterHover = false;
monsterCheck = -1;
msgState = 0;
msgCounter = 0;
lettersCounter = 0;
for (int i = 0; i < 256; i++) msgBuffer[i] = '\0';
framesCounter = 0;
finishScreen = 0;
background = LoadTexture("resources/textures/background_aisle01.png");
scroll = player.position.x - 200;
// Initialize doors
doorLeft.position = (Vector2) { -30, 135 };
doorLeft.facing = 0;
doorLeft.locked = true;
doorLeft.frameRec =(Rectangle) {((doors.width/3)*doorLeft.facing), doors.height/2, doors.width/3, doors.height/2};
doorLeft.bound = (Rectangle) { doorLeft.position.x, doorLeft.position.y, doors.width/3, doors.height/2};
doorLeft.selected = false;
doorCenter.position = (Vector2) { 1115, 104 };
doorCenter.facing = 1;
doorCenter.locked = true;
doorCenter.frameRec =(Rectangle) {((doors.width/3)*doorCenter.facing), doors.height/2, doors.width/3, doors.height/2};
doorCenter.bound = (Rectangle) { doorCenter.position.x, doorCenter.position.y, doors.width/3, doors.height/2};
doorCenter.selected = false;
doorRight.position = (Vector2) { 1710, 140 };
doorRight.facing = 2;
doorRight.locked = true;
doorRight.frameRec =(Rectangle) {((doors.width/3)*doorRight.facing), doors.height/2, doors.width/3, doors.height/2};
doorRight.bound = (Rectangle) { doorRight.position.x, doorRight.position.y, doors.width/3, doors.height/2};
// Monster init: lamp
lamp.position = (Vector2){ 187, 256 };
lamp.texture = LoadTexture("resources/textures/monster_lamp_left.png");
lamp.currentFrame = 0;
lamp.framesCounter = 0;
lamp.numFrames = 4;
lamp.bounds = (Rectangle){ lamp.position.x + 20, lamp.position.y, 90, 380 };
lamp.frameRec = (Rectangle) { 0, 0, lamp.texture.width/lamp.numFrames, lamp.texture.height };
lamp.selected = false;
lamp.active = false;
lamp.spooky = true;
// Monster init: arc
picture.position = (Vector2){ 637, 178 };
picture.texture = LoadTexture("resources/textures/monster_picture.png");
picture.currentFrame = 0;
picture.framesCounter = 0;
picture.numFrames = 4;
picture.bounds = (Rectangle){ picture.position.x + 44, picture.position.y, 174, 256 };
picture.frameRec = (Rectangle) { 0, 0, picture.texture.width/picture.numFrames, picture.texture.height };
picture.selected = false;
picture.active = false;
picture.spooky = false;
}
// 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 Draw logic
void DrawAisle01Screen(void)
{
DrawTexture(background, -scroll, 0, WHITE);
// Draw monsters
DrawMonster(lamp, scroll);
DrawMonster(picture, scroll);
// Draw door
Vector2 doorScrollPos = { doorCenter.position.x - scroll, doorCenter.position.y };
if (doorCenter.selected) DrawTextureRec(doors, doorCenter.frameRec, doorScrollPos, GREEN);
else DrawTextureRec(doors, doorCenter.frameRec, doorScrollPos, WHITE);
doorScrollPos = (Vector2){ doorLeft.position.x - scroll, doorLeft.position.y };
if (doorLeft.selected) DrawTextureRec(doors, doorLeft.frameRec, doorScrollPos, GREEN);
else DrawTextureRec(doors, doorLeft.frameRec, doorScrollPos, WHITE);
doorScrollPos = (Vector2){ doorRight.position.x - scroll, doorRight.position.y };
if (doorRight.selected) DrawTextureRec(doors, doorRight.frameRec, doorScrollPos, GREEN);
else DrawTextureRec(doors, doorRight.frameRec, doorScrollPos, WHITE);
// Draw messsages
if (msgState < 2) DrawRectangle(0, 40, GetScreenWidth(), 200, Fade(LIGHTGRAY, 0.5f));
else if (msgState == 2) DrawRectangle(0, 80, GetScreenWidth(), 100, Fade(LIGHTGRAY, 0.5f));
if (msgState == 0)
{
DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE);
}
else if (msgState == 1)
{
DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE);
if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK);
}
else if (msgState == 2)
{
if ((msgCounter/30)%2)
{
DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE);
DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f));
DrawRectangleRec(picture.bounds, Fade(RED, 0.6f));
}
}
else
{
if ((monsterHover) && ((msgCounter/30)%2))
{
DrawRectangle(0, 0, GetScreenWidth(), 50, Fade(LIGHTGRAY, 0.5f));
DrawText("PRESS SPACE or CLICK to INTERACT", 420, 15, 20, BLACK);
}
}
DrawPlayer(); // NOTE: Also draws mouse pointer!
}
// Gameplay Screen Unload logic
void UnloadAisle01Screen(void)
{
// TODO: Unload GAMEPLAY screen variables here!
UnloadTexture(background);
UnloadMonster(lamp);
UnloadMonster(picture);
}
// Gameplay Screen should finish?
int FinishAisle01Screen(void)
{
return finishScreen;
}

View File

@ -0,0 +1,444 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#include "raylib.h"
#include "screens.h"
#include "../player.h"
#include "../monster.h"
#include <string.h>
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
// Gameplay screen global variables
static int framesCounter;
static int finishScreen;
static Texture2D background;
// Declare doors
static Door doorLeft;
// Decalre monsters
static Monster lamp;
static Monster chair;
static Monster picture;
static Monster arc;
static bool monsterHover = false;
static int monsterCheck = -1; // Identify checking monster
static const char message[256] = "HAS LEGS BUT CAN NOT WALK...\nSEARCH FOR IT TO OPEN THE DOOR!";
static int msgPosX = 100;
static int msgState = 0; // 0-writting, 1-wait, 2-choose
static int lettersCounter = 0;
static char msgBuffer[256] = { '\0' };
static int msgCounter = 0;
static bool searching = false;
static int scroll = 0;
//----------------------------------------------------------------------------------
// Gameplay Screen Functions Definition
//----------------------------------------------------------------------------------
// Gameplay Screen Initialization logic
void InitAisle02Screen(void)
{
ResetPlayer();
// Reset Screen variables
monsterHover = false;
monsterCheck = -1;
msgState = 0;
msgCounter = 0;
lettersCounter = 0;
for (int i = 0; i < 256; i++) msgBuffer[i] = '\0';
framesCounter = 0;
finishScreen = 0;
background = LoadTexture("resources/textures/background_aisle02.png");
scroll = player.position.x - 200;
// Initialize doors
doorLeft.position = (Vector2) { -10, 136 };
doorLeft.facing = 0;
doorLeft.locked = true;
doorLeft.frameRec =(Rectangle) {((doors.width/3)*doorLeft.facing), doors.height/2, doors.width/3, doors.height/2};
doorLeft.bound = (Rectangle) { doorLeft.position.x, doorLeft.position.y, doors.width/3, doors.height/2};
doorLeft.selected = false;
// Monster init: lamp
lamp.position = (Vector2){ 1520, 300 };
lamp.texture = LoadTexture("resources/textures/monster_lamp_right.png");
lamp.currentFrame = 0;
lamp.framesCounter = 0;
lamp.numFrames = 4;
lamp.bounds = (Rectangle){ lamp.position.x + 200, lamp.position.y, 90, 380 };
lamp.frameRec = (Rectangle) { 0, 0, lamp.texture.width/lamp.numFrames, lamp.texture.height };
lamp.selected = false;
lamp.active = false;
lamp.spooky = true;
// Monster init: chair
chair.position = (Vector2){ 1400, 404 };
chair.texture = LoadTexture("resources/textures/monster_chair_right.png");
chair.currentFrame = 0;
chair.framesCounter = 0;
chair.numFrames = 4;
chair.bounds = (Rectangle){ chair.position.x + 50, chair.position.y + 30, 120, 190 };
chair.frameRec = (Rectangle) { 0, 0, chair.texture.width/chair.numFrames, chair.texture.height };
chair.selected = false;
chair.active = false;
chair.spooky = false;
// Monster init: picture
picture.position = (Vector2){ 837, 162 };
picture.texture = LoadTexture("resources/textures/monster_picture.png");
picture.currentFrame = 0;
picture.framesCounter = 0;
picture.numFrames = 4;
picture.bounds = (Rectangle){ picture.position.x + 44, picture.position.y, 174, 264 };
picture.frameRec = (Rectangle) { 0, 0, picture.texture.width/picture.numFrames, picture.texture.height };
picture.selected = false;
picture.active = false;
picture.spooky = true;
// Monster init: arc
arc.position = (Vector2){ 388, 423 };
arc.texture = LoadTexture("resources/textures/monster_arc.png");
arc.currentFrame = 0;
arc.framesCounter = 0;
arc.numFrames = 4;
arc.bounds = (Rectangle){ arc.position.x + 44, arc.position.y + 70, 220, 120 };
arc.frameRec = (Rectangle) { 0, 0, arc.texture.width/arc.numFrames, arc.texture.height };
arc.selected = false;
arc.active = false;
arc.spooky = true;
}
// Gameplay Screen Update logic
void UpdateAisle02Screen(void)
{
// Update doors bounds
doorLeft.bound.x = doorLeft.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;
}
}
}
if (msgState > 2)
{
UpdatePlayer();
// Monsters logic
UpdateMonster(&lamp);
UpdateMonster(&chair);
UpdateMonster(&picture);
UpdateMonster(&arc);
}
// Update monster bounds
lamp.bounds.x = lamp.position.x + 200 - scroll;
chair.bounds.x = chair.position.x + 50 - scroll;
picture.bounds.x = picture.position.x + 44 - scroll;
arc.bounds.x = arc.position.x + 44 - scroll;
// Check player hover monsters to interact
if (((CheckCollisionRecs(player.bounds, lamp.bounds)) && !lamp.active) ||
((CheckCollisionRecs(player.bounds, chair.bounds)) && !chair.active) ||
((CheckCollisionRecs(player.bounds, picture.bounds)) && !picture.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: chair
if ((CheckCollisionRecs(player.bounds, chair.bounds)) && !chair.active)
{
chair.selected = true;
if ((IsKeyPressed(KEY_SPACE)) ||
((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), chair.bounds))))
{
SearchKeyPlayer();
searching = true;
framesCounter = 0;
monsterCheck = 2;
}
}
else chair.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 = 3;
}
}
else picture.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 = 4;
}
}
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 (chair.spooky)
{
ScarePlayer();
PlaySound(sndScream);
}
else FindKeyPlayer();
chair.active = true;
chair.selected = false;
}
else if (monsterCheck == 3)
{
if (picture.spooky)
{
ScarePlayer();
PlaySound(sndScream);
}
else FindKeyPlayer();
picture.active = true;
picture.selected = false;
}
else if (monsterCheck == 4)
{
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 (player.position.x > 200)
{
scroll = player.position.x - 200;
if (scroll > 620) scroll = 620;
}
}
// Gameplay Screen Draw logic
void DrawAisle02Screen(void)
{
DrawTexture(background, -scroll, 0, WHITE);
// Draw monsters
DrawMonster(lamp, scroll);
DrawMonster(arc, scroll);
DrawMonster(picture, scroll);
DrawMonster(chair, scroll);
// Draw door
Vector2 doorScrollPos = { doorLeft.position.x - scroll, doorLeft.position.y };
if (doorLeft.selected) DrawTextureRec(doors, doorLeft.frameRec, doorScrollPos, GREEN);
else DrawTextureRec(doors, doorLeft.frameRec, doorScrollPos, WHITE);
// Draw messsages
if (msgState < 2) DrawRectangle(0, 40, GetScreenWidth(), 200, Fade(LIGHTGRAY, 0.5f));
else if (msgState == 2) DrawRectangle(0, 80, GetScreenWidth(), 100, Fade(LIGHTGRAY, 0.5f));
if (msgState == 0)
{
DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE);
}
else if (msgState == 1)
{
DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE);
if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK);
}
else if (msgState == 2)
{
if ((msgCounter/30)%2)
{
DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE);
DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f));
DrawRectangleRec(arc.bounds, Fade(RED, 0.6f));
DrawRectangleRec(chair.bounds, Fade(RED, 0.6f));
DrawRectangleRec(picture.bounds, Fade(RED, 0.6f));
}
}
else
{
if ((monsterHover) && ((msgCounter/30)%2))
{
DrawRectangle(0, 0, GetScreenWidth(), 50, Fade(LIGHTGRAY, 0.5f));
DrawText("PRESS SPACE or CLICK to INTERACT", 420, 15, 20, BLACK);
}
}
DrawPlayer(); // NOTE: Also draws mouse pointer!
}
// Gameplay Screen Unload logic
void UnloadAisle02Screen(void)
{
// TODO: Unload GAMEPLAY screen variables here!
UnloadTexture(background);
UnloadMonster(lamp);
UnloadMonster(chair);
UnloadMonster(picture);
UnloadMonster(arc);
}
// Gameplay Screen should finish?
int FinishAisle02Screen(void)
{
return finishScreen;
}

View File

@ -0,0 +1,404 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#include "raylib.h"
#include "screens.h"
#include "../player.h"
#include "../monster.h"
#include <string.h>
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
// Gameplay screen global variables
static int framesCounter;
static int finishScreen;
static Texture2D background;
// Declare doors
static Door doorLeft;
static Door doorRight;
// Decalre monsters
static Monster blazon01;
static Monster blazon02;
static Monster blazon03;
static bool monsterHover = false;
static int monsterCheck = -1; // Identify checking monster
static const char message[256] = "NO MORE TIPS...\nFOLLOW YOUR INSTINCT!";
static int msgPosX = 100;
static int msgState = 0; // 0-writting, 1-wait, 2-choose
static int lettersCounter = 0;
static char msgBuffer[256] = { '\0' };
static int msgCounter = 0;
static bool searching = false;
//----------------------------------------------------------------------------------
// Gameplay Screen Functions Definition
//----------------------------------------------------------------------------------
// Gameplay Screen Initialization logic
void InitArmoryScreen(void)
{
ResetPlayer();
// Reset Screen variables
monsterHover = false;
monsterCheck = -1;
msgState = 0;
msgCounter = 0;
lettersCounter = 0;
for (int i = 0; i < 256; i++) msgBuffer[i] = '\0';
framesCounter = 0;
finishScreen = 0;
background = LoadTexture("resources/textures/background_armory.png");
// Initialize doors
doorLeft.position = (Vector2) { -50, 145 };
doorLeft.facing = 0;
doorLeft.locked = true;
doorLeft.frameRec =(Rectangle) {((doors.width/3)*doorLeft.facing), doors.height/2, doors.width/3, doors.height/2};
doorLeft.bound = (Rectangle) { doorLeft.position.x, doorLeft.position.y, doors.width/3, doors.height/2};
doorLeft.selected = false;
doorRight.position = (Vector2) { 1074, 140 };
doorRight.facing = 2;
doorRight.locked = true;
doorRight.frameRec =(Rectangle) {((doors.width/3)*doorRight.facing), doors.height/2, doors.width/3, doors.height/2};
doorRight.bound = (Rectangle) { doorRight.position.x, doorRight.position.y, doors.width/3, doors.height/2};
doorRight.selected = false;
// Monster init: blazon01
blazon01.position = (Vector2){ 300, 260 };
blazon01.texture = LoadTexture("resources/textures/monster_blazon01.png");
blazon01.currentFrame = 0;
blazon01.framesCounter = 0;
blazon01.numFrames = 4;
blazon01.bounds = (Rectangle){ blazon01.position.x, blazon01.position.y + 20, 160, 230 };
blazon01.frameRec = (Rectangle) { 0, 0, blazon01.texture.width/blazon01.numFrames, blazon01.texture.height };
blazon01.selected = false;
blazon01.active = false;
blazon01.spooky = true;
// Monster init: blazon02
blazon02.position = (Vector2){ 550, 260 };
blazon02.texture = LoadTexture("resources/textures/monster_blazon02.png");
blazon02.currentFrame = 0;
blazon02.framesCounter = 0;
blazon02.numFrames = 4;
blazon02.bounds = (Rectangle){ blazon02.position.x, blazon02.position.y + 20, 160, 230 };
blazon02.frameRec = (Rectangle) { 0, 0, blazon02.texture.width/blazon02.numFrames, blazon02.texture.height };
blazon02.selected = false;
blazon02.active = false;
blazon02.spooky = true;
// Monster init: blazon03
blazon03.position = (Vector2){ 800, 260 };
blazon03.texture = LoadTexture("resources/textures/monster_blazon03.png");
blazon03.currentFrame = 0;
blazon03.framesCounter = 0;
blazon03.numFrames = 4;
blazon03.bounds = (Rectangle){ blazon03.position.x, blazon03.position.y + 20, 160, 230 };
blazon03.frameRec = (Rectangle) { 0, 0, blazon03.texture.width/blazon03.numFrames, blazon03.texture.height };
blazon03.selected = false;
blazon03.active = false;
blazon03.spooky = false;
}
// Gameplay Screen Update logic
void UpdateArmoryScreen(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: 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 = 2;
}
}
}
if (msgState > 2)
{
UpdatePlayer();
// Monsters logic
UpdateMonster(&blazon01);
UpdateMonster(&blazon02);
UpdateMonster(&blazon03);
}
// Check player hover monsters to interact
if (((CheckCollisionRecs(player.bounds, blazon01.bounds)) && !blazon01.active) ||
((CheckCollisionRecs(player.bounds, blazon02.bounds)) && !blazon02.active) ||
((CheckCollisionRecs(player.bounds, blazon03.bounds)) && !blazon03.active)) monsterHover = true;
else monsterHover = false;
// Monters logic: blazon01
if ((CheckCollisionRecs(player.bounds, blazon01.bounds)) && !blazon01.active)
{
blazon01.selected = true;
if ((IsKeyPressed(KEY_SPACE)) ||
((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), blazon01.bounds))))
{
SearchKeyPlayer();
searching = true;
framesCounter = 0;
monsterCheck = 1;
}
}
else blazon01.selected = false;
// Monters logic: blazon02
if ((CheckCollisionRecs(player.bounds, blazon02.bounds)) && !blazon02.active)
{
blazon02.selected = true;
if ((IsKeyPressed(KEY_SPACE)) ||
((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), blazon02.bounds))))
{
SearchKeyPlayer();
searching = true;
framesCounter = 0;
monsterCheck = 2;
}
}
else blazon02.selected = false;
// Monters logic: blazon03
if ((CheckCollisionRecs(player.bounds, blazon03.bounds)) && !blazon03.active)
{
blazon03.selected = true;
if ((IsKeyPressed(KEY_SPACE)) ||
((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), blazon03.bounds))))
{
SearchKeyPlayer();
searching = true;
framesCounter = 0;
monsterCheck = 3;
}
}
else blazon03.selected = false;
if (searching)
{
framesCounter++;
if (framesCounter > 180)
{
if (monsterCheck == 1)
{
if (blazon01.spooky)
{
ScarePlayer();
PlaySound(sndScream);
}
else FindKeyPlayer();
blazon01.active = true;
blazon01.selected = false;
}
else if (monsterCheck == 2)
{
if (blazon02.spooky)
{
ScarePlayer();
PlaySound(sndScream);
}
else FindKeyPlayer();
blazon02.active = true;
blazon02.selected = false;
}
else if (monsterCheck == 3)
{
if (blazon03.spooky)
{
ScarePlayer();
PlaySound(sndScream);
}
else FindKeyPlayer();
blazon03.active = true;
blazon03.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 Draw logic
void DrawArmoryScreen(void)
{
DrawTexture(background, 0, 0, WHITE);
// Draw monsters
DrawMonster(blazon01, 0);
DrawMonster(blazon02, 0);
DrawMonster(blazon03, 0);
// Draw door
if (doorLeft.selected) DrawTextureRec(doors, doorLeft.frameRec, doorLeft.position, GREEN);
else DrawTextureRec(doors, doorLeft.frameRec, doorLeft.position, WHITE);
if (doorRight.selected) DrawTextureRec(doors, doorRight.frameRec, doorRight.position, GREEN);
else DrawTextureRec(doors, doorRight.frameRec, doorRight.position, WHITE);
// Draw messsages
if (msgState < 2) DrawRectangle(0, 40, GetScreenWidth(), 200, Fade(LIGHTGRAY, 0.5f));
else if (msgState == 2) DrawRectangle(0, 80, GetScreenWidth(), 100, Fade(LIGHTGRAY, 0.5f));
if (msgState == 0)
{
DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE);
}
else if (msgState == 1)
{
DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE);
if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK);
}
else if (msgState == 2)
{
if ((msgCounter/30)%2)
{
DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE);
DrawRectangleRec(blazon01.bounds, Fade(RED, 0.6f));
DrawRectangleRec(blazon02.bounds, Fade(RED, 0.6f));
DrawRectangleRec(blazon03.bounds, Fade(RED, 0.6f));
}
}
else
{
if ((monsterHover) && ((msgCounter/30)%2))
{
DrawRectangle(0, 0, GetScreenWidth(), 50, Fade(LIGHTGRAY, 0.5f));
DrawText("PRESS SPACE or CLICK to INTERACT", 420, 15, 20, BLACK);
}
}
DrawPlayer(); // NOTE: Also draws mouse pointer!
}
// Gameplay Screen Unload logic
void UnloadArmoryScreen(void)
{
// TODO: Unload GAMEPLAY screen variables here!
UnloadTexture(background);
UnloadMonster(blazon01);
UnloadMonster(blazon02);
UnloadMonster(blazon03);
}
// Gameplay Screen should finish?
int FinishArmoryScreen(void)
{
return finishScreen;
}

View File

@ -0,0 +1,332 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#include "raylib.h"
#include "screens.h"
#include "../player.h"
#include "../monster.h"
#include <string.h>
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
// Gameplay screen global variables
static int framesCounter;
static int finishScreen;
static Texture2D background;
// Declare doors
static Door doorRight;
// Decalre monsters
static Monster lamp;
static Monster arc;
static bool monsterHover;
static int monsterCheck; // Identify checking monster
static const char message[256] = "YOUR PARENTS ARE GONE! TIME TO ESCAPE!\nTHE DOOR IS LOCKED... TURN ON THE LIGHTS! ;)";
static int msgPosX = 100;
static int msgState = 0; // 0-writting, 1-wait, 2-choose
static int lettersCounter = 0;
static char msgBuffer[256] = { '\0' };
static int msgCounter = 0;
static bool searching = false;
//----------------------------------------------------------------------------------
// Gameplay Screen Functions Definition
//----------------------------------------------------------------------------------
// Gameplay Screen Initialization logic
void InitAtticScreen(void)
{
ResetPlayer();
// Reset Screen variables
monsterHover = false;
monsterCheck = -1;
msgState = 0;
msgCounter = 0;
lettersCounter = 0;
for (int i = 0; i < 256; i++) msgBuffer[i] = '\0';
framesCounter = 0;
finishScreen = 0;
background = LoadTexture("resources/textures/background_attic.png");
// Initialize doors
doorRight.position = (Vector2) { 1074, 140 };
doorRight.facing = 2;
doorRight.locked = true;
doorRight.frameRec =(Rectangle) {((doors.width/3)*doorRight.facing), doors.height/2, doors.width/3, doors.height/2};
doorRight.bound = (Rectangle) { doorRight.position.x, doorRight.position.y, doors.width/3, doors.height/2};
doorRight.selected = false;
// Monster init: lamp
lamp.position = (Vector2){ 50, 316 };
lamp.texture = LoadTexture("resources/textures/monster_lamp_left.png");
lamp.currentFrame = 0;
lamp.framesCounter = 0;
lamp.numFrames = 4;
lamp.bounds = (Rectangle){ lamp.position.x + 20, lamp.position.y, 90, 380 };
lamp.frameRec = (Rectangle) { 0, 0, lamp.texture.width/lamp.numFrames, lamp.texture.height };
lamp.selected = false;
lamp.active = false;
lamp.spooky = false;
// Monster init: arc
arc.position = (Vector2){ 760, 430 };
arc.texture = LoadTexture("resources/textures/monster_arc.png");
arc.currentFrame = 0;
arc.framesCounter = 0;
arc.numFrames = 4;
arc.bounds = (Rectangle){ arc.position.x + 44, arc.position.y + 70, 220, 120 };
arc.frameRec = (Rectangle) { 0, 0, arc.texture.width/arc.numFrames, arc.texture.height };
arc.selected = false;
arc.active = false;
arc.spooky = true;
}
// 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;
}
}
// Gameplay Screen Draw logic
void DrawAtticScreen(void)
{
DrawTexture(background, 0, 0, WHITE);
// Draw monsters
DrawMonster(lamp, 0);
DrawMonster(arc, 0);
// Draw door
if (doorRight.selected) DrawTextureRec(doors, doorRight.frameRec, doorRight.position, GREEN);
else DrawTextureRec(doors, doorRight.frameRec, doorRight.position, WHITE);
// Draw messsages
if (msgState < 2) DrawRectangle(0, 40, GetScreenWidth(), 200, Fade(LIGHTGRAY, 0.5f));
else if (msgState == 2) DrawRectangle(0, 80, GetScreenWidth(), 100, Fade(LIGHTGRAY, 0.5f));
if (msgState == 0)
{
DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE);
}
else if (msgState == 1)
{
DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE);
if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK);
}
else if (msgState == 2)
{
if ((msgCounter/30)%2)
{
DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE);
DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f));
DrawRectangleRec(arc.bounds, Fade(RED, 0.6f));
}
}
else
{
if ((monsterHover) && ((msgCounter/30)%2))
{
DrawRectangle(0, 0, GetScreenWidth(), 50, Fade(LIGHTGRAY, 0.5f));
DrawText("PRESS SPACE or CLICK to INTERACT", 420, 15, 20, BLACK);
}
}
DrawPlayer(); // NOTE: Also draws mouse pointer!
}
// Gameplay Screen Unload logic
void UnloadAtticScreen(void)
{
// TODO: Unload GAMEPLAY screen variables here!
UnloadTexture(background);
UnloadMonster(lamp);
UnloadMonster(arc);
}
// Gameplay Screen should finish?
int FinishAtticScreen(void)
{
return finishScreen;
}

View File

@ -0,0 +1,383 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#include "raylib.h"
#include "screens.h"
#include "../player.h"
#include "../monster.h"
#include <string.h>
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
// Gameplay screen global variables
static int framesCounter;
static int finishScreen;
static Texture2D background;
// Declare doors
static Door doorRight;
// Decalre monst
static Monster lamp;
static Monster chair;
static Monster mirror;
static bool monsterHover = false;
static int monsterCheck = -1; // Identify checking monster
static const char message[256] = "TRICK OR TREAT! WHO IS THE MOST BEAUTIFUL\nSKELETON IN THE WORLD?";
static int msgPosX = 100;
static int msgState = 0; // 0-writting, 1-wait, 2-choose
static int lettersCounter = 0;
static char msgBuffer[256] = { '\0' };
static int msgCounter = 0;
static bool searching = false;
//----------------------------------------------------------------------------------
// Gameplay Screen Functions Definition
//----------------------------------------------------------------------------------
// Gameplay Screen Initialization logic
void InitBathroomScreen(void)
{
ResetPlayer();
// Reset Screen variables
monsterHover = false;
monsterCheck = -1;
msgState = 0;
msgCounter = 0;
lettersCounter = 0;
for (int i = 0; i < 256; i++) msgBuffer[i] = '\0';
framesCounter = 0;
finishScreen = 0;
background = LoadTexture("resources/textures/background_bathroom.png");
// Reset Screen variables
monsterHover = false;
monsterCheck = -1;
msgState = 0;
msgCounter = 0;
lettersCounter = 0;
for (int i = 0; i < 256; i++) msgBuffer[i] = '\0';
// Initialize doors
doorRight.position = (Vector2) { 1070, 135 };
doorRight.facing = 2;
doorRight.locked = true;
doorRight.frameRec =(Rectangle) {((doors.width/3)*doorRight.facing), doors.height/2, doors.width/3, doors.height/2};
doorRight.bound = (Rectangle) { doorRight.position.x, doorRight.position.y, doors.width/3, doors.height/2};
doorRight.selected = false;
// Monster init: lamp
lamp.position = (Vector2){ 35, 334 };
lamp.texture = LoadTexture("resources/textures/monster_lamp_left.png");
lamp.currentFrame = 0;
lamp.framesCounter = 0;
lamp.numFrames = 4;
lamp.bounds = (Rectangle){ lamp.position.x + 20, lamp.position.y + 0, 90, 380};
lamp.frameRec = (Rectangle) { 0, 0, lamp.texture.width/lamp.numFrames, lamp.texture.height };
lamp.selected = false;
lamp.active = false;
lamp.spooky = true;
// Monster init: mirror
mirror.position = (Vector2){ 300, 200 };
mirror.texture = LoadTexture("resources/textures/monster_mirror.png");
mirror.currentFrame = 0;
mirror.framesCounter = 0;
mirror.numFrames = 4;
mirror.bounds = (Rectangle){ mirror.position.x + 40, mirror.position.y + 20, 190, 200 };
mirror.frameRec = (Rectangle) { 0, 0, mirror.texture.width/mirror.numFrames, mirror.texture.height };
mirror.selected = false;
mirror.active = false;
mirror.spooky = false;
// Monster init: chair
chair.position = (Vector2){ 760, 430 };
chair.texture = LoadTexture("resources/textures/monster_chair_right.png");
chair.currentFrame = 0;
chair.framesCounter = 0;
chair.numFrames = 4;
chair.bounds = (Rectangle){ chair.position.x + 30, chair.position.y + 30, 120, 190 };
chair.frameRec = (Rectangle) { 0, 0, chair.texture.width/chair.numFrames, chair.texture.height };
chair.selected = false;
chair.active = false;
chair.spooky = true;
}
// Gameplay Screen Update logic
void UpdateBathroomScreen(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(&mirror);
UpdateMonster(&chair);
}
// Check player hover monsters to interact
if (((CheckCollisionRecs(player.bounds, lamp.bounds)) && !lamp.active) ||
((CheckCollisionRecs(player.bounds, mirror.bounds)) && !mirror.active) ||
((CheckCollisionRecs(player.bounds, chair.bounds)) && !chair.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: mirror
if ((CheckCollisionRecs(player.bounds, mirror.bounds)) && !mirror.active)
{
mirror.selected = true;
if ((IsKeyPressed(KEY_SPACE)) ||
((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), mirror.bounds))))
{
SearchKeyPlayer();
searching = true;
framesCounter = 0;
monsterCheck = 2;
}
}
else mirror.selected = false;
// Monters logic: chair
if ((CheckCollisionRecs(player.bounds, chair.bounds)) && !chair.active)
{
chair.selected = true;
if ((IsKeyPressed(KEY_SPACE)) ||
((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), chair.bounds))))
{
SearchKeyPlayer();
searching = true;
framesCounter = 0;
monsterCheck = 3;
}
}
else chair.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 (mirror.spooky)
{
ScarePlayer();
PlaySound(sndScream);
}
else FindKeyPlayer();
mirror.active = true;
mirror.selected = false;
}
else if (monsterCheck == 3)
{
if (chair.spooky)
{
ScarePlayer();
PlaySound(sndScream);
}
else FindKeyPlayer();
chair.active = true;
chair.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 Draw logic
void DrawBathroomScreen(void)
{
DrawTexture(background, 0, 0, WHITE);
// Draw monsters
DrawMonster(lamp, 0);
DrawMonster(mirror, 0);
DrawMonster(chair, 0);
// Draw door
if (doorRight.selected) DrawTextureRec(doors, doorRight.frameRec, doorRight.position, GREEN);
else DrawTextureRec(doors, doorRight.frameRec, doorRight.position, WHITE);
// Draw messsages
if (msgState < 2) DrawRectangle(0, 40, GetScreenWidth(), 200, Fade(LIGHTGRAY, 0.5f));
else if (msgState == 2) DrawRectangle(0, 80, GetScreenWidth(), 100, Fade(LIGHTGRAY, 0.5f));
if (msgState == 0)
{
DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE);
}
else if (msgState == 1)
{
DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE);
if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK);
}
else if (msgState == 2)
{
if ((msgCounter/30)%2)
{
DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE);
DrawRectangleRec(lamp.bounds, Fade(RED, 0.6f));
DrawRectangleRec(mirror.bounds, Fade(RED, 0.6f));
DrawRectangleRec(chair.bounds, Fade(RED, 0.6f));
}
}
else
{
if ((monsterHover) && ((msgCounter/30)%2))
{
DrawRectangle(0, 0, GetScreenWidth(), 50, Fade(LIGHTGRAY, 0.5f));
DrawText("PRESS SPACE or CLICK to INTERACT", 420, 15, 20, BLACK);
}
}
DrawPlayer(); // NOTE: Also draws mouse pointer!
}
// Gameplay Screen Unload logic
void UnloadBathroomScreen(void)
{
// TODO: Unload GAMEPLAY screen variables here!
UnloadTexture(background);
UnloadMonster(lamp);
UnloadMonster(chair);
UnloadMonster(mirror);
}
// Gameplay Screen should finish?
int FinishBathroomScreen(void)
{
return finishScreen;
}

View File

@ -0,0 +1,90 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Ending Screen Functions Definitions (Init, Update, Draw, Unload)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#include "raylib.h"
#include "screens.h"
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
// Ending screen global variables
static int framesCounter;
static int finishScreen;
static float alpha = 0.0f;
//----------------------------------------------------------------------------------
// Ending Screen Functions Definition
//----------------------------------------------------------------------------------
// Ending Screen Initialization logic
void InitEndingScreen(void)
{
// TODO: Initialize ENDING screen variables here!
framesCounter = 0;
finishScreen = 0;
alpha = 0.0f;
}
// Ending Screen Update logic
void UpdateEndingScreen(void)
{
// TODO: Update ENDING screen variables here!
framesCounter++;
alpha += 0.005f;
if (alpha >= 1.0f) alpha = 1.0f;
// Press enter to change to ATTIC screen
if ((IsKeyPressed(KEY_ENTER)) || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)))
{
finishScreen = 1;
}
}
// Ending Screen Draw logic
void DrawEndingScreen(void)
{
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), DARKGRAY);
DrawTextEx(font, "CONGRATULATIONS!", (Vector2){ 50, 160 }, font.size*3, 2, Fade(WHITE, alpha));
DrawTextEx(font, "SKULLY ESCAPED!", (Vector2){ 100, 300 }, font.size*3, 2, Fade(WHITE, alpha));
if ((framesCounter > 180) && ((framesCounter/40)%2)) DrawText("PRESS ENTER or CLICK", 380, 545, 40, BLACK);
}
// Ending Screen Unload logic
void UnloadEndingScreen(void)
{
// TODO: Unload ENDING screen variables here!
}
// Ending Screen should finish?
int FinishEndingScreen(void)
{
return finishScreen;
}

View File

@ -0,0 +1,403 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#include "raylib.h"
#include "screens.h"
#include "../player.h"
#include "../monster.h"
#include <string.h>
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
// Gameplay screen global variables
static int framesCounter;
static int finishScreen;
static Texture2D background;
// Declare doors
static Door doorLeft;
static Door doorRight;
// Decalre monsters
static Monster closet;
static Monster chair;
static Monster window;
static bool monsterHover = false;
static int monsterCheck = -1; // Identify checking monster
static const char message[256] = "QUITE BORING AROUND...\nANY BETTER ENTERTAINING?";
static int msgPosX = 100;
static int msgState = 0; // 0-writting, 1-wait, 2-choose
static int lettersCounter = 0;
static char msgBuffer[256] = { '\0' };
static int msgCounter = 0;
static bool searching = false;
//----------------------------------------------------------------------------------
// Gameplay Screen Functions Definition
//----------------------------------------------------------------------------------
// Gameplay Screen Initialization logic
void InitKitchenScreen(void)
{
ResetPlayer();
// Reset Screen variables
monsterHover = false;
monsterCheck = -1;
msgState = 0;
msgCounter = 0;
lettersCounter = 0;
for (int i = 0; i < 256; i++) msgBuffer[i] = '\0';
framesCounter = 0;
finishScreen = 0;
background = LoadTexture("resources/textures/background_kitchen.png");
// Initialize doors
doorLeft.position = (Vector2) { -45, 136 };
doorLeft.facing = 0;
doorLeft.locked = true;
doorLeft.frameRec =(Rectangle) {((doors.width/3)*doorLeft.facing), doors.height/2, doors.width/3, doors.height/2};
doorLeft.bound = (Rectangle) { doorLeft.position.x, doorLeft.position.y, doors.width/3, doors.height/2};
doorLeft.selected = false;
doorRight.position = (Vector2) { 1090, 148 };
doorRight.facing = 2;
doorRight.locked = true;
doorRight.frameRec =(Rectangle) {((doors.width/3)*doorRight.facing), doors.height/2, doors.width/3, doors.height/2};
doorRight.bound = (Rectangle) { doorRight.position.x, doorRight.position.y, doors.width/3, doors.height/2};
doorRight.selected = false;
// Monster init: lamp
closet.position = (Vector2){ 280, 260 };
closet.texture = LoadTexture("resources/textures/monster_closet.png");
closet.currentFrame = 0;
closet.framesCounter = 0;
closet.numFrames = 4;
closet.bounds = (Rectangle){ closet.position.x + 100, closet.position.y+25, 272,348 };
closet.frameRec = (Rectangle) { 0, 0, closet.texture.width/closet.numFrames, closet.texture.height };
closet.selected = false;
closet.active = false;
closet.spooky = true;
// Monster init: chair
chair.position = (Vector2){ 230, 410 };
chair.texture = LoadTexture("resources/textures/monster_chair_left.png");
chair.currentFrame = 0;
chair.framesCounter = 0;
chair.numFrames = 4;
chair.bounds = (Rectangle){ chair.position.x + 30, chair.position.y + 60, 100, 160 };
chair.frameRec = (Rectangle) { 0, 0, chair.texture.width/chair.numFrames, chair.texture.height };
chair.selected = false;
chair.active = false;
chair.spooky = true;
// Monster init: window
window.position = (Vector2){ 715, 88 };
window.texture = LoadTexture("resources/textures/monster_window.png");
window.currentFrame = 0;
window.framesCounter = 0;
window.numFrames = 4;
window.bounds = (Rectangle){ window.position.x + 100, window.position.y + 10, 200, 370 };
window.frameRec = (Rectangle) { 0, 0, window.texture.width/window.numFrames, window.texture.height };
window.selected = false;
window.active = false;
window.spooky = false;
}
// Gameplay Screen Update logic
void UpdateKitchenScreen(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: 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 = 2;
}
}
}
if (msgState > 2)
{
UpdatePlayer();
// Monsters logic
UpdateMonster(&closet);
UpdateMonster(&chair);
UpdateMonster(&window);
}
// Check player hover monsters to interact
if (((CheckCollisionRecs(player.bounds, closet.bounds)) && !closet.active) ||
((CheckCollisionRecs(player.bounds, window.bounds)) && !window.active)) monsterHover = true;
else monsterHover = false;
// Monters logic: closet
if ((CheckCollisionRecs(player.bounds, closet.bounds)) && !closet.active)
{
closet.selected = true;
if ((IsKeyPressed(KEY_SPACE)) ||
((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), closet.bounds))))
{
SearchKeyPlayer();
searching = true;
framesCounter = 0;
monsterCheck = 1;
}
}
else closet.selected = false;
// Monters logic: chair
if ((CheckCollisionRecs(player.bounds, chair.bounds)) && !chair.active)
{
chair.selected = true;
if ((IsKeyPressed(KEY_SPACE)) ||
((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), chair.bounds))))
{
SearchKeyPlayer();
searching = true;
framesCounter = 0;
monsterCheck = 2;
}
}
else chair.selected = false;
// Monters logic: window
if ((CheckCollisionRecs(player.bounds, window.bounds)) && !window.active)
{
window.selected = true;
if ((IsKeyPressed(KEY_SPACE)) ||
((IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) && (CheckCollisionPointRec(GetMousePosition(), window.bounds))))
{
SearchKeyPlayer();
searching = true;
framesCounter = 0;
monsterCheck = 3;
}
}
else window.selected = false;
if (searching)
{
framesCounter++;
if (framesCounter > 180)
{
if (monsterCheck == 1)
{
if (closet.spooky)
{
ScarePlayer();
PlaySound(sndScream);
}
else FindKeyPlayer();
closet.active = true;
closet.selected = false;
}
else if (monsterCheck == 2)
{
if (chair.spooky)
{
ScarePlayer();
PlaySound(sndScream);
}
else FindKeyPlayer();
chair.active = true;
chair.selected = false;
}
else if (monsterCheck == 3)
{
if (window.spooky)
{
ScarePlayer();
PlaySound(sndScream);
}
else FindKeyPlayer();
window.active = true;
window.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 Draw logic
void DrawKitchenScreen(void)
{
DrawTexture(background, 0, 0, WHITE);
// Draw monsters
DrawMonster(closet, 0);
DrawMonster(chair, 0);
DrawMonster(window, 0);
// Draw door
if (doorRight.selected) DrawTextureRec(doors, doorRight.frameRec, doorRight.position, GREEN);
else DrawTextureRec(doors, doorRight.frameRec, doorRight.position, WHITE);
if (doorLeft.selected) DrawTextureRec(doors, doorLeft.frameRec, doorLeft.position, GREEN);
else DrawTextureRec(doors, doorLeft.frameRec, doorLeft.position, WHITE);
// Draw messsages
if (msgState < 2) DrawRectangle(0, 40, GetScreenWidth(), 200, Fade(LIGHTGRAY, 0.5f));
else if (msgState == 2) DrawRectangle(0, 80, GetScreenWidth(), 100, Fade(LIGHTGRAY, 0.5f));
if (msgState == 0)
{
DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE);
}
else if (msgState == 1)
{
DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE);
if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK);
}
else if (msgState == 2)
{
if ((msgCounter/30)%2)
{
DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE);
DrawRectangleRec(closet.bounds, Fade(RED, 0.6f));
DrawRectangleRec(window.bounds, Fade(RED, 0.6f));
DrawRectangleRec(chair.bounds, Fade(RED, 0.6f));
}
}
else
{
if ((monsterHover) && ((msgCounter/30)%2))
{
DrawRectangle(0, 0, GetScreenWidth(), 50, Fade(LIGHTGRAY, 0.5f));
DrawText("PRESS SPACE or CLICK to INTERACT", 420, 15, 20, BLACK);
}
}
DrawPlayer(); // NOTE: Also draws mouse pointer!
}
// Gameplay Screen Unload logic
void UnloadKitchenScreen(void)
{
// TODO: Unload GAMEPLAY screen variables here!
UnloadTexture(background);
UnloadMonster(closet);
UnloadMonster(chair);
UnloadMonster(window);
}
// Gameplay Screen should finish?
int FinishKitchenScreen(void)
{
return finishScreen;
}

View File

@ -0,0 +1,403 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Gameplay Screen Functions Definitions (Init, Update, Draw, Unload)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#include "raylib.h"
#include "screens.h"
#include "../player.h"
#include "../monster.h"
#include <string.h>
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
// Gameplay screen global variables
static int framesCounter;
static int finishScreen;
static Texture2D background;
// Declare doors
static Door doorCenter;
static Door doorLeft;
// Decalre monsters
static Monster candle;
static Monster picture;
static Monster phone;
static bool monsterHover = false;
static int monsterCheck = -1; // Identify checking monster
static const char message[256] = "WHEN WIND BLOWS, IT KNOWS THE DIRECTION\nLET IT GUIDE YOU!";
static int msgPosX = 100;
static int msgState = 0; // 0-writting, 1-wait, 2-choose
static int lettersCounter = 0;
static char msgBuffer[256] = { '\0' };
static int msgCounter = 0;
static bool searching = false;
//----------------------------------------------------------------------------------
// Gameplay Screen Functions Definition
//----------------------------------------------------------------------------------
// Gameplay Screen Initialization logic
void InitLivingroomScreen(void)
{
ResetPlayer();
// Reset Screen variables
monsterHover = false;
monsterCheck = -1;
msgState = 0;
msgCounter = 0;
lettersCounter = 0;
for (int i = 0; i < 256; i++) msgBuffer[i] = '\0';
framesCounter = 0;
finishScreen = 0;
background = LoadTexture("resources/textures/background_livingroom.png");
// Initialize doors
doorLeft.position = (Vector2) { -45, 140};
doorLeft.facing = 0;
doorLeft.locked = true;
doorLeft.frameRec =(Rectangle) {((doors.width/3)*doorLeft.facing), doors.height/2, doors.width/3, doors.height/2};
doorLeft.bound = (Rectangle) { doorLeft.position.x, doorLeft.position.y, doors.width/3, doors.height/2};
doorLeft.selected = false;
doorCenter.position = (Vector2) { 830, 108 };
doorCenter.facing = 1;
doorCenter.locked = true;
doorCenter.frameRec =(Rectangle) {((doors.width/3)*doorCenter.facing), doors.height/2, doors.width/3, doors.height/2};
doorCenter.bound = (Rectangle) { doorCenter.position.x, doorCenter.position.y, doors.width/3, doors.height/2};
doorCenter.selected = false;
// Monster init: lamp
candle.position = (Vector2){ 154, 256 };
candle.texture = LoadTexture("resources/textures/monster_candle.png");
candle.currentFrame = 0;
candle.framesCounter = 0;
candle.numFrames = 4;
candle.bounds = (Rectangle){ candle.position.x + 90, candle.position.y + 30, 185, 340 };
candle.frameRec = (Rectangle) { 0, 0, candle.texture.width/candle.numFrames, candle.texture.height };
candle.selected = false;
candle.active = false;
candle.spooky = false;
// Monster init: arc
picture.position = (Vector2){ 504, 164 };
picture.texture = LoadTexture("resources/textures/monster_picture.png");
picture.currentFrame = 0;
picture.framesCounter = 0;
picture.numFrames = 4;
picture.bounds = (Rectangle){ picture.position.x + 44, picture.position.y, 174, 264 };
picture.frameRec = (Rectangle) { 0, 0, picture.texture.width/picture.numFrames, picture.texture.height };
picture.selected = false;
picture.active = false;
picture.spooky = true;
// Monster init: phone
phone.position = (Vector2){ 1054, 404 };
phone.texture = LoadTexture("resources/textures/monster_phone.png");
phone.currentFrame = 0;
phone.framesCounter = 0;
phone.numFrames = 4;
phone.bounds = (Rectangle){ phone.position.x + 64, phone.position.y +120, 100, 160 };
phone.frameRec = (Rectangle) { 0, 0, phone.texture.width/phone.numFrames, phone.texture.height };
phone.selected = false;
phone.active = false;
phone.spooky = true;
}
// 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 Draw logic
void DrawLivingroomScreen(void)
{
DrawTexture(background, 0, 0, WHITE);
// Draw monsters
DrawMonster(picture, 0);
DrawMonster(candle, 0);
DrawMonster(phone, 0);
// Draw door
if (doorCenter.selected) DrawTextureRec(doors, doorCenter.frameRec, doorCenter.position, GREEN);
else DrawTextureRec(doors, doorCenter.frameRec, doorCenter.position, WHITE);
if (doorLeft.selected) DrawTextureRec(doors, doorLeft.frameRec, doorLeft.position, GREEN);
else DrawTextureRec(doors, doorLeft.frameRec, doorLeft.position, WHITE);
// Draw messsages
if (msgState < 2) DrawRectangle(0, 40, GetScreenWidth(), 200, Fade(LIGHTGRAY, 0.5f));
else if (msgState == 2) DrawRectangle(0, 80, GetScreenWidth(), 100, Fade(LIGHTGRAY, 0.5f));
if (msgState == 0)
{
DrawTextEx(font, msgBuffer, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE);
}
else if (msgState == 1)
{
DrawTextEx(font, message, (Vector2){ msgPosX, 80 }, font.size, 2, WHITE);
if ((msgCounter/30)%2) DrawText("PRESS ENTER or CLICK", GetScreenWidth() - 280, 200, 20, BLACK);
}
else if (msgState == 2)
{
if ((msgCounter/30)%2)
{
DrawTextEx(font, "CHOOSE WISELY!", (Vector2){ 300, 95 }, font.size*2, 2, WHITE);
DrawRectangleRec(candle.bounds, Fade(RED, 0.6f));
DrawRectangleRec(phone.bounds, Fade(RED, 0.6f));
DrawRectangleRec(picture.bounds, Fade(RED, 0.6f));
}
}
else
{
if ((monsterHover) && ((msgCounter/30)%2))
{
DrawRectangle(0, 0, GetScreenWidth(), 50, Fade(LIGHTGRAY, 0.5f));
DrawText("PRESS SPACE or CLICK to INTERACT", 420, 15, 20, BLACK);
}
}
DrawPlayer(); // NOTE: Also draws mouse pointer!
}
// Gameplay Screen Unload logic
void UnloadLivingroomScreen(void)
{
// TODO: Unload GAMEPLAY screen variables here!
UnloadTexture(background);
UnloadMonster(candle);
UnloadMonster(picture);
UnloadMonster(phone);
}
// Gameplay Screen should finish?
int FinishLivingroomScreen(void)
{
return finishScreen;
}

View File

@ -0,0 +1,108 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Logo Screen Functions Definitions (Init, Update, Draw, Unload)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#include "raylib.h"
#include "screens.h"
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
// Logo screen global variables
static int framesCounter = 0;
static int finishScreen;
static Texture2D logo;
static float logoAlpha = 0;
static int state = 0;
//----------------------------------------------------------------------------------
// Logo Screen Functions Definition
//----------------------------------------------------------------------------------
// Logo Screen Initialization logic
void InitLogoScreen(void)
{
// Initialize LOGO screen variables here!
finishScreen = 0;
logo = LoadTexture("resources/textures/skully_logo.png");
}
// Logo Screen Update logic
void UpdateLogoScreen(void)
{
// Update LOGO screen variables here!
if (state == 0)
{
logoAlpha += 0.04f;
if (logoAlpha >= 1.0f) state = 1;
}
else if (state == 1)
{
framesCounter++;
if (framesCounter > 180) state = 2;
}
else if (state == 2)
{
logoAlpha -= 0.04f;
if (logoAlpha <= 0.0f)
{
framesCounter = 0;
state = 3;
}
}
else if (state == 3)
{
finishScreen = 1;
}
}
// Logo Screen Draw logic
void DrawLogoScreen(void)
{
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), RAYWHITE);
DrawTexture(logo, GetScreenWidth()/2 - logo.width/2, 130, Fade(WHITE, logoAlpha));
DrawText("GRAY TEAM", 340, 450, 100, Fade(DARKGRAY, logoAlpha));
}
// Logo Screen Unload logic
void UnloadLogoScreen(void)
{
// Unload LOGO screen variables here!
UnloadTexture(logo);
}
// Logo Screen should finish?
int FinishLogoScreen(void)
{
return finishScreen;
}

View File

@ -0,0 +1,201 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Logo Screen Functions Definitions (Init, Update, Draw, Unload)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#include "raylib.h"
#include "screens.h"
#define LOGO_RECS_SIDE 16
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
// Logo screen global variables
static int framesCounter = 0;
static int finishScreen;
static int logoPositionX;
static int logoPositionY;
static int lettersCount = 0;
static int topSideRecWidth = LOGO_RECS_SIDE;
static int leftSideRecHeight = LOGO_RECS_SIDE;
static int bottomSideRecWidth = LOGO_RECS_SIDE;
static int rightSideRecHeight = LOGO_RECS_SIDE;
static char raylib[8]; // raylib text array, max 8 letters
static int state = 0; // Tracking animation states (State Machine)
static float alpha = 1.0f; // Useful for fading
//----------------------------------------------------------------------------------
// Logo Screen Functions Definition
//----------------------------------------------------------------------------------
// Logo Screen Initialization logic
void rlInitLogoScreen(void)
{
// TODO: Initialize LOGO screen variables here!
finishScreen = 0;
logoPositionX = GetScreenWidth()/2 - 128;
logoPositionY = GetScreenHeight()/2 - 128;
for (int i = 0; i < 8; i++) raylib[i] = '\0';
}
// Logo Screen Update logic
void rlUpdateLogoScreen(void)
{
// Update LOGO screen variables here!
if (state == 0) // State 0: Small box blinking
{
framesCounter++;
if (framesCounter == 80)
{
state = 1;
framesCounter = 0; // Reset counter... will be used later...
}
}
else if (state == 1) // State 1: Top and left bars growing
{
topSideRecWidth += 8;
leftSideRecHeight += 8;
if (topSideRecWidth == 256) state = 2;
}
else if (state == 2) // State 2: Bottom and right bars growing
{
bottomSideRecWidth += 8;
rightSideRecHeight += 8;
if (bottomSideRecWidth == 256) state = 3;
}
else if (state == 3) // State 3: Letters appearing (one by one)
{
framesCounter++;
if (framesCounter/10) // Every 12 frames, one more letter!
{
lettersCount++;
framesCounter = 0;
}
switch (lettersCount)
{
case 1: raylib[0] = 'r'; break;
case 2: raylib[1] = 'a'; break;
case 3: raylib[2] = 'y'; break;
case 4: raylib[3] = 'l'; break;
case 5: raylib[4] = 'i'; break;
case 6: raylib[5] = 'b'; break;
default: break;
}
// When all letters have appeared...
if (lettersCount >= 10)
{
state = 4;
framesCounter = 0;
}
}
else if (state == 4)
{
framesCounter++;
if (framesCounter > 100)
{
alpha -= 0.02f;
if (alpha <= 0.0f)
{
alpha = 0.0f;
finishScreen = 1;
}
}
}
}
// Logo Screen Draw logic
void rlDrawLogoScreen(void)
{
if (state == 0)
{
if ((framesCounter/10)%2) DrawRectangle(logoPositionX, logoPositionY, 16, 16, BLACK);
}
else if (state == 1)
{
DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK);
DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK);
}
else if (state == 2)
{
DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, BLACK);
DrawRectangle(logoPositionX, logoPositionY, 16, leftSideRecHeight, BLACK);
DrawRectangle(logoPositionX + 240, logoPositionY, 16, rightSideRecHeight, BLACK);
DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, BLACK);
}
else if (state == 3)
{
DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha));
DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha));
DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha));
DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha));
DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha));
DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha));
}
else if (state == 4)
{
DrawRectangle(logoPositionX, logoPositionY, topSideRecWidth, 16, Fade(BLACK, alpha));
DrawRectangle(logoPositionX, logoPositionY + 16, 16, leftSideRecHeight - 32, Fade(BLACK, alpha));
DrawRectangle(logoPositionX + 240, logoPositionY + 16, 16, rightSideRecHeight - 32, Fade(BLACK, alpha));
DrawRectangle(logoPositionX, logoPositionY + 240, bottomSideRecWidth, 16, Fade(BLACK, alpha));
DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112, 224, 224, Fade(RAYWHITE, alpha));
DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48, 50, Fade(BLACK, alpha));
if (framesCounter > 20) DrawText("powered by", logoPositionX, logoPositionY - 27, 20, Fade(DARKGRAY, alpha));
}
}
// Logo Screen Unload logic
void rlUnloadLogoScreen(void)
{
// TODO: Unload LOGO screen variables here!
}
// Logo Screen should finish?
int rlFinishLogoScreen(void)
{
return finishScreen;
}

View File

@ -0,0 +1,92 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Title Screen Functions Definitions (Init, Update, Draw, Unload)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#include "raylib.h"
#include "screens.h"
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
// Title screen global variables
static int framesCounter;
static int finishScreen;
static Texture2D title;
static float titleAlpha = 0.0f;
//----------------------------------------------------------------------------------
// Title Screen Functions Definition
//----------------------------------------------------------------------------------
// Title Screen Initialization logic
void InitTitleScreen(void)
{
// Initialize TITLE screen variables here!
framesCounter = 0;
finishScreen = 0;
title = LoadTexture("resources/textures/title.png");
}
// Title Screen Update logic
void UpdateTitleScreen(void)
{
// Update TITLE screen variables here!
framesCounter++;
titleAlpha += 0.005f;
if (titleAlpha >= 1.0f) titleAlpha = 1.0f;
// Press enter to change to ATTIC screen
if ((IsKeyPressed(KEY_ENTER)) || (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)))
{
finishScreen = 1;
}
}
// Title Screen Draw logic
void DrawTitleScreen(void)
{
//DrawText("TITLE SCREEN", 100, 100, 140, Fade(BLACK, titleAlpha));
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), DARKGRAY);
DrawTexture(title, GetScreenWidth()/2 - title.width/2, 20, Fade(WHITE, titleAlpha));
if ((framesCounter > 180) && ((framesCounter/40)%2)) DrawText("PRESS ENTER to START", 380, 545, 40, BLACK);
}
// Title Screen Unload logic
void UnloadTitleScreen(void)
{
// Unload TITLE screen variables here!
UnloadTexture(title);
}
// Title Screen should finish?
int FinishTitleScreen(void)
{
return finishScreen;
}

View File

@ -0,0 +1,164 @@
/**********************************************************************************************
*
* raylib - Advance Game template
*
* Screens Functions Declarations (Init, Update, Draw, Unload)
*
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
*
* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not claim that you
* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
* as being the original software.
*
* 3. This notice may not be removed or altered from any source distribution.
*
**********************************************************************************************/
#ifndef SCREENS_H
#define SCREENS_H
#define PLAYER_ANIM_FRAMES 7
#define PLAYER_ANIM_SEQ 2
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
typedef enum GameScreen { LOGO = 0, LOGO_RL, TITLE, ATTIC, AISLE01, AISLE02, BATHROOM, LIVINGROOM, KITCHEN, ARMORY, ENDING } GameScreen;
typedef struct Door {
Vector2 position;
int facing;
bool locked;
bool selected;
Rectangle frameRec;
Rectangle bound;
} Door;
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
GameScreen currentScreen;
SpriteFont font;
Texture2D doors;
Sound sndDoor;
Sound sndScream;
#ifdef __cplusplus
extern "C" { // Prevents name mangling of functions
#endif
//----------------------------------------------------------------------------------
// Logo Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitLogoScreen(void);
void UpdateLogoScreen(void);
void DrawLogoScreen(void);
void UnloadLogoScreen(void);
int FinishLogoScreen(void);
//----------------------------------------------------------------------------------
// raylib Logo Screen Functions Declaration
//----------------------------------------------------------------------------------
void rlInitLogoScreen(void);
void rlUpdateLogoScreen(void);
void rlDrawLogoScreen(void);
void rlUnloadLogoScreen(void);
int rlFinishLogoScreen(void);
//----------------------------------------------------------------------------------
// Title Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitTitleScreen(void);
void UpdateTitleScreen(void);
void DrawTitleScreen(void);
void UnloadTitleScreen(void);
int FinishTitleScreen(void);
//----------------------------------------------------------------------------------
// Attic Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitAtticScreen(void);
void UpdateAtticScreen(void);
void DrawAtticScreen(void);
void UnloadAtticScreen(void);
int FinishAtticScreen(void);
//----------------------------------------------------------------------------------
// Aisle01 Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitAisle01Screen(void);
void UpdateAisle01Screen(void);
void DrawAisle01Screen(void);
void UnloadAisle01Screen(void);
int FinishAisle01Screen(void);
//----------------------------------------------------------------------------------
// Aisle02 Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitAisle02Screen(void);
void UpdateAisle02Screen(void);
void DrawAisle02Screen(void);
void UnloadAisle02Screen(void);
int FinishAisle02Screen(void);
//----------------------------------------------------------------------------------
// Bathroom Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitBathroomScreen(void);
void UpdateBathroomScreen(void);
void DrawBathroomScreen(void);
void UnloadBathroomScreen(void);
int FinishBathroomScreen(void);
//----------------------------------------------------------------------------------
// Livingroom Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitLivingroomScreen(void);
void UpdateLivingroomScreen(void);
void DrawLivingroomScreen(void);
void UnloadLivingroomScreen(void);
int FinishLivingroomScreen(void);
//----------------------------------------------------------------------------------
// Kitchen Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitKitchenScreen(void);
void UpdateKitchenScreen(void);
void DrawKitchenScreen(void);
void UnloadKitchenScreen(void);
int FinishKitchenScreen(void);
//----------------------------------------------------------------------------------
// Armory Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitArmoryScreen(void);
void UpdateArmoryScreen(void);
void DrawArmoryScreen(void);
void UnloadArmoryScreen(void);
int FinishArmoryScreen(void);
//----------------------------------------------------------------------------------
// Ending Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitEndingScreen(void);
void UpdateEndingScreen(void);
void DrawEndingScreen(void);
void UnloadEndingScreen(void);
int FinishEndingScreen(void);
#ifdef __cplusplus
}
#endif
#endif // SCREENS_H