Upload new game: Koala Seasons

This commit is contained in:
Ray 2017-04-18 10:42:15 +02:00
parent 99c226b344
commit a5c8ce2a34
25 changed files with 6695 additions and 0 deletions

View file

@ -0,0 +1,223 @@
#**************************************************************************************************
#
# raylib - Koala Seasons
#
# raylib makefile for desktop platforms, Raspberry Pi and HTML5 (emscripten)
#
# Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
#
# 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 to compile for
# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB
# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
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
#CFLAGSEXTRA = -Wextra -Wmissing-prototypes -Wstrict-prototypes
# define any directories containing required header files
INCLUDES = -I. -I../src -I../src/external
ifeq ($(PLATFORM),PLATFORM_RPI)
INCLUDES += -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads
endif
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# add standard directories for GNU/Linux
ifeq ($(PLATFORM_OS),LINUX)
INCLUDES += -I/usr/local/include/raylib/
else ifeq ($(PLATFORM_OS),WINDOWS)
# external libraries headers
# GLFW3
INCLUDES += -I../src/external/glfw3/include
# OpenAL Soft
INCLUDES += -I../src/external/openal_soft/include
endif
endif
# define library paths containing required libs
LFLAGS = -L. -L../src -L$(RAYLIB_PATH)
ifeq ($(PLATFORM),PLATFORM_RPI)
LFLAGS += -L/opt/vc/lib
endif
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
# add standard directories for GNU/Linux
ifeq ($(PLATFORM_OS),WINDOWS)
# external libraries to link with
# GLFW3
LFLAGS += -L../src/external/glfw3/lib/$(LIBPATH)
# OpenAL Soft
LFLAGS += -L../src/external/openal_soft/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 libegl1-mesa-dev
LIBS = -lraylib -lglfw3 -lGL -lopenal -lm -pthread -ldl
# on XWindow could require also below libraries, just uncomment
#LIBS += -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor
else
ifeq ($(PLATFORM_OS),OSX)
# libraries for OS X 10.9 desktop compiling
# requires the following packages:
# libglfw3-dev libopenal-dev libegl1-mesa-dev
LIBS = -lraylib -lglfw3 -framework OpenGL -framework OpenAl -framework Cocoa
else
# libraries for Windows desktop compiling
# NOTE: GLFW3 and OpenAL Soft libraries should be installed
LIBS = -lraylib -lglfw3 -lopengl32 -lopenal32 -lgdi32
endif
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)
# just adjust the correct path to libraylib.bc
LIBS = ../release/html5/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_icon
endif
ifeq ($(PLATFORM),PLATFORM_WEB)
EXT = .html
endif
# define all screen object files required
SCREENS = \
screens/screen_logo.o \
screens/screen_title.o \
screens/screen_gameplay.o \
screens/screen_ending.o \
# typing 'make' will invoke the first target entry in the file,
# in this case, the 'default' target entry is koala_seasons
default: koala_seasons
# compile template - koala_seasons
koala_seasons: koala_seasons.c $(SCREENS)
$(CC) -o $@$(EXT) $^ $(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 TITLE
screens/screen_title.o: screens/screen_title.c
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
# compile screen OPTIONS
screens/screen_options.o: screens/screen_options.c
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
# compile screen GAMEPLAY
screens/screen_gameplay.o: screens/screen_gameplay.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)
# 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 | xargs file -i | grep -E 'x-object|x-archive|x-sharedlib|x-executable' | rev | cut -d ':' -f 2- | rev | xargs rm -f
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)

View file

@ -0,0 +1,281 @@
/*******************************************************************************************
*
* raylib - Koala Seasons game
*
* Koala Seasons is a runner, you must survive as long as possible jumping from tree to tree
* Ready to start the adventure? How long can you survive?
*
* This game has been created using raylib 1.5 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
*
********************************************************************************************/
#include "raylib.h"
#include "screens/screens.h" // NOTE: Defines currentScreen
#if defined(PLATFORM_WEB)
#include <emscripten/emscripten.h>
#endif
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
static float transAlpha = 0;
static bool onTransition = false;
static bool transFadeOut = false;
static int transFromScreen = -1;
static int transToScreen = -1;
static int framesCounter = 0;
static Music music;
//----------------------------------------------------------------------------------
// Local Functions Declaration
//----------------------------------------------------------------------------------
void TransitionToScreen(int screen);
void UpdateTransition(void);
void DrawTransition(void);
void UpdateDrawFrame(void); // Update and Draw one frame
//----------------------------------------------------------------------------------
// Main entry point
//----------------------------------------------------------------------------------
#if defined(PLATFORM_ANDROID)
void android_main(struct android_app *app)
#else
int main(void)
#endif
{
// Initialization
//---------------------------------------------------------
const int screenWidth = 1280;
const int screenHeight = 720;
const char windowTitle[30] = "KOALA SEASONS";
//ShowLogo();
//SetConfigFlags(FLAG_FULLSCREEN_MODE);
#if defined(PLATFORM_ANDROID)
InitWindow(screenWidth, screenHeight, app);
#else
InitWindow(screenWidth, screenHeight, windowTitle);
#endif
// Load global data here (assets that must be available in all screens, i.e. fonts)
font = LoadSpriteFont("resources/graphics/mainfont.png");
atlas01 = LoadTexture("resources/graphics/atlas01.png");
atlas02 = LoadTexture("resources/graphics/atlas02.pvr");
#if defined(PLATFORM_WEB) || defined(PLATFORM_RPI) || defined(PLATFORM_ANDROID)
colorBlend = LoadShader("resources/shaders/glsl100/base.vs", "resources/shaders/glsl100/blend_color.fs");
#else
colorBlend = LoadShader("resources/shaders/glsl330/base.vs", "resources/shaders/glsl330/blend_color.fs");
#endif
InitAudioDevice();
// Load sounds data
fxJump = LoadSound("resources/audio/jump.ogg");
fxDash = LoadSound("resources/audio/dash.ogg");
fxEatLeaves = LoadSound("resources/audio/eat_leaves.ogg");
fxHitResin = LoadSound("resources/audio/resin_hit.ogg");
fxWind = LoadSound("resources/audio/wind_sound.ogg");
fxDieSnake = LoadSound("resources/audio/snake_die.ogg");
fxDieDingo = LoadSound("resources/audio/dingo_die.ogg");
fxDieOwl = LoadSound("resources/audio/owl_die.ogg");
music = LoadMusicStream("resources/audio/jngl.xm");
PlayMusicStream(music);
SetMusicVolume(music, 1.0f);
// Define and init first screen
// NOTE: currentScreen is defined in screens.h as a global variable
currentScreen = TITLE;
InitLogoScreen();
//InitOptionsScreen();
InitTitleScreen();
InitGameplayScreen();
InitEndingScreen();
#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()) UpdateDrawFrame();
#endif
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadEndingScreen();
UnloadTitleScreen();
UnloadGameplayScreen();
UnloadLogoScreen();
UnloadTexture(atlas01);
UnloadTexture(atlas02);
UnloadSpriteFont(font);
UnloadShader(colorBlend); // Unload color overlay blending shader
UnloadSound(fxJump);
UnloadSound(fxDash);
UnloadSound(fxEatLeaves);
UnloadSound(fxHitResin);
UnloadSound(fxWind);
UnloadSound(fxDieSnake);
UnloadSound(fxDieDingo);
UnloadSound(fxDieOwl);
UnloadMusicStream(music);
CloseAudioDevice(); // Close audio device
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
#if !defined(PLATFORM_ANDROID)
return 0;
#endif
}
void TransitionToScreen(int screen)
{
onTransition = true;
transFromScreen = currentScreen;
transToScreen = screen;
}
void UpdateTransition(void)
{
if (!transFadeOut)
{
transAlpha += 0.05f;
if (transAlpha >= 1.0)
{
transAlpha = 1.0;
currentScreen = transToScreen;
transFadeOut = true;
framesCounter = 0;
}
}
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 one frame
void UpdateDrawFrame(void)
{
// Update
//----------------------------------------------------------------------------------
if (!onTransition)
{
switch (currentScreen)
{
case LOGO:
{
UpdateLogoScreen();
if (FinishLogoScreen()) TransitionToScreen(TITLE);
} break;
case TITLE:
{
UpdateTitleScreen();
// NOTE: FinishTitleScreen() return an int defining the screen to jump to
if (FinishTitleScreen() == 1)
{
UnloadTitleScreen();
//currentScreen = OPTIONS;
//InitOptionsScreen();
}
else if (FinishTitleScreen() == 2)
{
UnloadTitleScreen();
InitGameplayScreen();
TransitionToScreen(GAMEPLAY);
}
} break;
case GAMEPLAY:
{
UpdateGameplayScreen();
if (FinishGameplayScreen())
{
UnloadGameplayScreen();
InitEndingScreen();
TransitionToScreen(ENDING);
}
} break;
case ENDING:
{
UpdateEndingScreen();
if (FinishEndingScreen())
{
UnloadEndingScreen();
InitGameplayScreen();
TransitionToScreen(GAMEPLAY);
}
} break;
default: break;
}
}
else UpdateTransition();
UpdateMusicStream(music);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(WHITE);
switch (currentScreen)
{
case LOGO: DrawLogoScreen(); break;
case TITLE: DrawTitleScreen(); break;
case GAMEPLAY: DrawGameplayScreen(); break;
case ENDING: DrawEndingScreen(); break;
default: break;
}
if (onTransition) DrawTransition();
DrawFPS(20, GetScreenHeight() - 30);
DrawRectangle(GetScreenWidth() - 200, GetScreenHeight() - 50, 200, 40, Fade(WHITE, 0.6f));
DrawText("ALPHA VERSION", GetScreenWidth() - 180, GetScreenHeight() - 40, 20, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 898 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

View file

@ -0,0 +1,25 @@
#version 100
// Input vertex attributes
attribute vec3 vertexPosition;
attribute vec2 vertexTexCoord;
attribute vec4 vertexColor;
// Input uniform values
uniform mat4 mvpMatrix;
// Output vertex attributes (to fragment shader)
varying vec2 fragTexCoord;
varying vec4 fragColor;
// NOTE: Add here your custom variables
void main()
{
// Send vertex attributes to fragment shader
fragTexCoord = vertexTexCoord;
fragColor = vertexColor;
// Calculate final vertex position
gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
}

View file

@ -0,0 +1,63 @@
#version 100
precision mediump float;
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord;
in vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// NOTE: Add here your custom variables
vec3 BlendOverlay(vec3 base, vec3 blend)
{
float red;
float green;
float blue;
if (base.r < 0.5) red = 2.0*base.r*blend.r;
else red = 1.0 - 2.0*(1.0 - base.r)*(1.0 - blend.r);
if (base.g < 0.5) green = 2.0*base.g*blend.g;
else green = 1.0 - 2.0 *(1.0 - base.g)*(1.0 - blend.g);
if (base.b < 0.5) blue = 2.0*base.b*blend.b;
else blue = 1.0 - 2.0 *(1.0 - base.b)*(1.0 - blend.b);
return vec3(red, green, blue);
}
void main()
{
// Blending Overlay
vec4 base = texture2D(texture0, fragTexCoord);
// No blending shader -> 64 FPS (1280x720)
//gl_FragColor = base*fragColor;
// Option01 -> 50 FPS (1280x720), 200 FPS (640x360)
vec3 final = BlendOverlay(base.rgb, fragColor.rgb);
gl_FragColor = vec4(final.rgb, base.a*fragColor.a);
// Option02 (Doesn't work) -> 63 FPS (1280x720)
//float luminance = (base.r*0.2126) + (base.g*0.7152) + (base.b*0.0722);
//gl_FragColor = vec4(tint*luminance, base.a);
// Option03 (no branches, precalculated ifs) -> 28 FPS (1280x720)
/*
vec4 blend = fragColor;
//if (base.a == 0.0) discard; // No improvement
vec3 br = clamp(sign(base.rgb - vec3(0.5)), vec3(0.0), vec3(1.0));
vec3 multiply = 2.0 * base.rgb * blend.rgb;
vec3 screen = vec3(1.0) - 2.0 * (vec3(1.0) - base.rgb)*(vec3(1.0) - blend.rgb);
vec3 overlay = mix(multiply, screen, br);
vec3 finalColor = mix(base.rgb, overlay, blend.a);
gl_FragColor = vec4(finalColor, base.a);
*/
// Option04 (no branches, using built-in functions) -> 38 FPS (1280x720)
//gl_FragColor = vec4(mix(1 - 2*(1 - base.rgb)*(1 - tint), 2*base.rgb*tint, step(0.5, base.rgb)), base.a);
}

View file

@ -0,0 +1,25 @@
#version 330
// Input vertex attributes
in vec3 vertexPosition;
in vec2 vertexTexCoord;
in vec4 vertexColor;
// Input uniform values
uniform mat4 mvpMatrix;
// Output vertex attributes (to fragment shader)
out vec2 fragTexCoord;
out vec4 fragColor;
// NOTE: Add here your custom variables
void main()
{
// Send vertex attributes to fragment shader
fragTexCoord = vertexTexCoord;
fragColor = vertexColor;
// Calculate final vertex position
gl_Position = mvpMatrix*vec4(vertexPosition, 1.0);
}

View file

@ -0,0 +1,64 @@
#version 330
// Input vertex attributes (from vertex shader)
in vec2 fragTexCoord;
in vec4 fragColor;
// Input uniform values
uniform sampler2D texture0;
uniform vec4 colDiffuse;
// Output fragment color
out vec4 finalColor;
// NOTE: Add here your custom variables
vec3 BlendOverlay(vec3 base, vec3 blend)
{
float red;
float green;
float blue;
if (base.r < 0.5) red = 2.0*base.r*blend.r;
else red = 1.0 - 2.0*(1.0 - base.r)*(1.0 - blend.r);
if (base.g < 0.5) green = 2.0*base.g*blend.g;
else green = 1.0 - 2.0 *(1.0 - base.g)*(1.0 - blend.g);
if (base.b < 0.5) blue = 2.0*base.b*blend.b;
else blue = 1.0 - 2.0 *(1.0 - base.b)*(1.0 - blend.b);
return vec3(red, green, blue);
}
void main()
{
// Blending Overlay
vec4 base = texture2D(texture0, fragTexCoord);
// No blending shader -> 64 FPS (1280x720)
//gl_FragColor = base*tintColor;
// Option01 -> 50 FPS (1280x720), 200 FPS (640x360)
vec3 final = BlendOverlay(base.rgb, fragColor.rgb);
finalColor = vec4(final.rgb, base.a*fragColor.a);
// Option02 (Doesn't work) -> 63 FPS (1280x720)
//float luminance = (base.r*0.2126) + (base.g*0.7152) + (base.b*0.0722);
//gl_FragColor = vec4(tintColor.rgb*luminance, base.a);
// Option03 (no branches, precalculated ifs) -> 28 FPS (1280x720)
/*
vec4 blend = tintColor;
//if (base.a == 0.0) discard; // No improvement
vec3 br = clamp(sign(base.rgb - vec3(0.5)), vec3(0.0), vec3(1.0));
vec3 multiply = 2.0 * base.rgb * blend.rgb;
vec3 screen = vec3(1.0) - 2.0 * (vec3(1.0) - base.rgb)*(vec3(1.0) - blend.rgb);
vec3 overlay = mix(multiply, screen, br);
vec3 finalColor = mix(base.rgb, overlay, blend.a);
gl_FragColor = vec4(finalColor, base.a);
*/
// Option04 (no branches, using built-in functions) -> 38 FPS (1280x720)
//gl_FragColor = vec4(mix(1 - 2*(1 - base.rgb)*(1 - tintColor.rgb), 2*base.rgb*tintColor.rgb, step(0.5, base.rgb)), base.a);
}

View file

@ -0,0 +1,86 @@
#define ending_button_replay (Rectangle){ 974, 1403, 123, 123 }
#define ending_button_share (Rectangle){ 954, 1528, 123, 123 }
#define ending_button_shop (Rectangle){ 958, 1653, 123, 123 }
#define ending_button_trophy (Rectangle){ 1479, 386, 123, 123 }
#define ending_goals_board (Rectangle){ 2, 254, 761, 422 }
#define ending_goals_check_plate (Rectangle){ 316, 2006, 36, 34 }
#define ending_goals_check_v (Rectangle){ 1727, 239, 50, 42 }
#define ending_goals_check_x (Rectangle){ 354, 1885, 42, 51 }
#define ending_goals_icon_death (Rectangle){ 1382, 516, 60, 60 }
#define ending_goals_icon_leaves (Rectangle){ 1444, 516, 60, 60 }
#define ending_goals_icon_special (Rectangle){ 1506, 511, 60, 60 }
#define ending_goals_icon_time (Rectangle){ 1568, 511, 60, 60 }
#define ending_paint_back (Rectangle){ 765, 254, 258, 305 }
#define ending_paint_frame (Rectangle){ 103, 1028, 334, 393 }
#define ending_paint_koalabee (Rectangle){ 439, 1060, 219, 216 }
#define ending_paint_koaladingo (Rectangle){ 439, 1278, 219, 216 }
#define ending_paint_koalaeagle (Rectangle){ 405, 1496, 219, 216 }
#define ending_paint_koalafire (Rectangle){ 771, 643, 219, 216 }
#define ending_paint_koalageneric (Rectangle){ 516, 678, 253, 250 }
#define ending_paint_koalaowl (Rectangle){ 661, 1790, 100, 81 }
#define ending_paint_koalasnake (Rectangle){ 774, 861, 219, 216 }
#define ending_plate_frame (Rectangle){ 2, 2, 1052, 250 }
#define ending_plate_headbee (Rectangle){ 1318, 516, 62, 60 }
#define ending_plate_headdingo (Rectangle){ 1481, 182, 56, 70 }
#define ending_plate_headeagle (Rectangle){ 1974, 116, 39, 48 }
#define ending_plate_headowl (Rectangle){ 226, 1885, 68, 52 }
#define ending_plate_headsnake (Rectangle){ 65, 1968, 46, 67 }
#define ending_score_enemyicon (Rectangle){ 661, 1697, 113, 91 }
#define ending_score_frame (Rectangle){ 419, 1714, 119, 123 }
#define ending_score_frameback (Rectangle){ 540, 1714, 119, 123 }
#define ending_score_leavesicon (Rectangle){ 1387, 254, 135, 130 }
#define ending_score_planklarge (Rectangle){ 1056, 132, 525, 48 }
#define ending_score_planksmall (Rectangle){ 1583, 116, 389, 48 }
#define ending_score_seasonicon (Rectangle){ 925, 1265, 135, 136 }
#define ending_score_seasonneedle (Rectangle){ 2032, 2, 12, 45 }
#define gameplay_countdown_1 (Rectangle){ 660, 1302, 110, 216 }
#define gameplay_countdown_2 (Rectangle){ 2, 1750, 110, 216 }
#define gameplay_countdown_3 (Rectangle){ 114, 1728, 110, 216 }
#define gameplay_enemy_bee (Rectangle){ 1025, 486, 250, 60 }
#define gameplay_enemy_dingo (Rectangle){ 755, 1079, 240, 150 }
#define gameplay_enemy_eagle (Rectangle){ 1570, 2, 460, 80 }
#define gameplay_enemy_eagle_death (Rectangle){ 1327, 386, 150, 128 }
#define gameplay_enemy_owl (Rectangle){ 765, 561, 240, 80 }
#define gameplay_enemy_snake (Rectangle){ 1025, 254, 360, 128 }
#define gameplay_fx_eaglealert (Rectangle){ 660, 1060, 93, 240 }
#define gameplay_fx_lightraymid (Rectangle){ 2, 1028, 54, 710 }
#define gameplay_gui_leafcounter_base (Rectangle){ 626, 1520, 178, 175 }
#define gameplay_gui_leafcounter_cell (Rectangle){ 972, 1231, 32, 32 }
#define gameplay_gui_leafcounter_glow (Rectangle){ 806, 1519, 146, 146 }
#define gameplay_gui_leafcounter_pulsel (Rectangle){ 226, 1728, 157, 155 }
#define gameplay_gui_seasonsclock_base (Rectangle){ 772, 1265, 151, 150 }
#define gameplay_gui_seasonsclock_disc (Rectangle){ 103, 1423, 300, 303 }
#define gameplay_koala_dash (Rectangle){ 1079, 1528, 100, 100 }
#define gameplay_koala_die (Rectangle){ 1083, 1630, 100, 100 }
#define gameplay_koala_fly (Rectangle){ 114, 1946, 200, 100 }
#define gameplay_koala_idle (Rectangle){ 1025, 384, 300, 100 }
#define gameplay_koala_jump (Rectangle){ 1083, 1732, 100, 100 }
#define gameplay_koala_menu (Rectangle){ 806, 1667, 150, 100 }
#define gameplay_koala_transform (Rectangle){ 772, 1417, 200, 100 }
#define gameplay_props_burnttree (Rectangle){ 58, 1028, 43, 720 }
#define gameplay_props_fire_spritesheet (Rectangle){ 516, 930, 256, 128 }
#define gameplay_props_ice_sprite (Rectangle){ 385, 1728, 32, 128 }
#define gameplay_props_leaf_big (Rectangle){ 1857, 166, 64, 64 }
#define gameplay_props_leaf_lil (Rectangle){ 1923, 166, 64, 64 }
#define gameplay_props_leaf_mid (Rectangle){ 316, 1940, 64, 64 }
#define gameplay_props_resin_sprite (Rectangle){ 405, 1423, 32, 64 }
#define gameplay_props_whirlwind_spritesheet (Rectangle){ 1056, 2, 512, 128 }
#define particle_dandelion (Rectangle){ 354, 2006, 32, 32 }
#define particle_ecualyptusflower (Rectangle){ 1989, 166, 32, 32 }
#define particle_ecualyptusleaf (Rectangle){ 1989, 200, 32, 32 }
#define particle_hit (Rectangle){ 296, 1885, 56, 53 }
#define particle_icecrystal (Rectangle){ 419, 1839, 32, 32 }
#define particle_planetreeleaf (Rectangle){ 453, 1839, 32, 32 }
#define particle_waterdrop (Rectangle){ 487, 1839, 32, 32 }
#define title_facebook (Rectangle){ 1539, 182, 92, 92 }
#define title_googleplay (Rectangle){ 1524, 276, 92, 92 }
#define title_music_off (Rectangle){ 1790, 166, 65, 66 }
#define title_music_on (Rectangle){ 1277, 486, 39, 66 }
#define title_speaker_off (Rectangle){ 2, 1968, 61, 71 }
#define title_speaker_on (Rectangle){ 1727, 166, 61, 71 }
#define title_textsnow01 (Rectangle){ 1570, 84, 439, 30 }
#define title_textsnow02 (Rectangle){ 1056, 182, 423, 48 }
#define title_textsnow03 (Rectangle){ 755, 1231, 215, 32 }
#define title_textsnow04 (Rectangle){ 1056, 232, 414, 20 }
#define title_titletext (Rectangle){ 2, 678, 512, 348 }
#define title_twitter (Rectangle){ 1633, 166, 92, 92 }

View file

@ -0,0 +1,40 @@
#define background_fog02 (Rectangle){ 644, 2, 500, 311 }
#define background_transformation (Rectangle){ 2, 364, 500, 400 }
#define ending_background (Rectangle){ 2, 766, 256, 256 }
#define gameplay_back_fx_lightraymid (Rectangle){ 260, 766, 14, 216 }
#define gameplay_back_ground00 (Rectangle){ 1146, 2, 640, 77 }
#define gameplay_back_ground01 (Rectangle){ 1146, 81, 640, 77 }
#define gameplay_back_ground02 (Rectangle){ 1146, 160, 640, 77 }
#define gameplay_back_ground03 (Rectangle){ 1146, 239, 640, 77 }
#define gameplay_back_tree01_layer01 (Rectangle){ 1833, 353, 28, 335 }
#define gameplay_back_tree01_layer02 (Rectangle){ 1998, 338, 28, 335 }
#define gameplay_back_tree01_layer03 (Rectangle){ 660, 315, 28, 335 }
#define gameplay_back_tree02_layer01 (Rectangle){ 690, 315, 26, 332 }
#define gameplay_back_tree02_layer02 (Rectangle){ 718, 315, 26, 332 }
#define gameplay_back_tree02_layer03 (Rectangle){ 746, 315, 26, 332 }
#define gameplay_back_tree03_layer01 (Rectangle){ 2028, 338, 15, 329 }
#define gameplay_back_tree03_layer02 (Rectangle){ 774, 315, 15, 329 }
#define gameplay_back_tree03_layer03 (Rectangle){ 791, 315, 15, 329 }
#define gameplay_back_tree04_layer01 (Rectangle){ 1860, 2, 38, 334 }
#define gameplay_back_tree04_layer02 (Rectangle){ 1900, 2, 38, 334 }
#define gameplay_back_tree04_layer03 (Rectangle){ 1940, 2, 38, 334 }
#define gameplay_back_tree05_layer01 (Rectangle){ 504, 364, 32, 349 }
#define gameplay_back_tree05_layer02 (Rectangle){ 538, 364, 32, 349 }
#define gameplay_back_tree05_layer03 (Rectangle){ 572, 364, 32, 349 }
#define gameplay_back_tree06_layer01 (Rectangle){ 1980, 2, 31, 334 }
#define gameplay_back_tree06_layer02 (Rectangle){ 2013, 2, 31, 334 }
#define gameplay_back_tree06_layer03 (Rectangle){ 1863, 338, 31, 334 }
#define gameplay_back_tree07_layer01 (Rectangle){ 606, 364, 25, 349 }
#define gameplay_back_tree07_layer02 (Rectangle){ 633, 364, 25, 349 }
#define gameplay_back_tree07_layer03 (Rectangle){ 1833, 2, 25, 349 }
#define gameplay_back_tree08_layer01 (Rectangle){ 1896, 338, 32, 331 }
#define gameplay_back_tree08_layer02 (Rectangle){ 1930, 338, 32, 331 }
#define gameplay_back_tree08_layer03 (Rectangle){ 1964, 338, 32, 331 }
#define gameplay_background (Rectangle){ 2, 2, 640, 360 }
#define gameplay_props_owl_branch (Rectangle){ 808, 349, 36, 24 }
#define gameplay_props_tree (Rectangle){ 1788, 2, 43, 720 }
#define particle_dandelion_bw (Rectangle){ 504, 715, 32, 32 }
#define particle_ecualyptusflower_bw (Rectangle){ 808, 315, 32, 32 }
#define particle_icecrystal_bw (Rectangle){ 276, 766, 32, 32 }
#define particle_planetreeleaf_bw (Rectangle){ 538, 715, 32, 32 }
#define particle_waterdrop_bw (Rectangle){ 842, 315, 32, 32 }

View file

@ -0,0 +1,530 @@
/**********************************************************************************************
*
* raylib - Koala Seasons game
*
* Ending Screen Functions Definitions (Init, Update, Draw, Unload)
*
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
*
* 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 <stdio.h>
#include "atlas01.h"
#include "atlas02.h"
typedef enum { DELAY, SEASONS, LEAVES, KILLS, REPLAY } EndingCounter;
typedef struct {
Vector2 position;
Vector2 speed;
float rotation;
float size;
Color color;
float alpha;
bool active;
} Particle;
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
// Ending screen global variables
static EndingCounter endingCounter;
static int framesCounter;
static int finishScreen;
static int framesKillsCounter;
static Rectangle playButton;
static Rectangle shopButton;
static Rectangle trophyButton;
static Rectangle shareButton;
static Color buttonPlayColor;
static Color buttonShopColor;
static Color buttonTrophyColor;
static Color buttonShareColor;
static Color backgroundColor;
static int currentScore;
static int seasonsCounter;
static int currentLeavesEnding;
static int finalYears;
static int replayTimer;
static int yearsElapsed;
static int initRotation;
static float clockRotation;
static float finalRotation;
static bool replaying;
static bool active[MAX_KILLS];
static char initMonthText[32];
static char finalMonthText[32];
static Particle leafParticles[20];
static int drawTimer;
// Death texts
const char textOwl01[32] = "Turned into a pretty";
const char textOwl02[32] = "owl pellet";
const char textDingo01[32] = "A dingo took your life";
const char textFire01[32] = "Kissed by fire";
const char textSnake01[32] = "Digested alive by a";
const char textSnake02[32] = "big snake";
const char textNaturalDeath01[32] = "LIFE KILLED YOU";
const char textBee01[32] = "You turn out to be";
const char textBee02[32] = "allergic to bee sting";
const char textEagle[32] = "KOALA IS DEAD :(";
static float LinearEaseIn(float t, float b, float c, float d) { return c*t/d + b; }
//----------------------------------------------------------------------------------
// Ending Screen Functions Definition
//----------------------------------------------------------------------------------
// Ending Screen Initialization logic
void InitEndingScreen(void)
{
framesCounter = -10;
finishScreen = 0;
drawTimer = 15;
replayTimer = 0;
replaying = false;
finalYears = initYears + (seasons/4);
yearsElapsed = seasons/4;
playButton = (Rectangle){ GetScreenWidth()*0.871, GetScreenHeight()*0.096, 123, 123};
shopButton = (Rectangle){ GetScreenWidth()*0.871, GetScreenHeight()*0.303, 123, 123};
trophyButton = (Rectangle){ GetScreenWidth()*0.871, GetScreenHeight()*0.513, 123, 123};
shareButton = (Rectangle){ GetScreenWidth()*0.871, GetScreenHeight()*0.719, 123, 123};
buttonPlayColor = WHITE;
buttonShopColor = WHITE;
buttonTrophyColor = WHITE;
buttonShareColor = WHITE;
currentScore = 0;
seasonsCounter = 0;
currentLeavesEnding = 0;
endingCounter = DELAY;
backgroundColor = (Color){ 176, 167, 151, 255};
for (int j = 0; j < 20; j++)
{
leafParticles[j].active = false;
leafParticles[j].position = (Vector2){ GetRandomValue(-20, 20), GetRandomValue(-20, 20) };
leafParticles[j].speed = (Vector2){ (float)GetRandomValue(-500, 500)/100, (float)GetRandomValue(-500, 500)/100 };
leafParticles[j].size = (float)GetRandomValue(3, 10)/5;
leafParticles[j].rotation = GetRandomValue(0, 360);
leafParticles[j].color = WHITE;
leafParticles[j].alpha = 1;
}
// Seasons death texts
if (initSeason == 0)
{
sprintf(initMonthText, "SUMMER");
clockRotation = 225;
initRotation = 225;
}
else if (initSeason == 1)
{
sprintf(initMonthText, "AUTUMN");
clockRotation = 135;
initRotation = 135;
}
else if (initSeason == 2)
{
sprintf(initMonthText, "WINTER");
clockRotation = 45;
initRotation = 45;
}
else if (initSeason == 3)
{
sprintf(initMonthText, "SPRING");
clockRotation = 315;
initRotation = 315;
}
if (currentSeason == 0)
{
sprintf(finalMonthText, "SUMMER");
finalRotation = 225 + 360*yearsElapsed;
}
else if (currentSeason == 1)
{
sprintf(finalMonthText, "AUTUMN");
finalRotation = 135 + 360*yearsElapsed;
}
else if (currentSeason == 2)
{
sprintf(finalMonthText, "WINTER");
finalRotation = 45 + 360*yearsElapsed;
}
else if (currentSeason == 3)
{
sprintf(finalMonthText, "SPRING");
finalRotation = 315 + 360*yearsElapsed;
}
for (int i = 0; i < MAX_KILLS; i++) active[i] = false;
}
// Ending Screen Update logic
void UpdateEndingScreen(void)
{
framesCounter += 1*TIME_FACTOR;
switch (endingCounter)
{
case DELAY:
{
if(framesCounter >= 10)
{
endingCounter = SEASONS;
framesCounter = 0;
}
} break;
case SEASONS:
{
if (seasons > 0)
{
seasonsCounter = (int)LinearEaseIn((float)framesCounter, 0.0f, (float)(seasons), 90.0f);
clockRotation = LinearEaseIn((float)framesCounter, (float)initRotation, (float)-(finalRotation - initRotation), 90.0f);
if (framesCounter >= 90)
{
endingCounter = LEAVES;
framesCounter = 0;
}
}
else endingCounter = LEAVES;
#if (defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB))
if (IsGestureDetected(GESTURE_TAP))
{
seasonsCounter = seasons;
clockRotation = finalRotation;
framesCounter = 0;
endingCounter = LEAVES;
}
#elif (defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB))
if (IsKeyPressed(KEY_ENTER))
{
seasonsCounter = seasons;
clockRotation = finalRotation;
framesCounter = 0;
endingCounter = LEAVES;
}
#endif
} break;
case LEAVES:
{
if (currentLeaves > 0)
{
if (currentLeavesEnding == currentLeaves)
{
endingCounter = KILLS;
framesCounter = 0;
}
else if (currentLeavesEnding < currentLeaves)
{
if (framesCounter >= 4)
{
currentLeavesEnding += 1;
framesCounter = 0;
}
for (int i = 0; i < 20; i++)
{
if (!leafParticles[i].active)
{
leafParticles[i].position = (Vector2){ GetScreenWidth()*0.46, GetScreenHeight()*0.32};
leafParticles[i].alpha = 1.0f;
leafParticles[i].active = true;
}
}
}
}
else endingCounter = KILLS;
#if (defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB))
if (IsGestureDetected(GESTURE_TAP))
{
currentLeavesEnding = currentLeaves;
framesCounter = 0;
endingCounter = KILLS;
}
#elif (defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB))
if (IsKeyPressed(KEY_ENTER))
{
currentLeavesEnding = currentLeaves;
framesCounter = 0;
endingCounter = KILLS;
}
#endif
} break;
case KILLS:
{
if (score > 0)
{
if (framesCounter <= 90 && !replaying)
{
currentScore = (int)LinearEaseIn((float)framesCounter, 0.0f, (float)(score), 90.0f);
}
framesKillsCounter += 1*TIME_FACTOR;
for (int i = 0; i < MAX_KILLS; i++)
{
if (framesKillsCounter >= drawTimer && active[i] == false)
{
active[i] = true;
framesKillsCounter = 0;
}
}
if (framesCounter >= 90)
{
endingCounter = REPLAY;
framesCounter = 0;
}
}
else endingCounter = REPLAY;
#if (defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB))
if (IsGestureDetected(GESTURE_TAP))
{
currentScore = score;
framesCounter = 0;
for (int i = 0; i < MAX_KILLS; i++) active[i] = true;
endingCounter = REPLAY;
}
#elif (defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB))
if (IsKeyPressed(KEY_ENTER))
{
currentScore = score;
framesCounter = 0;
for (int i = 0; i < MAX_KILLS; i++) active[i] = true;
endingCounter = REPLAY;
}
#endif
} break;
case REPLAY:
{
#if (defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB))
if (IsGestureDetected(GESTURE_TAP)) replaying = true;
#elif (defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB))
if (IsKeyPressed(KEY_ENTER)) replaying = true;
#endif
if (replaying)
{
replayTimer += 1*TIME_FACTOR;
if (replayTimer >= 30)
{
finishScreen = 1;
initSeason = GetRandomValue(0, 3);
}
buttonPlayColor = GOLD;
}
} break;
}
for (int i = 0; i < 20; i++)
{
if (leafParticles[i].active == true)
{
leafParticles[i].position.x += leafParticles[i].speed.x;
leafParticles[i].position.y += leafParticles[i].speed.y;
leafParticles[i].rotation += 6;
leafParticles[i].alpha -= 0.03f;
leafParticles[i].size -= 0.004;
if (leafParticles[i].size <= 0) leafParticles[i].size = 0.0f;
if (leafParticles[i].alpha <= 0)
{
leafParticles[i].alpha = 0.0f;
leafParticles[i].active = false;
}
}
}
// Buttons logic
#if (defined(PLATFORM_ANDROID) || defined(PLATFORM_WEB))
if ((IsGestureDetected(GESTURE_TAP)) && CheckCollisionPointRec(GetTouchPosition(0), playButton))
{
endingCounter = REPLAY;
replaying = true;
}
#elif (defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB))
if (CheckCollisionPointRec(GetMousePosition(), playButton))
{
buttonPlayColor = GOLD;
if (IsMouseButtonPressed(0))
{
endingCounter = REPLAY;
replaying = true;
}
}
else buttonPlayColor = WHITE;
if (CheckCollisionPointRec(GetMousePosition(), shopButton)) buttonShopColor = GOLD;
else buttonShopColor = WHITE;
if (CheckCollisionPointRec(GetMousePosition(), trophyButton)) buttonTrophyColor = GOLD;
else buttonTrophyColor = WHITE;
if (CheckCollisionPointRec(GetMousePosition(), shareButton)) buttonShareColor = GOLD;
else buttonShareColor = WHITE;
#endif
}
// Ending Screen Draw logic
void DrawEndingScreen(void)
{
for (int x = 0; x < 15; x++)
{
DrawTextureRec(atlas02, ending_background, (Vector2){ending_background.width*(x%5), ending_background.height*(x/5)}, backgroundColor);
}
// Frames and backgrounds
DrawTexturePro(atlas01, ending_plate_frame, (Rectangle){GetScreenWidth()*0.042, GetScreenHeight()*0.606, ending_plate_frame.width, ending_plate_frame.height}, (Vector2){ 0, 0}, 0, WHITE);
DrawTexturePro(atlas01, ending_paint_back, (Rectangle){GetScreenWidth()*0.133, GetScreenHeight()*0.097, ending_paint_back.width, ending_paint_back.height}, (Vector2){ 0, 0}, 0, WHITE);
if (killer == 0) DrawTexturePro(atlas01, ending_paint_koalafire, (Rectangle){GetScreenWidth()*0.145, GetScreenHeight()*0.171, ending_paint_koalafire.width, ending_paint_koalafire.height}, (Vector2){ 0, 0}, 0, WHITE);
else if (killer == 1) DrawTexturePro(atlas01, ending_paint_koalasnake, (Rectangle){GetScreenWidth()*0.145, GetScreenHeight()*0.171, ending_paint_koalasnake.width, ending_paint_koalasnake.height}, (Vector2){ 0, 0}, 0, WHITE);
else if (killer == 2) DrawTexturePro(atlas01, ending_paint_koaladingo, (Rectangle){GetScreenWidth()*0.145, GetScreenHeight()*0.171, ending_paint_koaladingo.width, ending_paint_koaladingo.height}, (Vector2){ 0, 0}, 0, WHITE);
else if (killer == 3) DrawTexturePro(atlas01, ending_paint_koalaowl, (Rectangle){GetScreenWidth()*0.2, GetScreenHeight()*0.3, ending_paint_koalaowl.width, ending_paint_koalaowl.height}, (Vector2){ 0, 0}, 0, WHITE);
else if (killer == 4) DrawTexturePro(atlas01, ending_paint_koalageneric, (Rectangle){GetScreenWidth()*0.133, GetScreenHeight()*0.171, ending_paint_koalageneric.width, ending_paint_koalageneric.height}, (Vector2){ 0, 0}, 0, WHITE);
else if (killer == 5) DrawTexturePro(atlas01, ending_paint_koalabee, (Rectangle){GetScreenWidth()*0.145, GetScreenHeight()*0.171, ending_paint_koalabee.width, ending_paint_koalabee.height}, (Vector2){ 0, 0}, 0, WHITE);
else if (killer == 6) DrawTexturePro(atlas01, ending_paint_koalaeagle, (Rectangle){GetScreenWidth()*0.145, GetScreenHeight()*0.171, ending_paint_koalaeagle.width, ending_paint_koalaeagle.height}, (Vector2){ 0, 0}, 0, WHITE);
DrawTexturePro(atlas01, ending_paint_frame, (Rectangle){GetScreenWidth()*0.102, GetScreenHeight()*0.035, ending_paint_frame.width, ending_paint_frame.height}, (Vector2){ 0, 0}, 0, WHITE);
// UI Score planks
DrawTexturePro(atlas01, ending_score_planksmall, (Rectangle){GetScreenWidth()*0.521, GetScreenHeight()*0.163, ending_score_planksmall.width, ending_score_planksmall.height}, (Vector2){ 0, 0}, 0, WHITE);
DrawTexturePro(atlas01, ending_score_planklarge, (Rectangle){GetScreenWidth()*0.415, GetScreenHeight()*0.303, ending_score_planklarge.width, ending_score_planklarge.height}, (Vector2){ 0, 0}, 0, WHITE);
DrawTexturePro(atlas01, ending_score_planksmall, (Rectangle){GetScreenWidth()*0.521, GetScreenHeight()*0.440, ending_score_planksmall.width, ending_score_planksmall.height}, (Vector2){ 0, 0}, 0, WHITE);
// UI Score icons and frames
DrawTexturePro(atlas01, ending_score_seasonicon, (Rectangle){GetScreenWidth()*0.529, GetScreenHeight()*0.096, ending_score_seasonicon.width, ending_score_seasonicon.height}, (Vector2){ 0, 0}, 0, WHITE);
DrawTexturePro(atlas01, ending_score_seasonneedle, (Rectangle){GetScreenWidth()*0.579, GetScreenHeight()*0.189, ending_score_seasonneedle.width, ending_score_seasonneedle.height}, (Vector2){ending_score_seasonneedle.width/2, ending_score_seasonneedle.height*0.9}, clockRotation, WHITE);
DrawTexturePro(atlas01, ending_score_frame, (Rectangle){GetScreenWidth()*0.535, GetScreenHeight()*0.11, ending_score_frame.width, ending_score_frame.height}, (Vector2){ 0, 0}, 0, WHITE);
DrawTexturePro(atlas01, ending_score_frameback, (Rectangle){GetScreenWidth()*0.430, GetScreenHeight()*0.246, ending_score_frameback.width, ending_score_frameback.height}, (Vector2){ 0, 0}, 0, WHITE);
DrawTexturePro(atlas01, ending_score_frame, (Rectangle){GetScreenWidth()*0.429, GetScreenHeight()*0.244, ending_score_frame.width, ending_score_frame.height}, (Vector2){ 0, 0}, 0, WHITE);
for (int i = 0; i < 20; i++)
{
if (leafParticles[i].active)
{
DrawTexturePro(atlas01, particle_ecualyptusleaf,
(Rectangle){ leafParticles[i].position.x, leafParticles[i].position.y, particle_ecualyptusleaf.width*leafParticles[i].size, particle_ecualyptusleaf.height*leafParticles[i].size },
(Vector2){ particle_ecualyptusleaf.width/2*leafParticles[i].size, particle_ecualyptusleaf.height/2*leafParticles[i].size }, leafParticles[i].rotation, Fade(WHITE,leafParticles[i].alpha));
}
}
DrawTexturePro(atlas01, ending_score_leavesicon, (Rectangle){GetScreenWidth()*0.421, GetScreenHeight()*0.228, ending_score_leavesicon.width, ending_score_leavesicon.height}, (Vector2){ 0, 0}, 0, WHITE);
DrawTexturePro(atlas01, ending_score_frameback, (Rectangle){GetScreenWidth()*0.536, GetScreenHeight()*0.383, ending_score_frameback.width, ending_score_frameback.height}, (Vector2){ 0, 0}, 0, WHITE);
DrawTexturePro(atlas01, ending_score_frame, (Rectangle){GetScreenWidth()*0.535, GetScreenHeight()*0.383, ending_score_frame.width, ending_score_frame.height}, (Vector2){ 0, 0}, 0, WHITE);
DrawTexturePro(atlas01, ending_score_enemyicon, (Rectangle){GetScreenWidth()*0.538, GetScreenHeight()*0.414, ending_score_enemyicon.width, ending_score_enemyicon.height}, (Vector2){ 0, 0}, 0, WHITE);
// UI Buttons
DrawTexturePro(atlas01, ending_button_replay, (Rectangle){GetScreenWidth()*0.871, GetScreenHeight()*0.096, ending_button_replay.width, ending_button_replay.height}, (Vector2){ 0, 0}, 0, buttonPlayColor);
DrawTexturePro(atlas01, ending_button_shop, (Rectangle){GetScreenWidth()*0.871, GetScreenHeight()*0.303, ending_button_shop.width, ending_button_shop.height}, (Vector2){ 0, 0}, 0, buttonShopColor);
DrawTexturePro(atlas01, ending_button_trophy, (Rectangle){GetScreenWidth()*0.871, GetScreenHeight()*0.513, ending_button_trophy.width, ending_button_trophy.height}, (Vector2){ 0, 0}, 0, buttonTrophyColor);
DrawTexturePro(atlas01, ending_button_share, (Rectangle){GetScreenWidth()*0.871, GetScreenHeight()*0.719, ending_button_share.width, ending_button_share.height}, (Vector2){ 0, 0}, 0, buttonShareColor);
DrawTextEx(font, FormatText("%03i", seasonsCounter), (Vector2){ GetScreenWidth()*0.73f, GetScreenHeight()*0.14f }, font.size, 1, WHITE);
DrawTextEx(font, FormatText("%03i", currentLeavesEnding), (Vector2){ GetScreenWidth()*0.73f, GetScreenHeight()*0.29f }, font.size, 1, WHITE);
DrawTextEx(font, FormatText("%04i", currentScore), (Vector2){ GetScreenWidth()*0.715f, GetScreenHeight()*0.426f }, font.size, 1, WHITE);
DrawTextEx(font, FormatText("%s %i - %s %i", initMonthText, initYears, finalMonthText, finalYears), (Vector2){ GetScreenWidth()*0.1f, GetScreenHeight()*0.7f }, font.size/2.0f, 1, WHITE);
for (int i = 0; i < MAX_KILLS; i++)
{
if (active[i])
{
switch (killHistory[i])
{
case 1: DrawTextureRec(atlas01, ending_plate_headsnake, (Vector2){GetScreenWidth()*0.448 + ending_plate_headsnake.width*(i%10), GetScreenHeight()*0.682 + (GetScreenHeight()*0.055)*(i/10)}, WHITE); break;
case 2: DrawTextureRec(atlas01, ending_plate_headdingo, (Vector2){GetScreenWidth()*0.448 + ending_plate_headdingo.width*(i%10), GetScreenHeight()*0.682 + (GetScreenHeight()*0.055)*(i/10)}, WHITE); break;
case 3: DrawTextureRec(atlas01, ending_plate_headowl, (Vector2){GetScreenWidth()*0.448 + ending_plate_headowl.width*(i%10), GetScreenHeight()*0.682 + (GetScreenHeight()*0.055)*(i/10)}, WHITE); break;
case 4: DrawTextureRec(atlas01, ending_plate_headbee, (Vector2){GetScreenWidth()*0.448 + ending_plate_headbee.width*(i%10), GetScreenHeight()*0.682 + (GetScreenHeight()*0.055)*(i/10)}, WHITE); break;
case 5: DrawTextureRec(atlas01, ending_plate_headeagle, (Vector2){GetScreenWidth()*0.448 + ending_plate_headeagle.width*(i%10), GetScreenHeight()*0.682 + (GetScreenHeight()*0.055)*(i/10)}, WHITE); break;
default: break;
}
}
}
/*
DrawText(FormatText("KOALA IS DEAD :("), GetScreenWidth()/2 - MeasureText("YOU'RE DEAD ", 60)/2, GetScreenHeight()/3, 60, RED);
DrawText(FormatText("Score: %02i - HiScore: %02i", score, hiscore),GetScreenWidth()/2 - MeasureText("Score: 00 - HiScore: 00", 60)/2, GetScreenHeight()/3 +100, 60, RED);
DrawText(FormatText("You lived: %02i years", years),GetScreenWidth()/2 - MeasureText("You lived: 00", 60)/2 + 60, GetScreenHeight()/3 +200, 30, RED);
DrawText(FormatText("%02s killed you", killer),GetScreenWidth()/2 - MeasureText("killer killed you", 60)/2 + 90, GetScreenHeight()/3 +270, 30, RED);
//DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(BLACK, 0.5));
*/
//DrawTextEx(font, FormatText("%02s", killer), (Vector2){ GetScreenWidth()*0.08, GetScreenHeight()*0.78 }, font.size/2, 1, WHITE);
if (killer == 0) DrawTextEx(font, textFire01, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.78f }, font.size/2.0f, 1, WHITE);
else if (killer == 2) DrawTextEx(font, textDingo01, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.78f }, font.size/2.0f, 1, WHITE);
else if (killer == 1)
{
DrawTextEx(font, textSnake01, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.78f }, font.size/2.0f, 1, WHITE);
DrawTextEx(font, textSnake02, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.83f }, font.size/2.0f, 1, WHITE);
}
else if (killer == 3)
{
DrawTextEx(font, textOwl01, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.78f }, font.size/2.0f, 1, WHITE);
DrawTextEx(font, textOwl02, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.83f }, font.size/2.0f, 1, WHITE);
}
else if (killer == 4) DrawTextEx(font, textNaturalDeath01, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.78f }, font.size/2.0f, 1, WHITE);
else if (killer == 5)
{
DrawTextEx(font, textBee01, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.78f }, font.size/2.0f, 1, WHITE);
DrawTextEx(font, textBee02, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.83f }, font.size/2.0f, 1, WHITE);
}
else if (killer == 6) DrawTextEx(font, textEagle, (Vector2){ GetScreenWidth()*0.13f, GetScreenHeight()*0.78f }, font.size/2.0f, 1, WHITE);
}
// Ending Screen Unload logic
void UnloadEndingScreen(void)
{
// ...
}
// Ending Screen should finish?
int FinishEndingScreen(void)
{
return finishScreen;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,227 @@
/**********************************************************************************************
*
* raylib - Standard 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"
#include <string.h>
//----------------------------------------------------------------------------------
// Global Variables Definition (local to this module)
//----------------------------------------------------------------------------------
// Logo screen global variables
static int framesCounter;
static int finishScreen;
const char msgLogoA[64] = "A simple and easy-to-use library";
const char msgLogoB[64] = "to learn videogames programming";
int logoPositionX;
int logoPositionY;
int raylibLettersCount = 0;
int topSideRecWidth = 16;
int leftSideRecHeight = 16;
int bottomSideRecWidth = 16;
int rightSideRecHeight = 16;
char raylib[8] = " \0"; // raylib text array, max 8 letters
int logoScreenState = 0; // Tracking animation states (State Machine)
bool msgLogoADone = false;
bool msgLogoBDone = false;
int lettersCounter = 0;
char msgBuffer[128] = { ' ' };
//----------------------------------------------------------------------------------
// Logo Screen Functions Definition
//----------------------------------------------------------------------------------
// Logo Screen Initialization logic
void InitLogoScreen(void)
{
// Initialize LOGO screen variables here!
framesCounter = 0;
finishScreen = 0;
logoPositionX = GetScreenWidth()/2 - 128;
logoPositionY = GetScreenHeight()/2 - 128;
}
// Logo Screen Update logic
void UpdateLogoScreen(void)
{
// Update LOGO screen
framesCounter++; // Count frames
// Update LOGO screen variables
if (logoScreenState == 0) // State 0: Small box blinking
{
framesCounter++;
if (framesCounter == 120)
{
logoScreenState = 1;
framesCounter = 0; // Reset counter... will be used later...
}
}
else if (logoScreenState == 1) // State 1: Top and left bars growing
{
topSideRecWidth += 4;
leftSideRecHeight += 4;
if (topSideRecWidth == 256) logoScreenState = 2;
}
else if (logoScreenState == 2) // State 2: Bottom and right bars growing
{
bottomSideRecWidth += 4;
rightSideRecHeight += 4;
if (bottomSideRecWidth == 256)
{
lettersCounter = 0;
for (int i = 0; i < (int)strlen(msgBuffer); i++) msgBuffer[i] = ' ';
logoScreenState = 3;
}
}
else if (logoScreenState == 3) // State 3: Letters appearing (one by one)
{
framesCounter++;
// Every 12 frames, one more letter!
if ((framesCounter%12) == 0) raylibLettersCount++;
switch (raylibLettersCount)
{
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;
}
if (raylibLettersCount >= 10)
{
// Write raylib description messages
if ((framesCounter%2) == 0) lettersCounter++;
if (!msgLogoADone)
{
if (lettersCounter <= (int)strlen(msgLogoA)) strncpy(msgBuffer, msgLogoA, lettersCounter);
else
{
for (int i = 0; i < (int)strlen(msgBuffer); i++) msgBuffer[i] = ' ';
lettersCounter = 0;
msgLogoADone = true;
}
}
else if (!msgLogoBDone)
{
if (lettersCounter <= (int)strlen(msgLogoB)) strncpy(msgBuffer, msgLogoB, lettersCounter);
else
{
msgLogoBDone = true;
framesCounter = 0;
//PlaySound(levelWin);
}
}
}
}
// Wait for 2 seconds (60 frames) before jumping to TITLE screen
if (msgLogoBDone)
{
framesCounter++;
if (framesCounter > 150) finishScreen = true;
}
}
// Logo Screen Draw logic
void DrawLogoScreen(void)
{
// Draw LOGO screen
if (logoScreenState == 0)
{
if ((framesCounter/15)%2) DrawRectangle(logoPositionX, logoPositionY - 60, 16, 16, BLACK);
}
else if (logoScreenState == 1)
{
DrawRectangle(logoPositionX, logoPositionY - 60, topSideRecWidth, 16, BLACK);
DrawRectangle(logoPositionX, logoPositionY - 60, 16, leftSideRecHeight, BLACK);
}
else if (logoScreenState == 2)
{
DrawRectangle(logoPositionX, logoPositionY - 60, topSideRecWidth, 16, BLACK);
DrawRectangle(logoPositionX, logoPositionY - 60, 16, leftSideRecHeight, BLACK);
DrawRectangle(logoPositionX + 240, logoPositionY - 60, 16, rightSideRecHeight, BLACK);
DrawRectangle(logoPositionX, logoPositionY + 240 - 60, bottomSideRecWidth, 16, BLACK);
}
else if (logoScreenState == 3)
{
DrawRectangle(logoPositionX, logoPositionY - 60, topSideRecWidth, 16, BLACK);
DrawRectangle(logoPositionX, logoPositionY + 16 - 60, 16, leftSideRecHeight - 32, BLACK);
DrawRectangle(logoPositionX + 240, logoPositionY + 16 - 60, 16, rightSideRecHeight - 32, BLACK);
DrawRectangle(logoPositionX, logoPositionY + 240 - 60, bottomSideRecWidth, 16, BLACK);
DrawRectangle(GetScreenWidth()/2 - 112, GetScreenHeight()/2 - 112 - 60, 224, 224, RAYWHITE);
DrawText(raylib, GetScreenWidth()/2 - 44, GetScreenHeight()/2 + 48 - 60, 50, BLACK);
if (!msgLogoADone) DrawText(msgBuffer, GetScreenWidth()/2 - MeasureText(msgLogoA, 30)/2, logoPositionY + 230, 30, GRAY);
else
{
DrawText(msgLogoA, GetScreenWidth()/2 - MeasureText(msgLogoA, 30)/2, logoPositionY + 230, 30, GRAY);
if (!msgLogoBDone) DrawText(msgBuffer, GetScreenWidth()/2 - MeasureText(msgLogoB, 30)/2, logoPositionY + 280, 30, GRAY);
else
{
DrawText(msgLogoB, GetScreenWidth()/2 - MeasureText(msgLogoA, 30)/2, logoPositionY + 280, 30, GRAY);
}
}
}
}
// Logo Screen Unload logic
void UnloadLogoScreen(void)
{
// TODO: Unload LOGO screen variables here!
}
// Logo Screen should finish?
int FinishLogoScreen(void)
{
return finishScreen;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,125 @@
/**********************************************************************************************
*
* raylib - Koala Seasons game
*
* Screens Functions Declarations (Init, Update, Draw, Unload)
*
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
*
* 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 GAME_FPS 60.0
#define TIME_FACTOR 60.0/GAME_FPS
#define MAX_KILLS 128
//----------------------------------------------------------------------------------
// Types and Structures Definition
//----------------------------------------------------------------------------------
typedef enum GameScreen { LOGO, TITLE, OPTIONS, GAMEPLAY, ENDING } GameScreen;
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
GameScreen currentScreen;
// NOTE: This is all the data used in the game
SpriteFont font;
Shader colorBlend;
Texture2D atlas01;
Texture2D atlas02;
Sound fxJump;
Sound fxDash;
Sound fxEatLeaves;
Sound fxDieSnake;
Sound fxDieDingo;
Sound fxDieOwl;
Sound fxHitResin;
Sound fxWind;
// Global Variables (required by ending screen and gameplay screen)
int score;
int hiscore;
int killHistory[MAX_KILLS];
int killer;
int seasons;
int years;
int currentLeaves;
int currentSeason;
int initSeason;
int initYears;
int rainChance;
#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);
//----------------------------------------------------------------------------------
// Title Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitTitleScreen(void);
void UpdateTitleScreen(void);
void DrawTitleScreen(void);
void UnloadTitleScreen(void);
int FinishTitleScreen(void);
//----------------------------------------------------------------------------------
// Options Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitOptionsScreen(void);
void UpdateOptionsScreen(void);
void DrawOptionsScreen(void);
void UnloadOptionsScreen(void);
int FinishOptionsScreen(void);
//----------------------------------------------------------------------------------
// Gameplay Screen Functions Declaration
//----------------------------------------------------------------------------------
void InitGameplayScreen(void);
void UpdateGameplayScreen(void);
void DrawGameplayScreen(void);
void UnloadGameplayScreen(void);
int FinishGameplayScreen(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