Added game sources: Skully Escape
This game was developed for King GameJam 2015
254
games/skully_escape/makefile
Normal file
@ -0,0 +1,254 @@
|
|||||||
|
#**************************************************************************************************
|
||||||
|
#
|
||||||
|
# raylib - Advance Game
|
||||||
|
#
|
||||||
|
# makefile to compile advance game
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
#**************************************************************************************************
|
||||||
|
|
||||||
|
# define raylib platform if not defined (by default, compile for RPI)
|
||||||
|
# Other possible platform: PLATFORM_DESKTOP
|
||||||
|
PLATFORM ?= PLATFORM_DESKTOP
|
||||||
|
|
||||||
|
# determine PLATFORM_OS in case PLATFORM_DESKTOP selected
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
|
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! ifeq ($(UNAME),Msys) -> Windows
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
PLATFORM_OS=WINDOWS
|
||||||
|
LIBPATH=win32
|
||||||
|
else
|
||||||
|
UNAMEOS:=$(shell uname)
|
||||||
|
ifeq ($(UNAMEOS),Linux)
|
||||||
|
PLATFORM_OS=LINUX
|
||||||
|
LIBPATH=linux
|
||||||
|
else
|
||||||
|
ifeq ($(UNAMEOS),Darwin)
|
||||||
|
PLATFORM_OS=OSX
|
||||||
|
LIBPATH=osx
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# define compiler: gcc for C program, define as g++ for C++
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
# define emscripten compiler
|
||||||
|
CC = emcc
|
||||||
|
else
|
||||||
|
ifeq ($(PLATFORM_OS),OSX)
|
||||||
|
# define llvm compiler for mac
|
||||||
|
CC = clang
|
||||||
|
else
|
||||||
|
# define default gcc compiler
|
||||||
|
CC = gcc
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# define compiler flags:
|
||||||
|
# -O2 defines optimization level
|
||||||
|
# -Wall turns on most, but not all, compiler warnings
|
||||||
|
# -std=c99 use standard C from 1999 revision
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||||
|
CFLAGS = -O2 -Wall -std=gnu99 -fgnu89-inline
|
||||||
|
else
|
||||||
|
CFLAGS = -O2 -Wall -std=c99
|
||||||
|
endif
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
CFLAGS = -O1 -Wall -std=c99 -s USE_GLFW=3 --preload-file resources -s ALLOW_MEMORY_GROWTH=1
|
||||||
|
#-s ASSERTIONS=1 --preload-file resources
|
||||||
|
#-s ALLOW_MEMORY_GROWTH=1 # to allow memory resizing
|
||||||
|
#-s TOTAL_MEMORY=16777216 # to specify heap memory size (default = 16MB)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# define any directories containing required header files
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||||
|
INCLUDES = -I. -I../../src -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads
|
||||||
|
else
|
||||||
|
INCLUDES = -I. -IC:/raylib/raylib/src -IC:/raylib/raylib/src
|
||||||
|
# external libraries headers
|
||||||
|
# GLFW3
|
||||||
|
INCLUDES += -I../../external/glfw3/include
|
||||||
|
# GLEW
|
||||||
|
INCLUDES += -I../../external/glew/include
|
||||||
|
# OpenAL Soft
|
||||||
|
INCLUDES += -I../../external/openal_soft/include
|
||||||
|
endif
|
||||||
|
|
||||||
|
# define library paths containing required libs
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||||
|
LFLAGS = -L. -L../../src -L/opt/vc/lib
|
||||||
|
else
|
||||||
|
LFLAGS = -L. -LC:/raylib/raylib/src -L../../../src
|
||||||
|
# external libraries to link with
|
||||||
|
# GLFW3
|
||||||
|
LFLAGS += -L../../external/glfw3/lib/$(LIBPATH)
|
||||||
|
ifneq ($(PLATFORM_OS),OSX)
|
||||||
|
# OpenAL Soft
|
||||||
|
LFLAGS += -L../../external/openal_soft/lib/$(LIBPATH)
|
||||||
|
# GLEW
|
||||||
|
LFLAGS += -L../../external/glew/lib/$(LIBPATH)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# define any libraries to link into executable
|
||||||
|
# if you want to link libraries (libname.so or libname.a), use the -lname
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
|
# libraries for Debian GNU/Linux desktop compiling
|
||||||
|
# requires the following packages:
|
||||||
|
# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
|
||||||
|
LIBS = -lraylib -lglfw -lGLEW -lGL -lopenal
|
||||||
|
endif
|
||||||
|
ifeq ($(PLATFORM_OS),OSX)
|
||||||
|
# libraries for OS X 10.9 desktop compiling
|
||||||
|
# requires the following packages:
|
||||||
|
# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
|
||||||
|
LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa
|
||||||
|
else
|
||||||
|
# libraries for Windows desktop compiling
|
||||||
|
# NOTE: GLFW3 and OpenAL Soft libraries should be installed
|
||||||
|
LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||||
|
# libraries for Raspberry Pi compiling
|
||||||
|
# NOTE: OpenAL Soft library should be installed (libopenal1 package)
|
||||||
|
LIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lbcm_host -lopenal
|
||||||
|
endif
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
LIBS = C:/raylib/raylib/src/libraylib.bc
|
||||||
|
endif
|
||||||
|
|
||||||
|
# define additional parameters and flags for windows
|
||||||
|
ifeq ($(PLATFORM_OS),WINDOWS)
|
||||||
|
# resources file contains windows exe icon
|
||||||
|
# -Wl,--subsystem,windows hides the console window
|
||||||
|
WINFLAGS = C:/raylib/raylib/src/resources
|
||||||
|
#-Wl,--subsystem,windows
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
EXT = .html
|
||||||
|
endif
|
||||||
|
|
||||||
|
# define all screen object files required
|
||||||
|
SCREENS = \
|
||||||
|
screens/screen_logo.o \
|
||||||
|
screens/screen_logo_raylib.o \
|
||||||
|
screens/screen_title.o \
|
||||||
|
screens/screen_attic.o \
|
||||||
|
screens/screen_aisle01.o \
|
||||||
|
screens/screen_aisle02.o \
|
||||||
|
screens/screen_armory.o \
|
||||||
|
screens/screen_livingroom.o \
|
||||||
|
screens/screen_kitchen.o \
|
||||||
|
screens/screen_bathroom.o \
|
||||||
|
screens/screen_ending.o \
|
||||||
|
player.o \
|
||||||
|
monster.o \
|
||||||
|
|
||||||
|
# typing 'make' will invoke the first target entry in the file,
|
||||||
|
# in this case, the 'default' target entry is advance_game
|
||||||
|
default: skully_escape
|
||||||
|
|
||||||
|
# compile template - advance_game
|
||||||
|
skully_escape: skully_escape.c $(SCREENS)
|
||||||
|
$(CC) -o $@$(EXT) $< $(SCREENS) $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
|
||||||
|
# compile screen LOGO
|
||||||
|
screens/screen_logo.o: screens/screen_logo.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen LOGO raylib
|
||||||
|
screens/screen_logo_raylib.o: screens/screen_logo_raylib.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen TITLE
|
||||||
|
screens/screen_title.o: screens/screen_title.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen ATTIC
|
||||||
|
screens/screen_attic.o: screens/screen_attic.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen AISLE01
|
||||||
|
screens/screen_aisle01.o: screens/screen_aisle01.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen AISLE02
|
||||||
|
screens/screen_aisle02.o: screens/screen_aisle02.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen BATHROOM
|
||||||
|
screens/screen_bathroom.o: screens/screen_bathroom.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen LIVINGROOM
|
||||||
|
screens/screen_livingroom.o: screens/screen_livingroom.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen KITCHEN
|
||||||
|
screens/screen_kitchen.o: screens/screen_kitchen.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen ARMORY
|
||||||
|
screens/screen_armory.o: screens/screen_armory.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen ENDING
|
||||||
|
screens/screen_ending.o: screens/screen_ending.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen LOGO
|
||||||
|
player.o: player.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen LOGO
|
||||||
|
monster.o: monster.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# clean everything
|
||||||
|
clean:
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
|
ifeq ($(PLATFORM_OS),OSX)
|
||||||
|
find . -type f -perm +ugo+x -delete
|
||||||
|
rm -f *.o
|
||||||
|
else
|
||||||
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
|
find . -type f -executable -delete
|
||||||
|
rm -f *.o
|
||||||
|
else
|
||||||
|
del *.o *.exe
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||||
|
find . -type f -executable -delete
|
||||||
|
rm -f *.o
|
||||||
|
endif
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_WEB)
|
||||||
|
del *.o *.html *.js
|
||||||
|
endif
|
||||||
|
@echo Cleaning done
|
||||||
|
|
||||||
|
# instead of defining every module one by one, we can define a pattern
|
||||||
|
# this pattern below will automatically compile every module defined on $(OBJS)
|
||||||
|
#%.exe : %.c
|
||||||
|
# $(CC) -o $@ $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM)
|
||||||
54
games/skully_escape/monster.c
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/***********************************************************************************
|
||||||
|
*
|
||||||
|
* KING GAME JAM - GRAY TEAM
|
||||||
|
*
|
||||||
|
* <Game title>
|
||||||
|
* <Game description>
|
||||||
|
*
|
||||||
|
* This game has been created using raylib (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
#include "monster.h"
|
||||||
|
|
||||||
|
void UpdateMonster(Monster *monster)
|
||||||
|
{
|
||||||
|
if (!monster->active)
|
||||||
|
{
|
||||||
|
if (CheckCollisionPointRec(GetMousePosition(), monster->bounds)) monster->selected = true;
|
||||||
|
else monster->selected = false;
|
||||||
|
}
|
||||||
|
else if (monster->spooky)
|
||||||
|
{
|
||||||
|
monster->framesCounter++;
|
||||||
|
monster->currentSeq = 0;
|
||||||
|
|
||||||
|
if (monster->framesCounter > 7)
|
||||||
|
{
|
||||||
|
monster->currentFrame++;
|
||||||
|
monster->framesCounter = 0;
|
||||||
|
|
||||||
|
if (monster->currentFrame > monster->numFrames - 1) monster->currentFrame = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
monster->frameRec.x = monster->currentFrame*monster->texture.width/monster->numFrames;
|
||||||
|
monster->frameRec.y = monster->currentSeq*monster->texture.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawMonster(Monster monster, int scroll)
|
||||||
|
{
|
||||||
|
Vector2 scrollPos = { monster.position.x - scroll, monster.position.y };
|
||||||
|
|
||||||
|
if (monster.selected) DrawTextureRec(monster.texture, monster.frameRec, scrollPos, RED);
|
||||||
|
else DrawTextureRec(monster.texture, monster.frameRec, scrollPos, WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UnloadMonster(Monster monster)
|
||||||
|
{
|
||||||
|
UnloadTexture(monster.texture);
|
||||||
|
}
|
||||||
73
games/skully_escape/monster.h
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/**********************************************************************************************
|
||||||
|
*
|
||||||
|
* 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 MONSTER_H
|
||||||
|
#define MONSTER_H
|
||||||
|
|
||||||
|
#define MONSTER_ANIM_FRAMES 7
|
||||||
|
#define MONSTER_ANIM_SEQ 2
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Types and Structures Definition
|
||||||
|
//---------------------------------------------------------------------------------
|
||||||
|
typedef struct Monster {
|
||||||
|
Vector2 position;
|
||||||
|
Texture2D texture;
|
||||||
|
Rectangle bounds;
|
||||||
|
Rectangle frameRec;
|
||||||
|
Color color;
|
||||||
|
int framesCounter;
|
||||||
|
int currentFrame;
|
||||||
|
int currentSeq;
|
||||||
|
int numFrames;
|
||||||
|
bool active;
|
||||||
|
bool selected;
|
||||||
|
bool spooky;
|
||||||
|
} Monster;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Global Variables Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" { // Prevents name mangling of functions
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Monster Functions Declaration
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void UpdateMonster(Monster *monster);
|
||||||
|
void DrawMonster(Monster monster, int scroll);
|
||||||
|
void UnloadMonster(Monster monster);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // SCREENS_H
|
||||||
281
games/skully_escape/player.c
Normal file
@ -0,0 +1,281 @@
|
|||||||
|
/***********************************************************************************
|
||||||
|
*
|
||||||
|
* KING GAME JAM - GRAY TEAM
|
||||||
|
*
|
||||||
|
* <Game title>
|
||||||
|
* <Game description>
|
||||||
|
*
|
||||||
|
* This game has been created using raylib (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
#include "player.h"
|
||||||
|
|
||||||
|
#define PLAYER_ANIM_FRAMES 4
|
||||||
|
#define PLAYER_ANIM_SEQ 6
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Module Variables Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Player mouse moving variables
|
||||||
|
static bool movingAnim;
|
||||||
|
static int moveDirection;
|
||||||
|
static int nextMovePoint;
|
||||||
|
|
||||||
|
// Mouse pointer variables
|
||||||
|
static Vector2 pointerPosition;
|
||||||
|
static bool pointerAnim;
|
||||||
|
static float pointerAlpha;
|
||||||
|
|
||||||
|
static int framesCounter;
|
||||||
|
static bool outControl = false;
|
||||||
|
|
||||||
|
static int animTimer = 0;
|
||||||
|
|
||||||
|
static Texture2D texLife;
|
||||||
|
|
||||||
|
static void DrawLifes(void);
|
||||||
|
|
||||||
|
// player initialitaction definition
|
||||||
|
void InitPlayer(void)
|
||||||
|
{
|
||||||
|
// NOTE: Some player variables are only initialized once
|
||||||
|
player.texture = LoadTexture("resources/textures/skully.png");
|
||||||
|
player.position = (Vector2){ 350, 400 };
|
||||||
|
player.numLifes = 4;
|
||||||
|
|
||||||
|
ResetPlayer();
|
||||||
|
|
||||||
|
framesCounter = 0;
|
||||||
|
|
||||||
|
texLife = LoadTexture("resources/textures/skully_icon.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
// player update definition
|
||||||
|
void UpdatePlayer(void)
|
||||||
|
{
|
||||||
|
if (!outControl)
|
||||||
|
{
|
||||||
|
if ((IsKeyDown(KEY_LEFT)) || (IsKeyDown(KEY_RIGHT)))
|
||||||
|
{
|
||||||
|
moveDirection = -1;
|
||||||
|
movingAnim = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((IsKeyDown(KEY_RIGHT)) || (moveDirection == 0))
|
||||||
|
{
|
||||||
|
player.currentSeq = WALK_RIGHT;
|
||||||
|
framesCounter++;
|
||||||
|
|
||||||
|
if (framesCounter > 15)
|
||||||
|
{
|
||||||
|
player.currentFrame++;
|
||||||
|
framesCounter = 0;
|
||||||
|
|
||||||
|
if (player.currentFrame > PLAYER_ANIM_FRAMES - 1) player.currentFrame = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.position.x += 4;
|
||||||
|
}
|
||||||
|
else if ((IsKeyDown(KEY_LEFT)) || (moveDirection == 1))
|
||||||
|
{
|
||||||
|
player.currentSeq = WALK_LEFT;
|
||||||
|
framesCounter++;
|
||||||
|
|
||||||
|
if (framesCounter > 15)
|
||||||
|
{
|
||||||
|
player.currentFrame++;
|
||||||
|
framesCounter = 0;
|
||||||
|
|
||||||
|
if (player.currentFrame > PLAYER_ANIM_FRAMES - 1) player.currentFrame = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.position.x -= 4;
|
||||||
|
}
|
||||||
|
else player.currentFrame = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
framesCounter++;
|
||||||
|
animTimer++;
|
||||||
|
|
||||||
|
if (framesCounter > 10)
|
||||||
|
{
|
||||||
|
player.currentFrame++;
|
||||||
|
framesCounter = 0;
|
||||||
|
|
||||||
|
if (player.currentFrame > PLAYER_ANIM_FRAMES - 1) player.currentFrame = 0;
|
||||||
|
|
||||||
|
// We can adjust animation playing time depending on sequence
|
||||||
|
switch (player.currentSeq)
|
||||||
|
{
|
||||||
|
case SCARE_RIGHT:
|
||||||
|
{
|
||||||
|
if (animTimer > 180)
|
||||||
|
{
|
||||||
|
animTimer = 0;
|
||||||
|
outControl = false;
|
||||||
|
player.currentSeq = WALK_LEFT;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case SCARE_LEFT:
|
||||||
|
{
|
||||||
|
if (animTimer > 240)
|
||||||
|
{
|
||||||
|
animTimer = 0;
|
||||||
|
outControl = false;
|
||||||
|
player.currentSeq = WALK_RIGHT;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case SEARCH:
|
||||||
|
case FIND_KEY:
|
||||||
|
{
|
||||||
|
if (animTimer > 240)
|
||||||
|
{
|
||||||
|
animTimer = 0;
|
||||||
|
outControl = false;
|
||||||
|
player.currentSeq = WALK_RIGHT;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.position.x < 30) player.position.x = 30;
|
||||||
|
else if (player.position.x > (GetScreenWidth() - 200)) player.position.x = GetScreenWidth() - 200;
|
||||||
|
|
||||||
|
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||||
|
{
|
||||||
|
pointerPosition = GetMousePosition();
|
||||||
|
pointerAnim = true;
|
||||||
|
pointerAlpha = 1.0f;
|
||||||
|
|
||||||
|
nextMovePoint = (int)pointerPosition.x;
|
||||||
|
movingAnim = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (movingAnim)
|
||||||
|
{
|
||||||
|
if (nextMovePoint > (player.position.x + (player.frameRec.width/2) + 5)) moveDirection = 0; // Move Left
|
||||||
|
else if (nextMovePoint < (player.position.x + (player.frameRec.width/2) - 5)) moveDirection = 1; // Move Right
|
||||||
|
else
|
||||||
|
{
|
||||||
|
moveDirection = -1;
|
||||||
|
movingAnim = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.frameRec.x = player.currentFrame*player.texture.width/PLAYER_ANIM_FRAMES;
|
||||||
|
player.frameRec.y = (player.currentSeq - 1)*player.texture.height/PLAYER_ANIM_SEQ;
|
||||||
|
|
||||||
|
// Update player bounds
|
||||||
|
player.bounds = (Rectangle){ player.position.x + 50, player.position.y - 60, 100, 300 };
|
||||||
|
|
||||||
|
// Mouse pointer alpha animation
|
||||||
|
if (pointerAnim)
|
||||||
|
{
|
||||||
|
pointerAlpha -= 0.1f;
|
||||||
|
|
||||||
|
if (pointerAlpha <= 0.0f)
|
||||||
|
{
|
||||||
|
pointerAlpha = 0.0f;
|
||||||
|
pointerAnim = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
void DrawPlayer(void)
|
||||||
|
{
|
||||||
|
DrawTextureRec(player.texture, player.frameRec, player.position, WHITE);
|
||||||
|
|
||||||
|
// Draw mouse pointer on click
|
||||||
|
if (pointerAnim) DrawCircleV(pointerPosition, 20, Fade(RED, pointerAlpha));
|
||||||
|
|
||||||
|
DrawLifes();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UnloadPlayer(void)
|
||||||
|
{
|
||||||
|
UnloadTexture(player.texture);
|
||||||
|
UnloadTexture(texLife);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResetPlayer(void)
|
||||||
|
{
|
||||||
|
// Reset player variables
|
||||||
|
player.frameRec = (Rectangle){ 0, 0, player.texture.width/PLAYER_ANIM_FRAMES, player.texture.height/PLAYER_ANIM_SEQ };
|
||||||
|
player.currentFrame = 0;
|
||||||
|
player.currentSeq = WALK_RIGHT;
|
||||||
|
|
||||||
|
player.key = false;
|
||||||
|
player.dead = false;
|
||||||
|
|
||||||
|
// Reset player position
|
||||||
|
if (player.position.x < 400) player.position.x = GetScreenWidth() - 350;
|
||||||
|
if (player.position.x > (GetScreenWidth() - 400)) player.position.x = 350;
|
||||||
|
|
||||||
|
// Reset moving variables
|
||||||
|
movingAnim = false;
|
||||||
|
moveDirection = -1;
|
||||||
|
nextMovePoint = 0;
|
||||||
|
framesCounter = 0;
|
||||||
|
outControl = false;
|
||||||
|
animTimer = 0;
|
||||||
|
|
||||||
|
// Reset pointer
|
||||||
|
pointerAlpha = 0.0f;
|
||||||
|
pointerAnim = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScarePlayer(void)
|
||||||
|
{
|
||||||
|
player.currentFrame = 0;
|
||||||
|
|
||||||
|
if (moveDirection == 0) player.currentSeq = SCARE_RIGHT;
|
||||||
|
else if (moveDirection == 1) player.currentSeq = SCARE_LEFT;
|
||||||
|
else player.currentSeq = SCARE_RIGHT;
|
||||||
|
|
||||||
|
player.numLifes--;
|
||||||
|
|
||||||
|
if (player.numLifes <= 0) player.dead = true;
|
||||||
|
|
||||||
|
outControl = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SearchKeyPlayer(void)
|
||||||
|
{
|
||||||
|
moveDirection = -1;
|
||||||
|
movingAnim = 0;
|
||||||
|
|
||||||
|
player.currentFrame = 0;
|
||||||
|
player.currentSeq = SEARCH;
|
||||||
|
|
||||||
|
outControl = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FindKeyPlayer(void)
|
||||||
|
{
|
||||||
|
player.currentFrame = 0;
|
||||||
|
player.currentSeq = FIND_KEY;
|
||||||
|
player.key = true;
|
||||||
|
|
||||||
|
outControl = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DrawLifes(void)
|
||||||
|
{
|
||||||
|
if (player.numLifes != 0)
|
||||||
|
{
|
||||||
|
Vector2 position = { 20, GetScreenHeight() - texLife.height - 20 };
|
||||||
|
|
||||||
|
for(int i = 0; i < player.numLifes; i++)
|
||||||
|
{
|
||||||
|
DrawTexture(texLife, position.x + i*texLife.width, position.y, Fade(RAYWHITE, 0.7f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
51
games/skully_escape/player.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#ifndef PLAYER_H
|
||||||
|
#define PLAYER_H
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Types and Structures Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
typedef enum { NONE, WALK_RIGHT, WALK_LEFT, SCARE_RIGHT, SCARE_LEFT, SEARCH, FIND_KEY } PlayerSequence;
|
||||||
|
|
||||||
|
typedef struct Player {
|
||||||
|
Vector2 position;
|
||||||
|
Rectangle bounds;
|
||||||
|
Texture2D texture;
|
||||||
|
Color color;
|
||||||
|
|
||||||
|
// Animation variables
|
||||||
|
Rectangle frameRec;
|
||||||
|
int currentFrame;
|
||||||
|
int currentSeq;
|
||||||
|
|
||||||
|
bool key;
|
||||||
|
int numLifes;
|
||||||
|
bool dead;
|
||||||
|
} Player;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Global Variables Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
Player player;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" { // Prevents name mangling of functions
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Logo Screen Functions Declaration
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
void InitPlayer(void);
|
||||||
|
void UpdatePlayer(void);
|
||||||
|
void DrawPlayer(void);
|
||||||
|
void UnloadPlayer(void);
|
||||||
|
void ResetPlayer(void);
|
||||||
|
|
||||||
|
void ScarePlayer(void);
|
||||||
|
void SearchKeyPlayer(void);
|
||||||
|
void FindKeyPlayer(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // SCREENS_H
|
||||||
BIN
games/skully_escape/resources/audio/come_play_with_me.ogg
Normal file
BIN
games/skully_escape/resources/audio/door.ogg
Normal file
BIN
games/skully_escape/resources/audio/scream.ogg
Normal file
BIN
games/skully_escape/resources/textures/alagard.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
games/skully_escape/resources/textures/background_aisle01.png
Normal file
|
After Width: | Height: | Size: 655 KiB |
BIN
games/skully_escape/resources/textures/background_aisle02.png
Normal file
|
After Width: | Height: | Size: 495 KiB |
BIN
games/skully_escape/resources/textures/background_armory.png
Normal file
|
After Width: | Height: | Size: 246 KiB |
BIN
games/skully_escape/resources/textures/background_attic.png
Normal file
|
After Width: | Height: | Size: 280 KiB |
BIN
games/skully_escape/resources/textures/background_bathroom.png
Normal file
|
After Width: | Height: | Size: 249 KiB |
BIN
games/skully_escape/resources/textures/background_kitchen.png
Normal file
|
After Width: | Height: | Size: 303 KiB |
BIN
games/skully_escape/resources/textures/background_livingroom.png
Normal file
|
After Width: | Height: | Size: 312 KiB |
BIN
games/skully_escape/resources/textures/doors.png
Normal file
|
After Width: | Height: | Size: 81 KiB |
BIN
games/skully_escape/resources/textures/monster_arc.png
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
games/skully_escape/resources/textures/monster_blazon01.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
games/skully_escape/resources/textures/monster_blazon02.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
games/skully_escape/resources/textures/monster_blazon03.png
Normal file
|
After Width: | Height: | Size: 51 KiB |
BIN
games/skully_escape/resources/textures/monster_candle.png
Normal file
|
After Width: | Height: | Size: 69 KiB |
BIN
games/skully_escape/resources/textures/monster_chair_left.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
BIN
games/skully_escape/resources/textures/monster_chair_right.png
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
games/skully_escape/resources/textures/monster_closet.png
Normal file
|
After Width: | Height: | Size: 91 KiB |
BIN
games/skully_escape/resources/textures/monster_lamp_left.png
Normal file
|
After Width: | Height: | Size: 78 KiB |
BIN
games/skully_escape/resources/textures/monster_lamp_right.png
Normal file
|
After Width: | Height: | Size: 145 KiB |
BIN
games/skully_escape/resources/textures/monster_mirror.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
games/skully_escape/resources/textures/monster_phone.png
Normal file
|
After Width: | Height: | Size: 50 KiB |
BIN
games/skully_escape/resources/textures/monster_picture.png
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
games/skully_escape/resources/textures/monster_window.png
Normal file
|
After Width: | Height: | Size: 172 KiB |
BIN
games/skully_escape/resources/textures/skully.png
Normal file
|
After Width: | Height: | Size: 136 KiB |
BIN
games/skully_escape/resources/textures/skully_icon.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
games/skully_escape/resources/textures/skully_logo.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
games/skully_escape/resources/textures/title.png
Normal file
|
After Width: | Height: | Size: 118 KiB |
409
games/skully_escape/screens/screen_aisle01.c
Normal 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;
|
||||||
|
}
|
||||||
444
games/skully_escape/screens/screen_aisle02.c
Normal 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;
|
||||||
|
}
|
||||||
404
games/skully_escape/screens/screen_armory.c
Normal 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;
|
||||||
|
}
|
||||||
332
games/skully_escape/screens/screen_attic.c
Normal 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;
|
||||||
|
}
|
||||||
383
games/skully_escape/screens/screen_bathroom.c
Normal 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;
|
||||||
|
}
|
||||||
90
games/skully_escape/screens/screen_ending.c
Normal 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;
|
||||||
|
}
|
||||||
403
games/skully_escape/screens/screen_kitchen.c
Normal 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;
|
||||||
|
}
|
||||||
403
games/skully_escape/screens/screen_livingroom.c
Normal 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;
|
||||||
|
}
|
||||||
108
games/skully_escape/screens/screen_logo.c
Normal 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;
|
||||||
|
}
|
||||||
201
games/skully_escape/screens/screen_logo_raylib.c
Normal 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;
|
||||||
|
}
|
||||||
92
games/skully_escape/screens/screen_title.c
Normal 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;
|
||||||
|
}
|
||||||
164
games/skully_escape/screens/screens.h
Normal 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
|
||||||
403
games/skully_escape/skully_escape.c
Normal file
@ -0,0 +1,403 @@
|
|||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* SKULLY ESCAPE [KING GAME JAM 2015]
|
||||||
|
*
|
||||||
|
* This game has been created using raylib (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 Ramon Santamaria (Ray San - raysan@raysanweb.com)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
#include "screens/screens.h" // NOTE: Defines global variable: currentScreen
|
||||||
|
|
||||||
|
#include "player.h"
|
||||||
|
|
||||||
|
#if defined(PLATFORM_WEB)
|
||||||
|
#include <emscripten/emscripten.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Global Variables Definition (local to this module)
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 1280;
|
||||||
|
const int screenHeight = 720;
|
||||||
|
|
||||||
|
// Required variables to manage screen transitions (fade-in, fade-out)
|
||||||
|
float transAlpha = 0;
|
||||||
|
bool onTransition = false;
|
||||||
|
bool transFadeOut = false;
|
||||||
|
int transFromScreen = -1;
|
||||||
|
int transToScreen = -1;
|
||||||
|
|
||||||
|
static int framesCounter = 0;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Local Functions Declaration
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
void TransitionToScreen(int screen);
|
||||||
|
void ChangeToScreen(int screen); // No transition effect
|
||||||
|
void UpdateTransition(void);
|
||||||
|
void DrawTransition(void);
|
||||||
|
|
||||||
|
void UpdateDrawFrame(void); // Update and Draw one frame
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Main entry point
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//---------------------------------------------------------
|
||||||
|
const char windowTitle[30] = "SKULLY ESCAPE [KING GAMEJAM]";
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, windowTitle);
|
||||||
|
|
||||||
|
// Global data loading (assets that must be available in all screens, i.e. fonts)
|
||||||
|
InitAudioDevice();
|
||||||
|
|
||||||
|
PlayMusicStream("resources/audio/come_play_with_me.ogg");
|
||||||
|
|
||||||
|
font = LoadSpriteFont("resources/textures/alagard.png");
|
||||||
|
doors = LoadTexture("resources/textures/doors.png");
|
||||||
|
sndDoor = LoadSound("resources/audio/door.ogg");
|
||||||
|
sndScream = LoadSound("resources/audio/scream.ogg");
|
||||||
|
|
||||||
|
InitPlayer();
|
||||||
|
|
||||||
|
// Setup and Init first screen
|
||||||
|
currentScreen = LOGO;
|
||||||
|
InitLogoScreen();
|
||||||
|
|
||||||
|
#if defined(PLATFORM_WEB)
|
||||||
|
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||||
|
#else
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
UpdateDrawFrame();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Unload all global loaded data (i.e. fonts) here!
|
||||||
|
UnloadPlayer();
|
||||||
|
UnloadSpriteFont(font);
|
||||||
|
UnloadTexture(doors);
|
||||||
|
UnloadSound(sndDoor);
|
||||||
|
UnloadSound(sndScream);
|
||||||
|
|
||||||
|
CloseAudioDevice();
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TransitionToScreen(int screen)
|
||||||
|
{
|
||||||
|
onTransition = true;
|
||||||
|
transFromScreen = currentScreen;
|
||||||
|
transToScreen = screen;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChangeToScreen(int screen)
|
||||||
|
{
|
||||||
|
switch (currentScreen)
|
||||||
|
{
|
||||||
|
case LOGO: UnloadLogoScreen(); break;
|
||||||
|
case LOGO_RL: rlUnloadLogoScreen(); break;
|
||||||
|
case TITLE: UnloadTitleScreen(); break;
|
||||||
|
case ATTIC: UnloadAtticScreen(); break;
|
||||||
|
case AISLE01: UnloadAisle01Screen();break;
|
||||||
|
case AISLE02: UnloadAisle02Screen();break;
|
||||||
|
case ARMORY: UnloadArmoryScreen();break;
|
||||||
|
case LIVINGROOM: UnloadLivingroomScreen();break;
|
||||||
|
case KITCHEN: UnloadKitchenScreen(); break;
|
||||||
|
case BATHROOM: UnloadBathroomScreen(); break;
|
||||||
|
case ENDING: UnloadEndingScreen(); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (screen)
|
||||||
|
{
|
||||||
|
case LOGO: InitLogoScreen(); break;
|
||||||
|
case LOGO_RL: rlInitLogoScreen(); break;
|
||||||
|
case TITLE: InitTitleScreen(); break;
|
||||||
|
case ATTIC: InitAtticScreen(); break;
|
||||||
|
case AISLE01: InitAisle01Screen();break;
|
||||||
|
case AISLE02: InitAisle02Screen();break;
|
||||||
|
case ARMORY: InitArmoryScreen();break;
|
||||||
|
case LIVINGROOM: InitLivingroomScreen();break;
|
||||||
|
case KITCHEN: InitKitchenScreen(); break;
|
||||||
|
case BATHROOM: InitBathroomScreen(); break;
|
||||||
|
case ENDING: InitEndingScreen(); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentScreen = screen;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateTransition(void)
|
||||||
|
{
|
||||||
|
if (!transFadeOut)
|
||||||
|
{
|
||||||
|
transAlpha += 0.05f;
|
||||||
|
|
||||||
|
if (transAlpha >= 1.0)
|
||||||
|
{
|
||||||
|
transAlpha = 1.0;
|
||||||
|
|
||||||
|
switch (transFromScreen)
|
||||||
|
{
|
||||||
|
case LOGO: UnloadLogoScreen(); break;
|
||||||
|
case LOGO_RL: rlUnloadLogoScreen(); break;
|
||||||
|
case TITLE: UnloadTitleScreen(); break;
|
||||||
|
case ATTIC: UnloadAtticScreen(); break;
|
||||||
|
case AISLE01: UnloadAisle01Screen();break;
|
||||||
|
case AISLE02: UnloadAisle02Screen();break;
|
||||||
|
case ARMORY: UnloadArmoryScreen();break;
|
||||||
|
case LIVINGROOM: UnloadLivingroomScreen();break;
|
||||||
|
case KITCHEN: UnloadKitchenScreen(); break;
|
||||||
|
case BATHROOM: UnloadBathroomScreen(); break;
|
||||||
|
case ENDING: UnloadEndingScreen(); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (transToScreen)
|
||||||
|
{
|
||||||
|
case LOGO:
|
||||||
|
{
|
||||||
|
InitLogoScreen();
|
||||||
|
currentScreen = LOGO;
|
||||||
|
} break;
|
||||||
|
case LOGO_RL:
|
||||||
|
{
|
||||||
|
rlInitLogoScreen();
|
||||||
|
currentScreen = LOGO_RL;
|
||||||
|
} break;
|
||||||
|
case TITLE:
|
||||||
|
{
|
||||||
|
InitTitleScreen();
|
||||||
|
currentScreen = TITLE;
|
||||||
|
} break;
|
||||||
|
case ATTIC:
|
||||||
|
{
|
||||||
|
InitAtticScreen();
|
||||||
|
currentScreen = ATTIC;
|
||||||
|
} break;
|
||||||
|
case AISLE01:
|
||||||
|
{
|
||||||
|
InitAisle01Screen();
|
||||||
|
currentScreen = AISLE01;
|
||||||
|
} break;
|
||||||
|
case AISLE02:
|
||||||
|
{
|
||||||
|
InitAisle02Screen();
|
||||||
|
currentScreen = AISLE02;
|
||||||
|
} break;
|
||||||
|
case BATHROOM:
|
||||||
|
{
|
||||||
|
InitBathroomScreen();
|
||||||
|
currentScreen = BATHROOM;
|
||||||
|
} break;
|
||||||
|
case LIVINGROOM:
|
||||||
|
{
|
||||||
|
InitLivingroomScreen();
|
||||||
|
currentScreen = LIVINGROOM;
|
||||||
|
} break;
|
||||||
|
case KITCHEN:
|
||||||
|
{
|
||||||
|
InitKitchenScreen();
|
||||||
|
currentScreen = KITCHEN;
|
||||||
|
} break;
|
||||||
|
case ARMORY:
|
||||||
|
{
|
||||||
|
InitArmoryScreen();
|
||||||
|
currentScreen = ARMORY;
|
||||||
|
} break;
|
||||||
|
case ENDING:
|
||||||
|
{
|
||||||
|
InitEndingScreen();
|
||||||
|
currentScreen = ENDING;
|
||||||
|
} break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
transFadeOut = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // Transition fade out logic
|
||||||
|
{
|
||||||
|
transAlpha -= 0.05f;
|
||||||
|
|
||||||
|
if (transAlpha <= 0)
|
||||||
|
{
|
||||||
|
transAlpha = 0;
|
||||||
|
transFadeOut = false;
|
||||||
|
onTransition = false;
|
||||||
|
transFromScreen = -1;
|
||||||
|
transToScreen = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawTransition(void)
|
||||||
|
{
|
||||||
|
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(BLACK, transAlpha));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update and draw game frame
|
||||||
|
void UpdateDrawFrame(void)
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
if (!onTransition)
|
||||||
|
{
|
||||||
|
if (player.dead)
|
||||||
|
{
|
||||||
|
framesCounter++;
|
||||||
|
|
||||||
|
if (framesCounter > 80)
|
||||||
|
{
|
||||||
|
framesCounter = 0;
|
||||||
|
player.dead = false;
|
||||||
|
player.numLifes = 4;
|
||||||
|
|
||||||
|
TransitionToScreen(TITLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(currentScreen)
|
||||||
|
{
|
||||||
|
case LOGO:
|
||||||
|
{
|
||||||
|
UpdateLogoScreen();
|
||||||
|
|
||||||
|
if (FinishLogoScreen()) ChangeToScreen(LOGO_RL);
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case LOGO_RL:
|
||||||
|
{
|
||||||
|
rlUpdateLogoScreen();
|
||||||
|
|
||||||
|
if (rlFinishLogoScreen()) TransitionToScreen(TITLE);
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case TITLE:
|
||||||
|
{
|
||||||
|
UpdateTitleScreen();
|
||||||
|
|
||||||
|
if (FinishTitleScreen() == 1) TransitionToScreen(ATTIC);
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case ATTIC:
|
||||||
|
{
|
||||||
|
UpdateAtticScreen();
|
||||||
|
|
||||||
|
if (FinishAtticScreen() == 1) TransitionToScreen(AISLE01);
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case AISLE01:
|
||||||
|
{
|
||||||
|
UpdateAisle01Screen();
|
||||||
|
|
||||||
|
if (FinishAisle01Screen() == 1) TransitionToScreen(BATHROOM);
|
||||||
|
else if(FinishAisle01Screen() == 2) TransitionToScreen(KITCHEN);
|
||||||
|
else if(FinishAisle01Screen() == 3) TransitionToScreen(LIVINGROOM);
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case BATHROOM:
|
||||||
|
{
|
||||||
|
UpdateBathroomScreen();
|
||||||
|
|
||||||
|
if (FinishBathroomScreen() == 1) TransitionToScreen(AISLE01);
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case LIVINGROOM:
|
||||||
|
{
|
||||||
|
UpdateLivingroomScreen();
|
||||||
|
|
||||||
|
if (FinishLivingroomScreen() == 1) TransitionToScreen(AISLE01);
|
||||||
|
else if(FinishLivingroomScreen() == 2)TransitionToScreen(AISLE02);
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case AISLE02:
|
||||||
|
{
|
||||||
|
UpdateAisle02Screen();
|
||||||
|
|
||||||
|
if (FinishAisle02Screen() == 1) TransitionToScreen(KITCHEN);
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case KITCHEN:
|
||||||
|
{
|
||||||
|
UpdateKitchenScreen();
|
||||||
|
|
||||||
|
if (FinishKitchenScreen() == 1) TransitionToScreen(ARMORY);
|
||||||
|
else if(FinishKitchenScreen() == 2)TransitionToScreen(AISLE02);
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case ARMORY:
|
||||||
|
{
|
||||||
|
UpdateArmoryScreen();
|
||||||
|
|
||||||
|
if(FinishArmoryScreen() == 1) TransitionToScreen(ENDING);
|
||||||
|
else if(FinishArmoryScreen() == 2) TransitionToScreen(KITCHEN);
|
||||||
|
|
||||||
|
} break;
|
||||||
|
case ENDING:
|
||||||
|
{
|
||||||
|
UpdateEndingScreen();
|
||||||
|
|
||||||
|
if (FinishEndingScreen()) TransitionToScreen(TITLE);
|
||||||
|
|
||||||
|
} break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Update transition (fade-in, fade-out)
|
||||||
|
UpdateTransition();
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateMusicStream();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
switch(currentScreen)
|
||||||
|
{
|
||||||
|
case LOGO: DrawLogoScreen(); break;
|
||||||
|
case LOGO_RL: rlDrawLogoScreen(); break;
|
||||||
|
case TITLE: DrawTitleScreen(); break;
|
||||||
|
case ATTIC: DrawAtticScreen(); break;
|
||||||
|
case AISLE01: DrawAisle01Screen();break;
|
||||||
|
case AISLE02: DrawAisle02Screen();break;
|
||||||
|
case BATHROOM: DrawBathroomScreen();break;
|
||||||
|
case LIVINGROOM: DrawLivingroomScreen();break;
|
||||||
|
case KITCHEN: DrawKitchenScreen();break;
|
||||||
|
case ARMORY: DrawArmoryScreen();break;
|
||||||
|
case ENDING: DrawEndingScreen(); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onTransition) DrawTransition();
|
||||||
|
|
||||||
|
//DrawFPS(10, 10);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||