commit
a59433e7a3
69 changed files with 13418 additions and 2536 deletions
10
.gitignore
vendored
10
.gitignore
vendored
|
|
@ -1,13 +1,6 @@
|
||||||
# Ignore generated files
|
# Ignore generated files
|
||||||
# ...
|
# ...
|
||||||
|
|
||||||
# Ignore compiled binaries
|
|
||||||
src/*.o
|
|
||||||
src/*.exe
|
|
||||||
examples/*.o
|
|
||||||
examples/*.exe
|
|
||||||
templates/*.exe
|
|
||||||
|
|
||||||
# Ignore Android generated files and folders
|
# Ignore Android generated files and folders
|
||||||
src_android/obj/
|
src_android/obj/
|
||||||
templates/android_project/bin/
|
templates/android_project/bin/
|
||||||
|
|
@ -48,6 +41,9 @@ _ReSharper*/
|
||||||
[Tt]est[Rr]esult*
|
[Tt]est[Rr]esult*
|
||||||
ipch/
|
ipch/
|
||||||
*.opensdf
|
*.opensdf
|
||||||
|
|
||||||
|
# Ignore compiled binaries
|
||||||
|
*.o
|
||||||
*.exe
|
*.exe
|
||||||
!tools/rrem.exe
|
!tools/rrem.exe
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
# define raylib platform to compile for
|
# define raylib platform to compile for
|
||||||
# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB
|
# possible platforms: PLATFORM_DESKTOP PLATFORM_RPI PLATFORM_WEB
|
||||||
# WARNING: To compile examples to HTML5, they must be redesigned to use emscripten.h and emscripten_set_main_loop()
|
# WARNING: To compile to HTML5, code must be redesigned to use emscripten.h and emscripten_set_main_loop()
|
||||||
PLATFORM ?= PLATFORM_DESKTOP
|
PLATFORM ?= PLATFORM_DESKTOP
|
||||||
|
|
||||||
# determine PLATFORM_OS in case PLATFORM_DESKTOP selected
|
# determine PLATFORM_OS in case PLATFORM_DESKTOP selected
|
||||||
|
|
@ -113,20 +113,20 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
# libraries for Debian GNU/Linux desktop compiling
|
# libraries for Debian GNU/Linux desktop compiling
|
||||||
# requires the following packages:
|
# requires the following packages:
|
||||||
# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
|
# libopenal-dev libglew-dev libegl1-mesa-dev
|
||||||
LIBS = -lraylib -lglfw -lGLEW -lGL -lopenal
|
LIBS = -lraylib -lglfw3 -lGLEW -lGL -lopenal -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lm -pthread
|
||||||
endif
|
else
|
||||||
ifeq ($(PLATFORM_OS),OSX)
|
ifeq ($(PLATFORM_OS),OSX)
|
||||||
# libraries for OS X 10.9 desktop compiling
|
# libraries for OS X 10.9 desktop compiling
|
||||||
# requires the following packages:
|
# requires the following packages:
|
||||||
# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
|
# libglfw3-dev libopenal-dev libglew-dev libegl1-mesa-dev
|
||||||
LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa
|
LIBS = -lraylib -lglfw -framework OpenGL -framework OpenAl -framework Cocoa
|
||||||
|
|
||||||
else
|
else
|
||||||
# libraries for Windows desktop compiling
|
# libraries for Windows desktop compiling
|
||||||
# NOTE: GLFW3 and OpenAL Soft libraries should be installed
|
# NOTE: GLFW3 and OpenAL Soft libraries should be installed
|
||||||
LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32
|
LIBS = -lraylib -lglfw3 -lglew32 -lopengl32 -lopenal32 -lgdi32
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(PLATFORM),PLATFORM_RPI)
|
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||||
# libraries for Raspberry Pi compiling
|
# libraries for Raspberry Pi compiling
|
||||||
|
|
@ -327,8 +327,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
rm -f *.o
|
rm -f *.o
|
||||||
else
|
else
|
||||||
ifeq ($(PLATFORM_OS),LINUX)
|
ifeq ($(PLATFORM_OS),LINUX)
|
||||||
find . -type f -executable -delete
|
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
|
||||||
rm -f *.o
|
|
||||||
else
|
else
|
||||||
del *.o *.exe
|
del *.o *.exe
|
||||||
endif
|
endif
|
||||||
|
|
|
||||||
86
examples/models_custom_shader.c
Normal file
86
examples/models_custom_shader.c
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [models] example - Load and draw a 3d model (OBJ)
|
||||||
|
*
|
||||||
|
* This example has been created using raylib 1.0 (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"
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
int screenWidth = 1280;
|
||||||
|
int screenHeight = 720;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - custom shader");
|
||||||
|
|
||||||
|
// Define the camera to look into our 3d world
|
||||||
|
Camera camera = {{ 10.0, 8.0, 10.0 }, { 0.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }};
|
||||||
|
|
||||||
|
Texture2D texture = LoadTexture("resources/catsham.png"); // Load model texture
|
||||||
|
Shader shader = LoadShader("resources/shaders/custom.vs", "resources/shaders/custom.fs");
|
||||||
|
//Shader poste = LoadShader("resources/shaders/custom.vs", "resources/shaders/pixel.fs");
|
||||||
|
|
||||||
|
Model cat = LoadModel("resources/cat.obj"); // Load OBJ model
|
||||||
|
|
||||||
|
SetModelTexture(&cat, texture); // Bind texture to model
|
||||||
|
//SetModelShader(&cat, poste);
|
||||||
|
|
||||||
|
Vector3 catPosition = { 0.0, 0.0, 0.0 }; // Set model position
|
||||||
|
|
||||||
|
SetPostproShader(shader);
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsKeyDown(KEY_LEFT)) catPosition.x -= 0.2;
|
||||||
|
if (IsKeyDown(KEY_RIGHT)) catPosition.x += 0.2;
|
||||||
|
if (IsKeyDown(KEY_UP)) catPosition.z -= 0.2;
|
||||||
|
if (IsKeyDown(KEY_DOWN)) catPosition.z += 0.2;
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
Begin3dMode(camera);
|
||||||
|
|
||||||
|
DrawModel(cat, catPosition, 0.1f, WHITE); // Draw 3d model with texture
|
||||||
|
|
||||||
|
DrawGrid(10.0, 1.0); // Draw a grid
|
||||||
|
|
||||||
|
DrawGizmo(catPosition); // Draw gizmo
|
||||||
|
|
||||||
|
End3dMode();
|
||||||
|
|
||||||
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
UnloadTexture(texture); // Unload texture
|
||||||
|
UnloadModel(cat); // Unload model
|
||||||
|
UnloadShader(shader);
|
||||||
|
//UnloadShader(poste);
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
19
examples/resources/shaders/base.vs
Normal file
19
examples/resources/shaders/base.vs
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
#version 110
|
||||||
|
|
||||||
|
attribute vec3 vertexPosition;
|
||||||
|
attribute vec2 vertexTexCoord;
|
||||||
|
attribute vec4 vertexColor;
|
||||||
|
|
||||||
|
uniform mat4 projectionMatrix;
|
||||||
|
uniform mat4 modelviewMatrix;
|
||||||
|
|
||||||
|
varying vec2 fragTexCoord;
|
||||||
|
varying vec4 fragColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
fragTexCoord = vertexTexCoord;
|
||||||
|
fragColor = vertexColor;
|
||||||
|
|
||||||
|
gl_Position = projectionMatrix*modelviewMatrix*vec4(vertexPosition, 1.0);
|
||||||
|
}
|
||||||
16
examples/resources/shaders/custom.fs
Normal file
16
examples/resources/shaders/custom.fs
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#version 330
|
||||||
|
|
||||||
|
uniform sampler2D texture0;
|
||||||
|
varying vec2 fragTexCoord;
|
||||||
|
|
||||||
|
uniform vec4 tintColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec4 base = texture2D(texture0, fragTexCoord)*tintColor;
|
||||||
|
|
||||||
|
// Convert to grayscale using NTSC conversion weights
|
||||||
|
float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114));
|
||||||
|
|
||||||
|
gl_FragColor = vec4(gray, gray, gray, tintColor.a);
|
||||||
|
}
|
||||||
16
examples/resources/shaders/custom.vs
Normal file
16
examples/resources/shaders/custom.vs
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#version 330
|
||||||
|
|
||||||
|
attribute vec3 vertexPosition;
|
||||||
|
attribute vec2 vertexTexCoord;
|
||||||
|
attribute vec3 vertexNormal;
|
||||||
|
|
||||||
|
uniform mat4 projectionMatrix;
|
||||||
|
uniform mat4 modelviewMatrix;
|
||||||
|
|
||||||
|
varying vec2 fragTexCoord;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
fragTexCoord = vertexTexCoord;
|
||||||
|
gl_Position = projectionMatrix*modelviewMatrix*vec4(vertexPosition, 1.0);
|
||||||
|
}
|
||||||
15
examples/resources/shaders/grayscale.fs
Normal file
15
examples/resources/shaders/grayscale.fs
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
#version 110
|
||||||
|
|
||||||
|
uniform sampler2D texture0;
|
||||||
|
varying vec2 fragTexCoord;
|
||||||
|
varying vec4 fragColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec4 base = texture2D(texture0, fragTexCoord)*fragColor;
|
||||||
|
|
||||||
|
// Convert to grayscale using NTSC conversion weights
|
||||||
|
float gray = dot(base.rgb, vec3(0.299, 0.587, 0.114));
|
||||||
|
|
||||||
|
gl_FragColor = vec4(gray, gray, gray, base.a);
|
||||||
|
}
|
||||||
BIN
external/glfw3/glfw3.dll
vendored
BIN
external/glfw3/glfw3.dll
vendored
Binary file not shown.
1982
external/glfw3/include/GLFW/glfw3.h
vendored
1982
external/glfw3/include/GLFW/glfw3.h
vendored
File diff suppressed because it is too large
Load diff
212
external/glfw3/include/GLFW/glfw3native.h
vendored
212
external/glfw3/include/GLFW/glfw3native.h
vendored
|
|
@ -1,5 +1,5 @@
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* GLFW 3.0 - www.glfw.org
|
* GLFW 3.1 - www.glfw.org
|
||||||
* A library for OpenGL, window and input
|
* A library for OpenGL, window and input
|
||||||
*------------------------------------------------------------------------
|
*------------------------------------------------------------------------
|
||||||
* Copyright (c) 2002-2006 Marcus Geelnard
|
* Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
|
|
@ -40,13 +40,13 @@ extern "C" {
|
||||||
|
|
||||||
/*! @defgroup native Native access
|
/*! @defgroup native Native access
|
||||||
*
|
*
|
||||||
* **By using the native API, you assert that you know what you're doing and
|
* **By using the native access functions you assert that you know what you're
|
||||||
* how to fix problems caused by using it. If you don't, you shouldn't be
|
* doing and how to fix problems caused by using them. If you don't, you
|
||||||
* using it.**
|
* shouldn't be using them.**
|
||||||
*
|
*
|
||||||
* Before the inclusion of @ref glfw3native.h, you must define exactly one
|
* Before the inclusion of @ref glfw3native.h, you must define exactly one
|
||||||
* window API macro and exactly one context API macro. Failure to do this
|
* window system API macro and exactly one context creation API macro. Failure
|
||||||
* will cause a compile-time error.
|
* to do this will cause a compile-time error.
|
||||||
*
|
*
|
||||||
* The available window API macros are:
|
* The available window API macros are:
|
||||||
* * `GLFW_EXPOSE_NATIVE_WIN32`
|
* * `GLFW_EXPOSE_NATIVE_WIN32`
|
||||||
|
|
@ -71,8 +71,13 @@ extern "C" {
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_WIN32)
|
#if defined(GLFW_EXPOSE_NATIVE_WIN32)
|
||||||
|
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
||||||
|
// example to allow applications to correctly declare a GL_ARB_debug_output
|
||||||
|
// callback) but windows.h assumes no one will define APIENTRY before it does
|
||||||
|
#undef APIENTRY
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#elif defined(GLFW_EXPOSE_NATIVE_COCOA)
|
#elif defined(GLFW_EXPOSE_NATIVE_COCOA)
|
||||||
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
#if defined(__OBJC__)
|
#if defined(__OBJC__)
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#else
|
#else
|
||||||
|
|
@ -80,8 +85,9 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#elif defined(GLFW_EXPOSE_NATIVE_X11)
|
#elif defined(GLFW_EXPOSE_NATIVE_X11)
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/extensions/Xrandr.h>
|
||||||
#else
|
#else
|
||||||
#error "No window API specified"
|
#error "No window API selected"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_WGL)
|
#if defined(GLFW_EXPOSE_NATIVE_WGL)
|
||||||
|
|
@ -93,7 +99,7 @@ extern "C" {
|
||||||
#elif defined(GLFW_EXPOSE_NATIVE_EGL)
|
#elif defined(GLFW_EXPOSE_NATIVE_EGL)
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#else
|
#else
|
||||||
#error "No context API specified"
|
#error "No context API selected"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -102,8 +108,49 @@ extern "C" {
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_WIN32)
|
#if defined(GLFW_EXPOSE_NATIVE_WIN32)
|
||||||
|
/*! @brief Returns the adapter device name of the specified monitor.
|
||||||
|
*
|
||||||
|
* @return The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
|
||||||
|
* of the specified monitor, or `NULL` if an [error](@ref error_handling)
|
||||||
|
* occurred.
|
||||||
|
*
|
||||||
|
* @par Thread Safety
|
||||||
|
* This function may be called from any thread. Access is not synchronized.
|
||||||
|
*
|
||||||
|
* @par History
|
||||||
|
* Added in GLFW 3.1.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
|
||||||
|
|
||||||
|
/*! @brief Returns the display device name of the specified monitor.
|
||||||
|
*
|
||||||
|
* @return The UTF-8 encoded display device name (for example
|
||||||
|
* `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @par Thread Safety
|
||||||
|
* This function may be called from any thread. Access is not synchronized.
|
||||||
|
*
|
||||||
|
* @par History
|
||||||
|
* Added in GLFW 3.1.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
|
||||||
|
|
||||||
/*! @brief Returns the `HWND` of the specified window.
|
/*! @brief Returns the `HWND` of the specified window.
|
||||||
* @return The `HWND` of the specified window.
|
*
|
||||||
|
* @return The `HWND` of the specified window, or `NULL` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @par Thread Safety
|
||||||
|
* This function may be called from any thread. Access is not synchronized.
|
||||||
|
*
|
||||||
|
* @par History
|
||||||
|
* Added in GLFW 3.0.
|
||||||
|
*
|
||||||
* @ingroup native
|
* @ingroup native
|
||||||
*/
|
*/
|
||||||
GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
|
GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
|
||||||
|
|
@ -111,15 +158,48 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_WGL)
|
#if defined(GLFW_EXPOSE_NATIVE_WGL)
|
||||||
/*! @brief Returns the `HGLRC` of the specified window.
|
/*! @brief Returns the `HGLRC` of the specified window.
|
||||||
* @return The `HGLRC` of the specified window.
|
*
|
||||||
|
* @return The `HGLRC` of the specified window, or `NULL` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @par Thread Safety
|
||||||
|
* This function may be called from any thread. Access is not synchronized.
|
||||||
|
*
|
||||||
|
* @par History
|
||||||
|
* Added in GLFW 3.0.
|
||||||
|
*
|
||||||
* @ingroup native
|
* @ingroup native
|
||||||
*/
|
*/
|
||||||
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
|
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_COCOA)
|
#if defined(GLFW_EXPOSE_NATIVE_COCOA)
|
||||||
|
/*! @brief Returns the `CGDirectDisplayID` of the specified monitor.
|
||||||
|
*
|
||||||
|
* @return The `CGDirectDisplayID` of the specified monitor, or
|
||||||
|
* `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @par Thread Safety
|
||||||
|
* This function may be called from any thread. Access is not synchronized.
|
||||||
|
*
|
||||||
|
* @par History
|
||||||
|
* Added in GLFW 3.1.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
|
||||||
|
|
||||||
/*! @brief Returns the `NSWindow` of the specified window.
|
/*! @brief Returns the `NSWindow` of the specified window.
|
||||||
* @return The `NSWindow` of the specified window.
|
*
|
||||||
|
* @return The `NSWindow` of the specified window, or `nil` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @par Thread Safety
|
||||||
|
* This function may be called from any thread. Access is not synchronized.
|
||||||
|
*
|
||||||
|
* @par History
|
||||||
|
* Added in GLFW 3.0.
|
||||||
|
*
|
||||||
* @ingroup native
|
* @ingroup native
|
||||||
*/
|
*/
|
||||||
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
|
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
|
||||||
|
|
@ -127,7 +207,16 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
|
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
|
||||||
/*! @brief Returns the `NSOpenGLContext` of the specified window.
|
/*! @brief Returns the `NSOpenGLContext` of the specified window.
|
||||||
* @return The `NSOpenGLContext` of the specified window.
|
*
|
||||||
|
* @return The `NSOpenGLContext` of the specified window, or `nil` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @par Thread Safety
|
||||||
|
* This function may be called from any thread. Access is not synchronized.
|
||||||
|
*
|
||||||
|
* @par History
|
||||||
|
* Added in GLFW 3.0.
|
||||||
|
*
|
||||||
* @ingroup native
|
* @ingroup native
|
||||||
*/
|
*/
|
||||||
GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
|
GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
|
||||||
|
|
@ -135,12 +224,61 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_X11)
|
#if defined(GLFW_EXPOSE_NATIVE_X11)
|
||||||
/*! @brief Returns the `Display` used by GLFW.
|
/*! @brief Returns the `Display` used by GLFW.
|
||||||
* @return The `Display` used by GLFW.
|
*
|
||||||
|
* @return The `Display` used by GLFW, or `NULL` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @par Thread Safety
|
||||||
|
* This function may be called from any thread. Access is not synchronized.
|
||||||
|
*
|
||||||
|
* @par History
|
||||||
|
* Added in GLFW 3.0.
|
||||||
|
*
|
||||||
* @ingroup native
|
* @ingroup native
|
||||||
*/
|
*/
|
||||||
GLFWAPI Display* glfwGetX11Display(void);
|
GLFWAPI Display* glfwGetX11Display(void);
|
||||||
|
|
||||||
|
/*! @brief Returns the `RRCrtc` of the specified monitor.
|
||||||
|
*
|
||||||
|
* @return The `RRCrtc` of the specified monitor, or `None` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @par Thread Safety
|
||||||
|
* This function may be called from any thread. Access is not synchronized.
|
||||||
|
*
|
||||||
|
* @par History
|
||||||
|
* Added in GLFW 3.1.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
|
||||||
|
|
||||||
|
/*! @brief Returns the `RROutput` of the specified monitor.
|
||||||
|
*
|
||||||
|
* @return The `RROutput` of the specified monitor, or `None` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @par Thread Safety
|
||||||
|
* This function may be called from any thread. Access is not synchronized.
|
||||||
|
*
|
||||||
|
* @par History
|
||||||
|
* Added in GLFW 3.1.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
|
||||||
|
|
||||||
/*! @brief Returns the `Window` of the specified window.
|
/*! @brief Returns the `Window` of the specified window.
|
||||||
* @return The `Window` of the specified window.
|
*
|
||||||
|
* @return The `Window` of the specified window, or `None` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @par Thread Safety
|
||||||
|
* This function may be called from any thread. Access is not synchronized.
|
||||||
|
*
|
||||||
|
* @par History
|
||||||
|
* Added in GLFW 3.0.
|
||||||
|
*
|
||||||
* @ingroup native
|
* @ingroup native
|
||||||
*/
|
*/
|
||||||
GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
|
GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
|
||||||
|
|
@ -148,7 +286,16 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_GLX)
|
#if defined(GLFW_EXPOSE_NATIVE_GLX)
|
||||||
/*! @brief Returns the `GLXContext` of the specified window.
|
/*! @brief Returns the `GLXContext` of the specified window.
|
||||||
* @return The `GLXContext` of the specified window.
|
*
|
||||||
|
* @return The `GLXContext` of the specified window, or `NULL` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @par Thread Safety
|
||||||
|
* This function may be called from any thread. Access is not synchronized.
|
||||||
|
*
|
||||||
|
* @par History
|
||||||
|
* Added in GLFW 3.0.
|
||||||
|
*
|
||||||
* @ingroup native
|
* @ingroup native
|
||||||
*/
|
*/
|
||||||
GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
|
GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
|
||||||
|
|
@ -156,17 +303,46 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
|
||||||
|
|
||||||
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
||||||
/*! @brief Returns the `EGLDisplay` used by GLFW.
|
/*! @brief Returns the `EGLDisplay` used by GLFW.
|
||||||
* @return The `EGLDisplay` used by GLFW.
|
*
|
||||||
|
* @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @par Thread Safety
|
||||||
|
* This function may be called from any thread. Access is not synchronized.
|
||||||
|
*
|
||||||
|
* @par History
|
||||||
|
* Added in GLFW 3.0.
|
||||||
|
*
|
||||||
* @ingroup native
|
* @ingroup native
|
||||||
*/
|
*/
|
||||||
GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
|
GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
|
||||||
|
|
||||||
/*! @brief Returns the `EGLContext` of the specified window.
|
/*! @brief Returns the `EGLContext` of the specified window.
|
||||||
* @return The `EGLContext` of the specified window.
|
*
|
||||||
|
* @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @par Thread Safety
|
||||||
|
* This function may be called from any thread. Access is not synchronized.
|
||||||
|
*
|
||||||
|
* @par History
|
||||||
|
* Added in GLFW 3.0.
|
||||||
|
*
|
||||||
* @ingroup native
|
* @ingroup native
|
||||||
*/
|
*/
|
||||||
GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
|
GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
|
||||||
|
|
||||||
/*! @brief Returns the `EGLSurface` of the specified window.
|
/*! @brief Returns the `EGLSurface` of the specified window.
|
||||||
* @return The `EGLSurface` of the specified window.
|
*
|
||||||
|
* @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @par Thread Safety
|
||||||
|
* This function may be called from any thread. Access is not synchronized.
|
||||||
|
*
|
||||||
|
* @par History
|
||||||
|
* Added in GLFW 3.0.
|
||||||
|
*
|
||||||
* @ingroup native
|
* @ingroup native
|
||||||
*/
|
*/
|
||||||
GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
|
GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
|
||||||
|
|
|
||||||
BIN
external/glfw3/lib/linux/libglfw3.a
vendored
Normal file
BIN
external/glfw3/lib/linux/libglfw3.a
vendored
Normal file
Binary file not shown.
BIN
external/glfw3/lib/win32/libglfw3.a
vendored
BIN
external/glfw3/lib/win32/libglfw3.a
vendored
Binary file not shown.
BIN
external/glfw3/lib/win32/libglfw3dll.a
vendored
BIN
external/glfw3/lib/win32/libglfw3dll.a
vendored
Binary file not shown.
358
games/just_do_GGJ2015/src/just_do.c
Normal file
358
games/just_do_GGJ2015/src/just_do.c
Normal file
|
|
@ -0,0 +1,358 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* JUST DO - Global Game Jam 2015 Videogame
|
||||||
|
* Experimental puzzle game that lets the user try to find a logic solution to
|
||||||
|
* different shape-color-based situations.
|
||||||
|
*
|
||||||
|
* Developed by: Ramon Santamaria (Ray San)
|
||||||
|
*
|
||||||
|
* This game has been created using raylib (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* raylib - Copyright (c) 2015 Ramon Santamaria (Ray San - raysan@raysanweb.com)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#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)
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 1280; // Moved to screens.h
|
||||||
|
const int screenHeight = 720; // Moved to screens.h
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
int framesCounter = 0;
|
||||||
|
|
||||||
|
//static Sound levelWin;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Local Functions Declaration
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
void TransitionToScreen(int screen);
|
||||||
|
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] = "JUST DO";
|
||||||
|
|
||||||
|
//SetupFlags(FLAG_FULLSCREEN_MODE);
|
||||||
|
InitWindow(screenWidth, screenHeight, windowTitle);
|
||||||
|
|
||||||
|
// TODO: Load global data here (assets that must be available in all screens, i.e. fonts)
|
||||||
|
InitAudioDevice();
|
||||||
|
|
||||||
|
levelWin = LoadSound("resources/win.wav");
|
||||||
|
|
||||||
|
// 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
|
||||||
|
{
|
||||||
|
|
||||||
|
if (IsKeyPressed(KEY_SPACE)) PlaySound(levelWin);
|
||||||
|
|
||||||
|
UpdateDrawFrame();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// TODO: Unload all global loaded data (i.e. fonts) here!
|
||||||
|
UnloadSound(levelWin);
|
||||||
|
|
||||||
|
CloseAudioDevice();
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Local Functions Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
void TransitionToScreen(int screen)
|
||||||
|
{
|
||||||
|
onTransition = true;
|
||||||
|
transFromScreen = currentScreen;
|
||||||
|
transToScreen = screen;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateTransition(void)
|
||||||
|
{
|
||||||
|
if (!transFadeOut)
|
||||||
|
{
|
||||||
|
transAlpha += 0.02f;
|
||||||
|
|
||||||
|
if (transAlpha >= 1.0)
|
||||||
|
{
|
||||||
|
transAlpha = 1.0;
|
||||||
|
currentScreen = transToScreen;
|
||||||
|
transFadeOut = true;
|
||||||
|
framesCounter = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // Transition fade out logic
|
||||||
|
{
|
||||||
|
transAlpha -= 0.02f;
|
||||||
|
|
||||||
|
if (transAlpha <= 0)
|
||||||
|
{
|
||||||
|
transAlpha = 0;
|
||||||
|
transFadeOut = false;
|
||||||
|
onTransition = false;
|
||||||
|
transFromScreen = -1;
|
||||||
|
transToScreen = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawTransition(void)
|
||||||
|
{
|
||||||
|
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, transAlpha));
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateDrawFrame(void)
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
if (!onTransition)
|
||||||
|
{
|
||||||
|
if (IsKeyPressed('0'))
|
||||||
|
{
|
||||||
|
TransitionToScreen(LEVEL00);
|
||||||
|
InitLevel00Screen();
|
||||||
|
}
|
||||||
|
else if (IsKeyPressed('1'))
|
||||||
|
{
|
||||||
|
TransitionToScreen(LEVEL01);
|
||||||
|
InitLevel01Screen();
|
||||||
|
}
|
||||||
|
else if (IsKeyPressed('2'))
|
||||||
|
{
|
||||||
|
TransitionToScreen(LEVEL02);
|
||||||
|
InitLevel02Screen();
|
||||||
|
}
|
||||||
|
else if (IsKeyPressed('3'))
|
||||||
|
{
|
||||||
|
TransitionToScreen(LEVEL03);
|
||||||
|
InitLevel03Screen();
|
||||||
|
}
|
||||||
|
else if (IsKeyPressed('4'))
|
||||||
|
{
|
||||||
|
TransitionToScreen(LEVEL04);
|
||||||
|
InitLevel04Screen();
|
||||||
|
}
|
||||||
|
else if (IsKeyPressed('5'))
|
||||||
|
{
|
||||||
|
TransitionToScreen(LEVEL05);
|
||||||
|
InitLevel05Screen();
|
||||||
|
}
|
||||||
|
else if (IsKeyPressed('6'))
|
||||||
|
{
|
||||||
|
TransitionToScreen(LEVEL06);
|
||||||
|
InitLevel06Screen();
|
||||||
|
}
|
||||||
|
else if (IsKeyPressed('7'))
|
||||||
|
{
|
||||||
|
TransitionToScreen(LEVEL07);
|
||||||
|
InitLevel07Screen();
|
||||||
|
}
|
||||||
|
else if (IsKeyPressed('8'))
|
||||||
|
{
|
||||||
|
TransitionToScreen(LEVEL08);
|
||||||
|
InitLevel08Screen();
|
||||||
|
}
|
||||||
|
else if (IsKeyPressed('9'))
|
||||||
|
{
|
||||||
|
TransitionToScreen(LEVEL09);
|
||||||
|
InitLevel08Screen();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(currentScreen)
|
||||||
|
{
|
||||||
|
case LOGO:
|
||||||
|
{
|
||||||
|
UpdateLogoScreen();
|
||||||
|
|
||||||
|
if (FinishLogoScreen())
|
||||||
|
{
|
||||||
|
UnloadLogoScreen();
|
||||||
|
TransitionToScreen(LEVEL00);
|
||||||
|
InitLevel00Screen();
|
||||||
|
|
||||||
|
PlayMusicStream("resources/ambient.ogg");
|
||||||
|
SetMusicVolume(0.6f);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case LEVEL00:
|
||||||
|
{
|
||||||
|
UpdateLevel00Screen();
|
||||||
|
|
||||||
|
if (FinishLevel00Screen())
|
||||||
|
{
|
||||||
|
UnloadLevel00Screen();
|
||||||
|
TransitionToScreen(LEVEL01);
|
||||||
|
InitLevel01Screen();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case LEVEL01:
|
||||||
|
{
|
||||||
|
UpdateLevel01Screen();
|
||||||
|
|
||||||
|
if (FinishLevel01Screen())
|
||||||
|
{
|
||||||
|
UnloadLevel01Screen();
|
||||||
|
TransitionToScreen(LEVEL02);
|
||||||
|
InitLevel02Screen();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case LEVEL02:
|
||||||
|
{
|
||||||
|
UpdateLevel02Screen();
|
||||||
|
|
||||||
|
if (FinishLevel02Screen())
|
||||||
|
{
|
||||||
|
UnloadLevel02Screen();
|
||||||
|
TransitionToScreen(LEVEL03);
|
||||||
|
InitLevel03Screen();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case LEVEL03:
|
||||||
|
{
|
||||||
|
UpdateLevel03Screen();
|
||||||
|
|
||||||
|
if (FinishLevel03Screen())
|
||||||
|
{
|
||||||
|
UnloadLevel03Screen();
|
||||||
|
TransitionToScreen(LEVEL04);
|
||||||
|
InitLevel04Screen();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case LEVEL04:
|
||||||
|
{
|
||||||
|
UpdateLevel04Screen();
|
||||||
|
|
||||||
|
if (FinishLevel04Screen())
|
||||||
|
{
|
||||||
|
UnloadLevel04Screen();
|
||||||
|
TransitionToScreen(LEVEL05);
|
||||||
|
InitLevel05Screen();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case LEVEL05:
|
||||||
|
{
|
||||||
|
UpdateLevel05Screen();
|
||||||
|
|
||||||
|
if (FinishLevel05Screen())
|
||||||
|
{
|
||||||
|
UnloadLevel05Screen();
|
||||||
|
TransitionToScreen(LEVEL06);
|
||||||
|
InitLevel06Screen();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case LEVEL06:
|
||||||
|
{
|
||||||
|
UpdateLevel06Screen();
|
||||||
|
|
||||||
|
if (FinishLevel06Screen())
|
||||||
|
{
|
||||||
|
UnloadLevel06Screen();
|
||||||
|
TransitionToScreen(LEVEL07);
|
||||||
|
InitLevel07Screen();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case LEVEL07:
|
||||||
|
{
|
||||||
|
UpdateLevel07Screen();
|
||||||
|
|
||||||
|
if (FinishLevel07Screen())
|
||||||
|
{
|
||||||
|
UnloadLevel07Screen();
|
||||||
|
TransitionToScreen(LEVEL08);
|
||||||
|
InitLevel08Screen();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case LEVEL08:
|
||||||
|
{
|
||||||
|
UpdateLevel08Screen();
|
||||||
|
|
||||||
|
if (FinishLevel08Screen())
|
||||||
|
{
|
||||||
|
UnloadLevel08Screen();
|
||||||
|
TransitionToScreen(LEVEL09);
|
||||||
|
InitLevel09Screen();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
case LEVEL09:
|
||||||
|
{
|
||||||
|
UpdateLevel09Screen();
|
||||||
|
|
||||||
|
if (FinishLevel09Screen())
|
||||||
|
{
|
||||||
|
UnloadLevel09Screen();
|
||||||
|
TransitionToScreen(LEVEL00);
|
||||||
|
InitLevel00Screen();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else UpdateTransition(); // Update transition (fade-in, fade-out)
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
switch(currentScreen)
|
||||||
|
{
|
||||||
|
case LOGO: DrawLogoScreen(); break;
|
||||||
|
case LEVEL00: DrawLevel00Screen(); break;
|
||||||
|
case LEVEL01: DrawLevel01Screen(); break;
|
||||||
|
case LEVEL02: DrawLevel02Screen(); break;
|
||||||
|
case LEVEL03: DrawLevel03Screen(); break;
|
||||||
|
case LEVEL04: DrawLevel04Screen(); break;
|
||||||
|
case LEVEL05: DrawLevel05Screen(); break;
|
||||||
|
case LEVEL06: DrawLevel06Screen(); break;
|
||||||
|
case LEVEL07: DrawLevel07Screen(); break;
|
||||||
|
case LEVEL08: DrawLevel08Screen(); break;
|
||||||
|
case LEVEL09: DrawLevel09Screen(); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onTransition) DrawTransition();
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
246
games/just_do_GGJ2015/src/makefile
Normal file
246
games/just_do_GGJ2015/src/makefile
Normal file
|
|
@ -0,0 +1,246 @@
|
||||||
|
#**************************************************************************************************
|
||||||
|
#
|
||||||
|
# raylib - Advance Game
|
||||||
|
#
|
||||||
|
# makefile to compile advance game for desktop platforms, Raspberry Pi and HTML5 (emscripten)
|
||||||
|
#
|
||||||
|
# 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 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 = -O2 -Wall -std=c99 -s USE_GLFW=3
|
||||||
|
#-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
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_RPI)
|
||||||
|
INCLUDES = -I. -I../../src -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads
|
||||||
|
else
|
||||||
|
INCLUDES = -I. -I../../src -I../../../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. -L../../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 = ../../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 = ../../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_level00.o \
|
||||||
|
screens/screen_level01.o \
|
||||||
|
screens/screen_level02.o \
|
||||||
|
screens/screen_level03.o \
|
||||||
|
screens/screen_level04.o \
|
||||||
|
screens/screen_level05.o \
|
||||||
|
screens/screen_level06.o \
|
||||||
|
screens/screen_level07.o \
|
||||||
|
screens/screen_level08.o \
|
||||||
|
screens/screen_level09.o \
|
||||||
|
|
||||||
|
# typing 'make' will invoke the first target entry in the file,
|
||||||
|
# in this case, the 'default' target entry is just_do
|
||||||
|
default: just_do
|
||||||
|
|
||||||
|
# compile just_do
|
||||||
|
just_do: just_do.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 LEVEL00
|
||||||
|
screens/screen_level00.o: screens/screen_level00.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen LEVEL01
|
||||||
|
screens/screen_level01.o: screens/screen_level01.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen LEVEL02
|
||||||
|
screens/screen_level02.o: screens/screen_level02.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen LEVEL03
|
||||||
|
screens/screen_level03.o: screens/screen_level03.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen LEVEL04
|
||||||
|
screens/screen_level04.o: screens/screen_level04.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen LEVEL05
|
||||||
|
screens/screen_level05.o: screens/screen_level05.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen LEVEL06
|
||||||
|
screens/screen_level06.o: screens/screen_level06.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen LEVEL07
|
||||||
|
screens/screen_level07.o: screens/screen_level07.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen LEVEL08
|
||||||
|
screens/screen_level08.o: screens/screen_level08.c
|
||||||
|
$(CC) -c $< -o $@ $(CFLAGS) $(INCLUDES) -D$(PLATFORM)
|
||||||
|
|
||||||
|
# compile screen LEVEL09
|
||||||
|
screens/screen_level09.o: screens/screen_level09.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)
|
||||||
BIN
games/just_do_GGJ2015/src/resources/ambient.ogg
Normal file
BIN
games/just_do_GGJ2015/src/resources/ambient.ogg
Normal file
Binary file not shown.
BIN
games/just_do_GGJ2015/src/resources/win.wav
Normal file
BIN
games/just_do_GGJ2015/src/resources/win.wav
Normal file
Binary file not shown.
167
games/just_do_GGJ2015/src/screens/screen_level00.c
Normal file
167
games/just_do_GGJ2015/src/screens/screen_level00.c
Normal file
|
|
@ -0,0 +1,167 @@
|
||||||
|
/**********************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib - Standard Game template
|
||||||
|
*
|
||||||
|
* Level00 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)
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Level00 screen global variables
|
||||||
|
static int framesCounter;
|
||||||
|
static int finishScreen;
|
||||||
|
|
||||||
|
static Rectangle boundsU, boundsO;
|
||||||
|
|
||||||
|
static bool mouseOverU = false;
|
||||||
|
static bool mouseOverO = false;
|
||||||
|
static bool placedU = false;
|
||||||
|
static bool placedO = false;
|
||||||
|
|
||||||
|
static bool done = false;
|
||||||
|
static int levelTimeSec = 0;
|
||||||
|
static bool levelFinished = false;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Level00 Screen Functions Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Level00 Screen Initialization logic
|
||||||
|
void InitLevel00Screen(void)
|
||||||
|
{
|
||||||
|
// Initialize Level00 screen variables here!
|
||||||
|
framesCounter = 0;
|
||||||
|
finishScreen = 0;
|
||||||
|
|
||||||
|
boundsU = (Rectangle){GetScreenWidth()/2 - 265, -200, MeasureText("U", 160) + 40, 160 };
|
||||||
|
boundsO = (Rectangle){GetScreenWidth() - 370, -30, MeasureText("O", 160) + 40, 160 };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Level00 Screen Update logic
|
||||||
|
void UpdateLevel00Screen(void)
|
||||||
|
{
|
||||||
|
// Update Level00 screen variables here!
|
||||||
|
if (!done) framesCounter++;
|
||||||
|
|
||||||
|
if (!done)
|
||||||
|
{
|
||||||
|
if (!placedU) boundsU.y += 2;
|
||||||
|
|
||||||
|
if (boundsU.y >= GetScreenHeight()) boundsU.y = -boundsU.height;
|
||||||
|
|
||||||
|
Vector2 mousePos = GetMousePosition();
|
||||||
|
|
||||||
|
if (CheckCollisionPointRec(mousePos, boundsU))
|
||||||
|
{
|
||||||
|
mouseOverU = true;
|
||||||
|
|
||||||
|
if (!placedU && IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||||
|
{
|
||||||
|
if ((boundsU.y > GetScreenHeight()/2 - 110) && ((boundsU.y + boundsU.height) < (GetScreenHeight()/2 + 100)))
|
||||||
|
{
|
||||||
|
placedU = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else mouseOverU = false;
|
||||||
|
|
||||||
|
if (CheckCollisionPointRec(mousePos, boundsO))
|
||||||
|
{
|
||||||
|
mouseOverO = true;
|
||||||
|
|
||||||
|
if (!placedO && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) boundsO.y += 100;
|
||||||
|
|
||||||
|
if (boundsO.y >= (GetScreenHeight()/2 - 130)) placedO = true;
|
||||||
|
}
|
||||||
|
else mouseOverO = false;
|
||||||
|
|
||||||
|
if (placedO && placedU)
|
||||||
|
{
|
||||||
|
done = true;
|
||||||
|
PlaySound(levelWin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (done && !levelFinished)
|
||||||
|
{
|
||||||
|
levelTimeSec = framesCounter/60;
|
||||||
|
levelFinished = true;
|
||||||
|
framesCounter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (levelFinished)
|
||||||
|
{
|
||||||
|
framesCounter++;
|
||||||
|
|
||||||
|
if ((framesCounter > 30) && (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) finishScreen = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Level00 Screen Draw logic
|
||||||
|
void DrawLevel00Screen(void)
|
||||||
|
{
|
||||||
|
// Draw Level00 screen
|
||||||
|
DrawText("U", boundsU.x, boundsU.y + 10, 160, GRAY);
|
||||||
|
DrawText("J", GetScreenWidth()/2 - MeasureText("JUST DO", 160)/2, GetScreenHeight()/2 - 80, 160, GRAY);
|
||||||
|
DrawText("ST D", GetScreenWidth()/2 - MeasureText("JUST DO", 160)/2 + 210, GetScreenHeight()/2 - 80, 160, GRAY);
|
||||||
|
DrawText("O", boundsO.x, boundsO.y + 10, 160, GRAY);
|
||||||
|
|
||||||
|
DrawText("by RAMON SANTAMARIA (@raysan5)", 370, GetScreenHeight()/2 + 100, 30, Fade(LIGHTGRAY, 0.4f));
|
||||||
|
|
||||||
|
if (mouseOverU && !placedU) DrawRectangleLines(boundsU.x - 20, boundsU.y, boundsU.width, boundsU.height, Fade(LIGHTGRAY, 0.8f));
|
||||||
|
//DrawRectangleBordersRec(boundsU, -20, 0, 20, Fade(RED, 0.3f));
|
||||||
|
|
||||||
|
if (mouseOverO && !placedO) DrawRectangleLines(boundsO.x - 20, boundsO.y, boundsO.width, boundsO.height, Fade(LIGHTGRAY, 0.8f));
|
||||||
|
//DrawRectangleBordersRec(boundsO, -20, 0, 20, Fade(RED, 0.3f));
|
||||||
|
|
||||||
|
if (levelFinished)
|
||||||
|
{
|
||||||
|
DrawRectangleBordersRec((Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, 0, 0, 60, Fade(LIGHTGRAY, 0.6f));
|
||||||
|
DrawText("LEVEL 00", GetScreenWidth()/2 - MeasureText("LEVEL 00", 30)/2, 20, 30, GRAY);
|
||||||
|
DrawText(FormatText("DONE! (Seconds: %03i)", levelTimeSec), GetScreenWidth()/2 - MeasureText("DONE! (Seconds: 000)", 30)/2, GetScreenHeight() - 40, 30, GRAY);
|
||||||
|
}
|
||||||
|
else DrawText("LEVEL 00", GetScreenWidth()/2 - MeasureText("LEVEL 00", 30)/2, 20, 30, LIGHTGRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Level00 Screen Unload logic
|
||||||
|
void UnloadLevel00Screen(void)
|
||||||
|
{
|
||||||
|
// TODO: Unload Level00 screen variables here!
|
||||||
|
}
|
||||||
|
|
||||||
|
// Level00 Screen should finish?
|
||||||
|
int FinishLevel00Screen(void)
|
||||||
|
{
|
||||||
|
return finishScreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawRectangleBordersRec(Rectangle rec, int offsetX, int offsetY, int borderSize, Color col)
|
||||||
|
{
|
||||||
|
DrawRectangle(rec.x + offsetX, rec.y + offsetY, rec.width, borderSize, col);
|
||||||
|
DrawRectangle(rec.x + offsetX, rec.y + borderSize + offsetY, borderSize, rec.height - borderSize*2, col);
|
||||||
|
DrawRectangle(rec.x + rec.width - borderSize + offsetX, rec.y + borderSize + offsetY, borderSize, rec.height - borderSize*2, col);
|
||||||
|
DrawRectangle(rec.x + offsetX, rec.y + rec.height - borderSize + offsetY, rec.width, borderSize, col);
|
||||||
|
}
|
||||||
163
games/just_do_GGJ2015/src/screens/screen_level01.c
Normal file
163
games/just_do_GGJ2015/src/screens/screen_level01.c
Normal file
|
|
@ -0,0 +1,163 @@
|
||||||
|
/**********************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib - Standard Game template
|
||||||
|
*
|
||||||
|
* Level01 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)
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Level01 screen global variables
|
||||||
|
static int framesCounter;
|
||||||
|
static int finishScreen;
|
||||||
|
|
||||||
|
static Rectangle innerLeftRec, outerLeftRec;
|
||||||
|
static Rectangle innerRightRec, outerRightRec;
|
||||||
|
|
||||||
|
static bool done = false;
|
||||||
|
static int levelTimeSec = 0;
|
||||||
|
static bool levelFinished = false;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Level01 Screen Functions Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Level01 Screen Initialization logic
|
||||||
|
void InitLevel01Screen(void)
|
||||||
|
{
|
||||||
|
// Initialize Level01 screen variables here!
|
||||||
|
framesCounter = 0;
|
||||||
|
finishScreen = 0;
|
||||||
|
|
||||||
|
outerLeftRec = (Rectangle){ 0, 0, GetScreenWidth()/2, GetScreenHeight() };
|
||||||
|
outerRightRec = (Rectangle){ GetScreenWidth()/2, 0, GetScreenWidth()/2, GetScreenHeight() };
|
||||||
|
|
||||||
|
innerLeftRec = (Rectangle){ GetScreenWidth()/4 - 200, GetScreenHeight()/2 - 200, 400, 400};
|
||||||
|
innerRightRec = (Rectangle){ GetScreenWidth()/2 + GetScreenWidth()/4 - 200, GetScreenHeight()/2 - 200, 400, 400};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Level01 Screen Update logic
|
||||||
|
void UpdateLevel01Screen(void)
|
||||||
|
{
|
||||||
|
// Update Level01 screen
|
||||||
|
framesCounter++;
|
||||||
|
|
||||||
|
if (!done)
|
||||||
|
{
|
||||||
|
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||||
|
{
|
||||||
|
if (CheckCollisionPointRec(GetMousePosition(), innerLeftRec))
|
||||||
|
{
|
||||||
|
if (innerRightRec.width > 0)
|
||||||
|
{
|
||||||
|
innerRightRec.x += 20;
|
||||||
|
innerRightRec.y += 20;
|
||||||
|
innerRightRec.width -= 40;
|
||||||
|
innerRightRec.height -= 40;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (CheckCollisionPointRec(GetMousePosition(), innerRightRec))
|
||||||
|
{
|
||||||
|
if (innerLeftRec.width > 0)
|
||||||
|
{
|
||||||
|
innerLeftRec.x += 20;
|
||||||
|
innerLeftRec.y += 20;
|
||||||
|
innerLeftRec.width -= 40;
|
||||||
|
innerLeftRec.height -= 40;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (CheckCollisionPointRec(GetMousePosition(), outerLeftRec))
|
||||||
|
{
|
||||||
|
innerLeftRec.x -= 20;
|
||||||
|
innerLeftRec.y -= 20;
|
||||||
|
innerLeftRec.width += 40;
|
||||||
|
innerLeftRec.height += 40;
|
||||||
|
}
|
||||||
|
else if (CheckCollisionPointRec(GetMousePosition(), outerRightRec))
|
||||||
|
{
|
||||||
|
innerRightRec.x -= 20;
|
||||||
|
innerRightRec.y -= 20;
|
||||||
|
innerRightRec.width += 40;
|
||||||
|
innerRightRec.height += 40;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (((innerRightRec.width == 0) && (innerLeftRec.height >= GetScreenHeight())) ||
|
||||||
|
((innerLeftRec.width == 0) && (innerRightRec.height >= GetScreenHeight())))
|
||||||
|
{
|
||||||
|
done = true;
|
||||||
|
PlaySound(levelWin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (done && !levelFinished)
|
||||||
|
{
|
||||||
|
levelTimeSec = framesCounter/60;
|
||||||
|
levelFinished = true;
|
||||||
|
framesCounter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (levelFinished)
|
||||||
|
{
|
||||||
|
framesCounter++;
|
||||||
|
|
||||||
|
if ((framesCounter > 90) && (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) finishScreen = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Level01 Screen Draw logic
|
||||||
|
void DrawLevel01Screen(void)
|
||||||
|
{
|
||||||
|
// Draw Level01 screen
|
||||||
|
if (!levelFinished) DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), LIGHTGRAY);
|
||||||
|
else DrawRectangle(60, 60, GetScreenWidth() - 120, GetScreenHeight() - 120, LIGHTGRAY);
|
||||||
|
|
||||||
|
DrawRectangleRec(outerLeftRec, GRAY);
|
||||||
|
DrawRectangleRec(innerLeftRec, RAYWHITE);
|
||||||
|
DrawRectangleRec(outerRightRec, RAYWHITE);
|
||||||
|
DrawRectangleRec(innerRightRec, GRAY);
|
||||||
|
|
||||||
|
if (levelFinished)
|
||||||
|
{
|
||||||
|
DrawRectangleBordersRec((Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, 0, 0, 60, Fade(LIGHTGRAY, 0.6f));
|
||||||
|
DrawText("LEVEL 01", GetScreenWidth()/2 - MeasureText("LEVEL 01", 30)/2, 20, 30, GRAY);
|
||||||
|
DrawText(FormatText("DONE! (Seconds: %03i)", levelTimeSec), GetScreenWidth()/2 - MeasureText("DONE! (Seconds: 000)", 30)/2, GetScreenHeight() - 40, 30, GRAY);
|
||||||
|
}
|
||||||
|
else DrawText("LEVEL 01", GetScreenWidth()/2 - MeasureText("LEVEL 01", 30)/2, 20, 30, LIGHTGRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Level01 Screen Unload logic
|
||||||
|
void UnloadLevel01Screen(void)
|
||||||
|
{
|
||||||
|
// TODO: Unload Level01 screen variables here!
|
||||||
|
}
|
||||||
|
|
||||||
|
// Level01 Screen should finish?
|
||||||
|
int FinishLevel01Screen(void)
|
||||||
|
{
|
||||||
|
return finishScreen;
|
||||||
|
}
|
||||||
170
games/just_do_GGJ2015/src/screens/screen_level02.c
Normal file
170
games/just_do_GGJ2015/src/screens/screen_level02.c
Normal file
|
|
@ -0,0 +1,170 @@
|
||||||
|
/**********************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib - Standard Game template
|
||||||
|
*
|
||||||
|
* Level02 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 <math.h>
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Global Variables Definition (local to this module)
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Level02 screen global variables
|
||||||
|
static int framesCounter;
|
||||||
|
static int finishScreen;
|
||||||
|
|
||||||
|
static Vector2 bouncingBallPos;
|
||||||
|
static float bouncingBallRadius = 40;
|
||||||
|
static Vector2 bouncingBallSpeed;
|
||||||
|
|
||||||
|
static Vector2 holeCirclePos;
|
||||||
|
static float holeCircleRadius = 50;
|
||||||
|
|
||||||
|
static bool ballOnHole = false;
|
||||||
|
|
||||||
|
static int levelTimeSec = 0;
|
||||||
|
static bool levelFinished = false;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Level02 Screen Functions Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
float Vector2Distance(Vector2 v1, Vector2 v2);
|
||||||
|
|
||||||
|
// Level02 Screen Initialization logic
|
||||||
|
void InitLevel02Screen(void)
|
||||||
|
{
|
||||||
|
// TODO: Initialize Level02 screen variables here!
|
||||||
|
framesCounter = 0;
|
||||||
|
finishScreen = 0;
|
||||||
|
|
||||||
|
bouncingBallPos = (Vector2){ 120, 80 };
|
||||||
|
bouncingBallSpeed = (Vector2){ 6, 8 };
|
||||||
|
holeCirclePos = (Vector2){ GetScreenWidth()/2, GetScreenHeight()/2 };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Level02 Screen Update logic
|
||||||
|
void UpdateLevel02Screen(void)
|
||||||
|
{
|
||||||
|
// Update Level02 screen
|
||||||
|
framesCounter++;
|
||||||
|
|
||||||
|
if (!ballOnHole)
|
||||||
|
{
|
||||||
|
bouncingBallPos.x += bouncingBallSpeed.x;
|
||||||
|
bouncingBallPos.y += bouncingBallSpeed.y;
|
||||||
|
|
||||||
|
if (((bouncingBallPos.x - bouncingBallRadius) <= 0) || ((bouncingBallPos.x + bouncingBallRadius) >= GetScreenWidth())) bouncingBallSpeed.x *= -1;
|
||||||
|
if (((bouncingBallPos.y - bouncingBallRadius) <= 0) || ((bouncingBallPos.y + bouncingBallRadius) >= GetScreenHeight())) bouncingBallSpeed.y *= -1;
|
||||||
|
|
||||||
|
Vector2 mousePos = GetMousePosition();
|
||||||
|
|
||||||
|
if (CheckCollisionPointCircle(mousePos, bouncingBallPos, 120))
|
||||||
|
{
|
||||||
|
bouncingBallPos.x = GetRandomValue(80, 1200);
|
||||||
|
bouncingBallPos.y = GetRandomValue(80, 650);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CheckCollisionPointCircle(mousePos, holeCirclePos, 120))
|
||||||
|
{
|
||||||
|
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
|
||||||
|
{
|
||||||
|
holeCirclePos = mousePos;
|
||||||
|
|
||||||
|
if ((holeCirclePos.x - holeCircleRadius) <= 0) holeCirclePos.x = holeCircleRadius;
|
||||||
|
else if ((holeCirclePos.x + holeCircleRadius) >= GetScreenWidth()) holeCirclePos.x = GetScreenWidth() - holeCircleRadius;
|
||||||
|
|
||||||
|
if ((holeCirclePos.y - holeCircleRadius) <= 0) holeCirclePos.y = holeCircleRadius;
|
||||||
|
else if ((holeCirclePos.y + holeCircleRadius) >= GetScreenHeight()) holeCirclePos.y = GetScreenHeight() - holeCircleRadius;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Vector2Distance(bouncingBallPos, holeCirclePos) < 20)
|
||||||
|
{
|
||||||
|
ballOnHole = true;
|
||||||
|
PlaySound(levelWin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ballOnHole && !levelFinished)
|
||||||
|
{
|
||||||
|
levelTimeSec = framesCounter/60;
|
||||||
|
levelFinished = true;
|
||||||
|
framesCounter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (levelFinished)
|
||||||
|
{
|
||||||
|
framesCounter++;
|
||||||
|
|
||||||
|
if ((framesCounter > 90) && (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))) finishScreen = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Level02 Screen Draw logic
|
||||||
|
void DrawLevel02Screen(void)
|
||||||
|
{
|
||||||
|
// Draw Level02 screen
|
||||||
|
|
||||||
|
DrawCircleV(holeCirclePos, holeCircleRadius, LIGHTGRAY);
|
||||||
|
DrawCircleV(bouncingBallPos, bouncingBallRadius, DARKGRAY);
|
||||||
|
|
||||||
|
DrawCircleLines(bouncingBallPos.x, bouncingBallPos.y, 120, Fade(LIGHTGRAY, 0.8f));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (levelFinished)
|
||||||
|
{
|
||||||
|
DrawRectangleBordersRec((Rectangle){0, 0, GetScreenWidth(), GetScreenHeight()}, 0, 0, 60, Fade(LIGHTGRAY, 0.6f));
|
||||||
|
DrawText("LEVEL 02", GetScreenWidth()/2 - MeasureText("LEVEL 02", 30)/2, 20, 30, GRAY);
|
||||||
|
DrawText(FormatText("DONE! (Seconds: %03i)", levelTimeSec), GetScreenWidth()/2 - MeasureText("DONE! (Seconds: 000)", 30)/2, GetScreenHeight() - 40, 30, GRAY);
|
||||||
|
}
|
||||||
|
else DrawText("LEVEL 02", GetScreenWidth()/2 - MeasureText("LEVEL 02", 30)/2, 20, 30, LIGHTGRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Level02 Screen Unload logic
|
||||||
|
void UnloadLevel02Screen(void)
|
||||||
|
{
|
||||||
|
// TODO: Unload Level02 screen variables here!
|
||||||
|
}
|
||||||
|
|
||||||
|
// Level02 Screen should finish?
|
||||||
|
int FinishLevel02Screen(void)
|
||||||
|
{
|
||||||
|
return finishScreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate distance between two points
|
||||||
|
float Vector2Distance(Vector2 v1, Vector2 v2)
|
||||||
|
{
|
||||||
|
float result;
|
||||||
|
|
||||||
|
float dx = v2.x - v1.x;
|
||||||
|
float dy = v2.y - v1.y;
|
||||||
|
|
||||||
|
result = sqrt(dx*dx + dy*dy);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue