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 |