Merge remote-tracking branch 'refs/remotes/raysan5/develop' into develop
39
CHANGELOG
|
|
@ -1,11 +1,48 @@
|
||||||
changelog
|
changelog
|
||||||
---------
|
---------
|
||||||
|
|
||||||
Current Release: raylib 1.3.0 (03 September 2015)
|
Current Release: raylib 1.4.0 (22 February 2016)
|
||||||
|
|
||||||
NOTE: Only versions marked as 'Release' are available in installer, updates are only available as source.
|
NOTE: Only versions marked as 'Release' are available in installer, updates are only available as source.
|
||||||
NOTE: Current Release includes all previous updates.
|
NOTE: Current Release includes all previous updates.
|
||||||
|
|
||||||
|
-----------------------------------------------
|
||||||
|
Release: raylib 1.4.0 (22 February 2016)
|
||||||
|
-----------------------------------------------
|
||||||
|
NOTE:
|
||||||
|
This version supposed another big improvement for raylib, inlcuding new modules and new features.
|
||||||
|
More than 30 new functions have been added to previous raylib version.
|
||||||
|
Around 8 new examples and +10 new game samples have been added.
|
||||||
|
|
||||||
|
BIG changes:
|
||||||
|
[textures] IMAGE MANIPULATION: Functions to crop, resize, colorize, flip, dither and even draw image-to-image or text-to-image.
|
||||||
|
[text] SPRITEFONT SUPPORT: Added support for AngelCode fonts (.fnt) and TrueType fonts (.ttf).
|
||||||
|
[gestures] REDESIGN: Gestures system simplified and prepared to process generic touch events, including mouse events (multiplatform).
|
||||||
|
[physac] NEW MODULE: Basic 2D physics support, use colliders and rigidbodies; apply forces to physic objects.
|
||||||
|
|
||||||
|
other changes:
|
||||||
|
[rlgl] Removed GLEW library dependency, now using GLAD
|
||||||
|
[rlgl] Implemented alternative to glGetTexImage() on OpenGL ES
|
||||||
|
[rlgl] Using depth data on batch drawing
|
||||||
|
[rlgl] Reviewed glReadPixels() function
|
||||||
|
[core][rlgl] Reviewed raycast system, now 3D picking works
|
||||||
|
[core] Android: Reviewed Android App cycle, paused if inactive
|
||||||
|
[shaders] Implemented Blinn-Phong lighting shading model
|
||||||
|
[textures] Implemented Floyd-Steinberg dithering - ImageDither()
|
||||||
|
[text] Added line-break support to DrawText()
|
||||||
|
[text] Added TrueType Fonts support (using stb_truetype)
|
||||||
|
[models] Implement function: CalculateBoundingBox(Mesh mesh)
|
||||||
|
[models] Added functions to check Ray collisions
|
||||||
|
[models] Improve map resolution control on LoadHeightmap()
|
||||||
|
[camera] Corrected small-glitch on zoom-in with mouse-wheel
|
||||||
|
[gestures] Implemented SetGesturesEnabled() to enable only some gestures
|
||||||
|
[gestures] Implemented GetElapsedTime() on Windows system
|
||||||
|
[gestures] Support mouse gestures for desktop platforms
|
||||||
|
[raymath] Complete review of the module and converted to header-only
|
||||||
|
[easings] Added new module for easing animations
|
||||||
|
[stb] Updated to latest headers versions
|
||||||
|
[*] Lots of tweaks around
|
||||||
|
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
Release: raylib 1.3.0 (01 September 2015)
|
Release: raylib 1.3.0 (01 September 2015)
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ contact
|
||||||
* Webpage: [http://www.raylib.com](http://www.raylib.com)
|
* Webpage: [http://www.raylib.com](http://www.raylib.com)
|
||||||
* Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5)
|
* Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5)
|
||||||
* Facebook: [http://www.facebook.com/raylibgames](http://www.facebook.com/raylibgames)
|
* Facebook: [http://www.facebook.com/raylibgames](http://www.facebook.com/raylibgames)
|
||||||
|
* Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
||||||
|
* Twitch: [http://www.twitch.tv/raysan5](http://www.twitch.tv/raysan5)
|
||||||
|
* Patreon: [https://www.patreon.com/raysan5](https://www.patreon.com/raysan5)
|
||||||
|
|
||||||
|
[raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San"
|
||||||
[raysan5]: mailto:raysan@raysanweb.com "Ramon Santamaria - Ray San"
|
|
||||||
|
|
|
||||||
28
README.md
|
|
@ -6,7 +6,6 @@ about
|
||||||
raylib is a simple and easy-to-use library to learn videogames programming.
|
raylib is a simple and easy-to-use library to learn videogames programming.
|
||||||
|
|
||||||
raylib is highly inspired by Borland BGI graphics lib and by XNA framework.
|
raylib is highly inspired by Borland BGI graphics lib and by XNA framework.
|
||||||
Allegro and SDL have also been analyzed for reference.
|
|
||||||
|
|
||||||
NOTE for ADVENTURERS: raylib is a programming library to learn videogames programming;
|
NOTE for ADVENTURERS: raylib is a programming library to learn videogames programming;
|
||||||
no fancy interface, no visual helpers, no auto-debugging... just coding in the most
|
no fancy interface, no visual helpers, no auto-debugging... just coding in the most
|
||||||
|
|
@ -15,7 +14,7 @@ pure spartan-programmers way. Are you ready to learn? Jump to [code examples!](h
|
||||||
history
|
history
|
||||||
-------
|
-------
|
||||||
|
|
||||||
I've developed videogames for some years and last year I had to taught videogames development
|
I've developed videogames for some years and 4 years ago I started teaching videogames development
|
||||||
to young people with artistic profile, most of them had never written a single line of code.
|
to young people with artistic profile, most of them had never written a single line of code.
|
||||||
|
|
||||||
I started with C language basis and, after searching for the most simple and easy-to-use library to teach
|
I started with C language basis and, after searching for the most simple and easy-to-use library to teach
|
||||||
|
|
@ -102,25 +101,25 @@ Lots of code changes and lot of testing have concluded in this amazing new rayli
|
||||||
notes on raylib 1.4
|
notes on raylib 1.4
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
On February 2016, after 4 months of raylib 1.3 release, it comes raylib 1.4.
|
On February 2016, after 4 months of raylib 1.3 release, it comes raylib 1.4. For this new version, lots of parts of the library have been reviewed, lots of bugs have been solved and some interesting features have been added.
|
||||||
|
|
||||||
Lots of parts of the library have been reviewed to better accomodate to shaders systems and multiple new features have been added.
|
First big addition is a set of [Image manipulation functions](https://github.com/raysan5/raylib/blob/develop/src/raylib.h#L673) have been added to crop, resize, colorize, flip, dither and even draw image-to-image or text-to-image. Now a basic image processing can be done before converting the image to texture for usage.
|
||||||
|
|
||||||
SpriteFonts system has been improved, adding support for AngelCode fonts (.fnt) and TTF fonts (using stb_truetype).
|
SpriteFonts system has been improved, adding support for AngelCode fonts (.fnt) and TrueType Fonts (using [stb_truetype](https://github.com/nothings/stb/blob/master/stb_truetype.h) helper library). Now raylib can read standard .fnt font data and also generate at loading a SpriteFont from a TTF file.
|
||||||
|
|
||||||
Finally, raycast system for 3D picking is working, including some ray collision-detection functions.
|
New [physac](https://github.com/raysan5/raylib/blob/develop/src/physac.h) physics module for basic 2D physics support. Still in development but already functional. Module comes with some usage examples for basic jump and level interaction and also force-based physic movements.
|
||||||
|
|
||||||
A set of Image manipulation functions have been added to crop, resize, colorize, dither and even draw image-to-image or text-to-image.
|
[raymath](https://github.com/raysan5/raylib/blob/develop/src/raymath.h) module has been reviewed; some bugs have been solved and the module has been converted to a header-only file for easier portability, optionally, functions can also be used as inline.
|
||||||
|
|
||||||
Two new functions added for persistent data storage.
|
[gestures](https://github.com/raysan5/raylib/blob/develop/src/gestures.c) module has redesigned and simplified, now it can process touch events from any source, including mouse. This way, gestures system can be used on any platform providing an unified way to work with inputs and allowing the user to create multiplatform games with only one source code.
|
||||||
|
|
||||||
New [physac](https://github.com/raysan5/raylib/blob/develop/src/physac.h) physics module!
|
Raspberry Pi input system has been redesigned to better read raw inputs using generic Linux event handlers (keyboard:`stdin`, mouse:`/dev/input/mouse0`, gamepad:`/dev/input/js0`). Gamepad support has also been added (experimental).
|
||||||
|
|
||||||
Complete LUA scripting support to allow raylib usage from LUA and LUA scripts support within raylib.
|
Other important improvements are the functional raycast system for 3D picking, including some ray collision-detection functions, and the addition of two simple functions for persistent data storage. Now raylib user can save and load game data in a file (only some platforms supported). A simple [easings](https://github.com/raysan5/raylib/blob/develop/src/easings.h) module has also been added for values animation.
|
||||||
|
|
||||||
Up to 8 new examples have been added to show the new raylib features.
|
Up to 8 new code examples have been added to show the new raylib features and +10 complete game samples have been provided to learn how to create some classic games like Arkanoid, Asteroids, Missile Commander, Snake or Tetris.
|
||||||
|
|
||||||
Lots of code changes and lot of testing have concluded in this amazing new raylib 1.4.
|
Lots of code changes and lots of hours of hard work have concluded in this amazing new raylib 1.4.
|
||||||
|
|
||||||
features
|
features
|
||||||
--------
|
--------
|
||||||
|
|
@ -130,7 +129,7 @@ features
|
||||||
* Hardware accelerated with OpenGL (1.1, 3.3 or ES2)
|
* Hardware accelerated with OpenGL (1.1, 3.3 or ES2)
|
||||||
* Unique OpenGL abstraction layer (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c)
|
* Unique OpenGL abstraction layer (usable as standalone module): [rlgl](https://github.com/raysan5/raylib/blob/master/src/rlgl.c)
|
||||||
* Powerful fonts module with multiple SpriteFonts formats support (XNA bitmap fonts, AngelCode fonts, TTF)
|
* Powerful fonts module with multiple SpriteFonts formats support (XNA bitmap fonts, AngelCode fonts, TTF)
|
||||||
* Outstanding texture formats support, including compressed formats
|
* Outstanding texture formats support, including compressed formats (DXT, ETC, PVRT, ASTC)
|
||||||
* Basic 3d support for Shapes, Models, Billboards, Heightmaps and Cubicmaps
|
* Basic 3d support for Shapes, Models, Billboards, Heightmaps and Cubicmaps
|
||||||
* Powerful math module for Vector and Matrix operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.c)
|
* Powerful math module for Vector and Matrix operations: [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.c)
|
||||||
* Audio loading and playing with streaming support (WAV and OGG)
|
* Audio loading and playing with streaming support (WAV and OGG)
|
||||||
|
|
@ -181,6 +180,9 @@ contact
|
||||||
* Webpage: [http://www.raylib.com](http://www.raylib.com)
|
* Webpage: [http://www.raylib.com](http://www.raylib.com)
|
||||||
* Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5)
|
* Twitter: [http://www.twitter.com/raysan5](http://www.twitter.com/raysan5)
|
||||||
* Facebook: [http://www.facebook.com/raylibgames](http://www.facebook.com/raylibgames)
|
* Facebook: [http://www.facebook.com/raylibgames](http://www.facebook.com/raylibgames)
|
||||||
|
* Reddit: [https://www.reddit.com/r/raylib](https://www.reddit.com/r/raylib)
|
||||||
|
* Twitch: [http://www.twitch.tv/raysan5](http://www.twitch.tv/raysan5)
|
||||||
|
* Patreon: [https://www.patreon.com/raysan5](https://www.patreon.com/raysan5)
|
||||||
|
|
||||||
If you are using raylib and you enjoy it, please, [let me know][raysan5].
|
If you are using raylib and you enjoy it, please, [let me know][raysan5].
|
||||||
|
|
||||||
|
|
|
||||||
41
ROADMAP.md
|
|
@ -1,28 +1,37 @@
|
||||||
roadmap
|
roadmap
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Current version of raylib is quite complete and functional but there is still a lot of things I would like to improve.
|
Current version of raylib is quite complete and functional but there is still a lot of things to add and improve.
|
||||||
Here it is a list of features I would like to add and functions to improve.
|
Here it is a wish list of features I would like to add and functions to improve.
|
||||||
|
|
||||||
Around the source code there are multiple TODO points with pending revisions/bugs and here it is a list of desired features.
|
Note that around the raylib source code there are multiple TODO points with pending revisions/bugs. Check [GitHub Issues](https://github.com/raysan5/raylib/issues) for further details!
|
||||||
|
|
||||||
raylib v1.4
|
raylib 1.5
|
||||||
|
|
||||||
[DONE] TTF fonts support (using stb_truetype)
|
Redesign Shaders/Textures system, use Materials
|
||||||
[DONE] Raycast system for 3D picking (including collisions detection)
|
Redesign physics module (physac)
|
||||||
[DONE] Floyd-Steinberg dithering on 16bit image format conversion
|
Basic GPU stats sytem (memory, draws, time...)
|
||||||
[DONE] Basic image manipulation functions (crop, resize, draw...)
|
Procedural image generation functions (spot, gradient, noise...)
|
||||||
[DONE] Storage load/save data functionality
|
Procedural mesh generation functions (cube, cone, sphere...)
|
||||||
[DONE] Physics module
|
Touch-based camera controls for Android
|
||||||
[IN PROGRESS] LUA scripting support (wrapper to lua lib)
|
Skybox and Fog support
|
||||||
- Remove GLEW dependency (use another solution... glad?)
|
[IN PROGRESS] LUA scripting support (wrapper to lua lib)
|
||||||
- Basic image procedural generation (spot, gradient, noise...)
|
|
||||||
- Basic GPU stats sytem (memory, draws, time...)
|
|
||||||
|
|
||||||
|
raylib 1.4
|
||||||
|
|
||||||
Check [GITHUB ISSUES][issues] for further details on implementation status for this features!
|
[DONE] TTF fonts support (using stb_truetype)
|
||||||
|
[DONE] Raycast system for 3D picking (including collisions detection)
|
||||||
|
[DONE] Floyd-Steinberg dithering on 16bit image format conversion
|
||||||
|
[DONE] Basic image manipulation functions (crop, resize, draw...)
|
||||||
|
[DONE] Storage load/save data functionality
|
||||||
|
[DONE] Add Physics module (physac)
|
||||||
|
[DONE] Remove GLEW dependency -> Replaced by GLAD
|
||||||
|
[DONE] Redesign Raspberry PI inputs system
|
||||||
|
[DONE] Redesign gestures module to be multiplatform
|
||||||
|
[DONE] Module raymath as header-only and functions inline
|
||||||
|
[DONE] Add Easings module (easings.h)
|
||||||
|
|
||||||
Any feature missing? Do you have a request? [Let me know!][raysan5]
|
Any feature missing? Do you have a request? [Let me know!][raysan5]
|
||||||
|
|
||||||
[raysan5]: mailto:raysan@raysanweb.com "Ramon Santamaria - Ray San"
|
[raysan5]: mailto:raysan5@gmail.com "Ramon Santamaria - Ray San"
|
||||||
[isssues]: https://github.com/raysan5/raylib/issues
|
[isssues]: https://github.com/raysan5/raylib/issues
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ int main()
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world (position, target, up vector)
|
||||||
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }};
|
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }};
|
||||||
|
|
||||||
// Generates some random columns
|
// Generates some random columns
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,9 @@ int main()
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera;
|
Camera camera;
|
||||||
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f };
|
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position
|
||||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
|
|
||||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
|
@ -22,9 +22,9 @@ int main()
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera;
|
Camera camera;
|
||||||
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f };
|
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position
|
||||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
|
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
|
|
||||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,10 @@ int main()
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }};
|
Camera camera;
|
||||||
|
camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; // Camera position
|
||||||
|
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
||||||
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
|
|
||||||
Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
|
Vector3 cubePosition = { 0.0f, 1.0f, 0.0f };
|
||||||
Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
|
Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 24 KiB |
115
examples/core_gestures_detection.c
Normal file
|
|
@ -0,0 +1,115 @@
|
||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raylib [core] example - Gestures Detection
|
||||||
|
*
|
||||||
|
* This example has been created using raylib 1.4 (www.raylib.com)
|
||||||
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016 Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define MAX_GESTURE_STRINGS 20
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
int screenWidth = 800;
|
||||||
|
int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - gestures detection");
|
||||||
|
|
||||||
|
Vector2 touchPosition = { 0, 0 };
|
||||||
|
Rectangle touchArea = { 220, 10, screenWidth - 230, screenHeight - 20 };
|
||||||
|
|
||||||
|
int gesturesCount = 0;
|
||||||
|
char gestureStrings[MAX_GESTURE_STRINGS][32];
|
||||||
|
|
||||||
|
int currentGesture = GESTURE_NONE;
|
||||||
|
int lastGesture = GESTURE_NONE;
|
||||||
|
|
||||||
|
//SetGesturesEnabled(0b0000000000001001); // Enable only some gestures to be detected
|
||||||
|
|
||||||
|
SetTargetFPS(30);
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
lastGesture = currentGesture;
|
||||||
|
touchPosition = GetTouchPosition(0);
|
||||||
|
|
||||||
|
if (CheckCollisionPointRec(touchPosition, touchArea) && IsGestureDetected())
|
||||||
|
{
|
||||||
|
currentGesture = GetGestureType();
|
||||||
|
|
||||||
|
if (currentGesture != lastGesture)
|
||||||
|
{
|
||||||
|
// Store gesture string
|
||||||
|
switch (currentGesture)
|
||||||
|
{
|
||||||
|
case GESTURE_TAP: strcpy(gestureStrings[gesturesCount], "GESTURE TAP"); break;
|
||||||
|
case GESTURE_DOUBLETAP: strcpy(gestureStrings[gesturesCount], "GESTURE DOUBLETAP"); break;
|
||||||
|
case GESTURE_HOLD: strcpy(gestureStrings[gesturesCount], "GESTURE HOLD"); break;
|
||||||
|
case GESTURE_DRAG: strcpy(gestureStrings[gesturesCount], "GESTURE DRAG"); break;
|
||||||
|
case GESTURE_SWIPE_RIGHT: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE RIGHT"); break;
|
||||||
|
case GESTURE_SWIPE_LEFT: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE LEFT"); break;
|
||||||
|
case GESTURE_SWIPE_UP: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE UP"); break;
|
||||||
|
case GESTURE_SWIPE_DOWN: strcpy(gestureStrings[gesturesCount], "GESTURE SWIPE DOWN"); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
gesturesCount++;
|
||||||
|
|
||||||
|
// Reset gestures strings
|
||||||
|
if (gesturesCount >= MAX_GESTURE_STRINGS)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < MAX_GESTURE_STRINGS; i++) strcpy(gestureStrings[i], "\0");
|
||||||
|
|
||||||
|
gesturesCount = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else currentGesture = GESTURE_NONE;
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
DrawRectangleRec(touchArea, GRAY);
|
||||||
|
DrawRectangle(225, 15, screenWidth - 240, screenHeight - 30, RAYWHITE);
|
||||||
|
|
||||||
|
DrawText("GESTURES TEST AREA", screenWidth - 270, screenHeight - 40, 20, Fade(GRAY, 0.5f));
|
||||||
|
|
||||||
|
for (int i = 0; i < gesturesCount; i++)
|
||||||
|
{
|
||||||
|
if (i%2 == 0) DrawRectangle(10, 30 + 20*i, 200, 20, Fade(LIGHTGRAY, 0.5f));
|
||||||
|
else DrawRectangle(10, 30 + 20*i, 200, 20, Fade(LIGHTGRAY, 0.3f));
|
||||||
|
|
||||||
|
if (i < gesturesCount - 1) DrawText(gestureStrings[i], 35, 36 + 20*i, 10, DARKGRAY);
|
||||||
|
else DrawText(gestureStrings[i], 35, 36 + 20*i, 10, MAROON);
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawRectangleLines(10, 29, 200, screenHeight - 50, GRAY);
|
||||||
|
DrawText("DETECTED GESTURES", 50, 15, 10, GRAY);
|
||||||
|
|
||||||
|
if (currentGesture != GESTURE_NONE) DrawCircleV(touchPosition, 30, MAROON);
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
BIN
examples/core_gestures_detection.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
|
|
@ -21,6 +21,7 @@ int main()
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - mouse input");
|
||||||
|
|
||||||
Vector2 ballPosition = { -100.0f, -100.0f };
|
Vector2 ballPosition = { -100.0f, -100.0f };
|
||||||
|
Color ballColor = DARKBLUE;
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
|
|
@ -30,10 +31,11 @@ int main()
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
ballPosition = GetMousePosition();
|
||||||
{
|
|
||||||
ballPosition = GetMousePosition();
|
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ballColor = MAROON;
|
||||||
}
|
else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) ballColor = LIME;
|
||||||
|
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE;
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
@ -42,9 +44,9 @@ int main()
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
DrawCircleV(ballPosition, 40, GOLD);
|
DrawCircleV(ballPosition, 40, ballColor);
|
||||||
|
|
||||||
DrawText("mouse click to draw the ball", 10, 10, 20, DARKGRAY);
|
DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
* This example has been created using raylib 1.4 (www.raylib.com)
|
* This example has been created using raylib 1.4 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,8 @@ else
|
||||||
# external libraries headers
|
# external libraries headers
|
||||||
# GLFW3
|
# GLFW3
|
||||||
INCLUDES += -I../external/glfw3/include
|
INCLUDES += -I../external/glfw3/include
|
||||||
# GLEW
|
# GLEW - Not required any more, replaced by GLAD
|
||||||
INCLUDES += -I../external/glew/include
|
#INCLUDES += -I../external/glew/include
|
||||||
# OpenAL Soft
|
# OpenAL Soft
|
||||||
INCLUDES += -I../external/openal_soft/include
|
INCLUDES += -I../external/openal_soft/include
|
||||||
endif
|
endif
|
||||||
|
|
@ -102,8 +102,8 @@ else
|
||||||
ifneq ($(PLATFORM_OS),OSX)
|
ifneq ($(PLATFORM_OS),OSX)
|
||||||
# OpenAL Soft
|
# OpenAL Soft
|
||||||
LFLAGS += -L../external/openal_soft/lib/$(LIBPATH)
|
LFLAGS += -L../external/openal_soft/lib/$(LIBPATH)
|
||||||
# GLEW
|
# GLEW - Not required any more, replaced by GLAD
|
||||||
LFLAGS += -L../external/glew/lib/$(LIBPATH)
|
#LFLAGS += -L../external/glew/lib/$(LIBPATH)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
@ -126,7 +126,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
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 -lopengl32 -lopenal32 -lgdi32
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
@ -161,6 +161,8 @@ EXAMPLES = \
|
||||||
core_random_values \
|
core_random_values \
|
||||||
core_color_select \
|
core_color_select \
|
||||||
core_drop_files \
|
core_drop_files \
|
||||||
|
core_storage_values \
|
||||||
|
core_gestures_detection \
|
||||||
core_3d_mode \
|
core_3d_mode \
|
||||||
core_3d_picking \
|
core_3d_picking \
|
||||||
core_3d_camera_free \
|
core_3d_camera_free \
|
||||||
|
|
@ -177,10 +179,14 @@ EXAMPLES = \
|
||||||
textures_raw_data \
|
textures_raw_data \
|
||||||
textures_formats_loading \
|
textures_formats_loading \
|
||||||
textures_particles_trail_blending \
|
textures_particles_trail_blending \
|
||||||
|
textures_image_processing \
|
||||||
|
textures_image_drawing \
|
||||||
text_sprite_fonts \
|
text_sprite_fonts \
|
||||||
|
text_bmfont_ttf \
|
||||||
text_rbmf_fonts \
|
text_rbmf_fonts \
|
||||||
text_format_text \
|
text_format_text \
|
||||||
text_font_select \
|
text_font_select \
|
||||||
|
text_writing_anim \
|
||||||
models_geometric_shapes \
|
models_geometric_shapes \
|
||||||
models_box_collisions \
|
models_box_collisions \
|
||||||
models_billboard \
|
models_billboard \
|
||||||
|
|
@ -195,8 +201,6 @@ EXAMPLES = \
|
||||||
audio_music_stream \
|
audio_music_stream \
|
||||||
fix_dylib \
|
fix_dylib \
|
||||||
|
|
||||||
#core_input_gamepad \
|
|
||||||
|
|
||||||
|
|
||||||
# typing 'make' will invoke the first target entry in the file,
|
# typing 'make' will invoke the first target entry in the file,
|
||||||
# in this case, the 'default' target entry is raylib
|
# in this case, the 'default' target entry is raylib
|
||||||
|
|
@ -217,24 +221,16 @@ core_input_keys: core_input_keys.c
|
||||||
core_input_mouse: core_input_mouse.c
|
core_input_mouse: core_input_mouse.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
|
||||||
# compile [core] example - gamepad input
|
|
||||||
core_input_gamepad: core_input_gamepad.c
|
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
|
||||||
else
|
|
||||||
@echo core_input_gamepad: Only supported on desktop platform
|
|
||||||
endif
|
|
||||||
|
|
||||||
# compile [core] example - mouse wheel
|
# compile [core] example - mouse wheel
|
||||||
core_mouse_wheel: core_mouse_wheel.c
|
core_mouse_wheel: core_mouse_wheel.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
|
||||||
# compile [core] example - drop files
|
# compile [core] example - gamepad input
|
||||||
core_drop_files: core_drop_files.c
|
core_input_gamepad: core_input_gamepad.c
|
||||||
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
ifeq ($(PLATFORM), $(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_RPI))
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
else
|
else
|
||||||
@echo core_drop_files: Only supported on desktop platform
|
@echo core_input_gamepad: Example not supported on PLATFORM_ANDROID or PLATFORM_WEB
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# compile [core] example - generate random values
|
# compile [core] example - generate random values
|
||||||
|
|
@ -245,6 +241,26 @@ core_random_values: core_random_values.c
|
||||||
core_color_select: core_color_select.c
|
core_color_select: core_color_select.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
|
||||||
|
# compile [core] example - drop files
|
||||||
|
core_drop_files: core_drop_files.c
|
||||||
|
ifeq ($(PLATFORM),PLATFORM_DESKTOP)
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
else
|
||||||
|
@echo core_drop_files: Example not supported on PLATFORM_ANDROID or PLATFORM_WEB or PLATFORM_RPI
|
||||||
|
endif
|
||||||
|
|
||||||
|
# compile [core] example - storage values
|
||||||
|
core_storage_values: core_storage_values.c
|
||||||
|
ifeq ($(PLATFORM), $(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_RPI))
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
else
|
||||||
|
@echo core_storage_values: Example not supported on PLATFORM_ANDROID or PLATFORM_WEB
|
||||||
|
endif
|
||||||
|
|
||||||
|
# compile [core] example - gestures detection
|
||||||
|
core_gestures_detection: core_gestures_detection.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
|
||||||
# compile [core] example - 3d mode
|
# compile [core] example - 3d mode
|
||||||
core_3d_mode: core_3d_mode.c
|
core_3d_mode: core_3d_mode.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
|
@ -309,10 +325,22 @@ textures_formats_loading: textures_formats_loading.c
|
||||||
textures_particles_trail_blending: textures_particles_trail_blending.c
|
textures_particles_trail_blending: textures_particles_trail_blending.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
|
||||||
|
# compile [textures] example - texture image processing
|
||||||
|
textures_image_processing: textures_image_processing.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
|
||||||
|
# compile [textures] example - texture image drawing
|
||||||
|
textures_image_drawing: textures_image_drawing.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
|
||||||
# compile [text] example - sprite fonts loading
|
# compile [text] example - sprite fonts loading
|
||||||
text_sprite_fonts: text_sprite_fonts.c
|
text_sprite_fonts: text_sprite_fonts.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
|
||||||
|
# compile [text] example - bmfonts and ttf loading
|
||||||
|
text_bmfont_ttf: text_bmfont_ttf.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
|
||||||
# compile [text] example - raylib bitmap fonts (rBMF)
|
# compile [text] example - raylib bitmap fonts (rBMF)
|
||||||
text_rbmf_fonts: text_rbmf_fonts.c
|
text_rbmf_fonts: text_rbmf_fonts.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
|
@ -325,6 +353,10 @@ text_format_text: text_format_text.c
|
||||||
text_font_select: text_font_select.c
|
text_font_select: text_font_select.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
|
||||||
|
# compile [text] example - text writing animation
|
||||||
|
text_writing_anim: text_writing_anim.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
|
||||||
# compile [models] example - basic geometric 3d shapes
|
# compile [models] example - basic geometric 3d shapes
|
||||||
models_geometric_shapes: models_geometric_shapes.c
|
models_geometric_shapes: models_geometric_shapes.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDES) $(LFLAGS) $(LIBS) -D$(PLATFORM) $(WINFLAGS)
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 54 KiB |
|
|
@ -21,13 +21,13 @@ int main()
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
|
||||||
|
|
||||||
// Define our custom camera to look into our 3d world
|
// Define our custom camera to look into our 3d world
|
||||||
Camera camera = {{ 24.0f, 18.0f, 24.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }};
|
Camera camera = {{ 18.0f, 16.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }};
|
||||||
|
|
||||||
Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
|
Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
|
||||||
Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)
|
Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)
|
||||||
Model map = LoadHeightmap(image, 32); // Load heightmap model
|
Model map = LoadHeightmap(image, (Vector3){ 16, 8, 16 }); // Load heightmap model with defined size
|
||||||
SetModelTexture(&map, texture); // Bind texture to model
|
SetModelTexture(&map, texture); // Bind texture to model
|
||||||
Vector3 mapPosition = { -16.0f, 0.0f, -16.0f }; // Set model position (depends on model scaling!)
|
Vector3 mapPosition = { -8.0f, 0.0f, -8.0f }; // Set model position (depends on model scaling!)
|
||||||
|
|
||||||
UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
|
UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM
|
||||||
|
|
||||||
|
|
@ -54,7 +54,9 @@ int main()
|
||||||
Begin3dMode(camera);
|
Begin3dMode(camera);
|
||||||
|
|
||||||
// NOTE: Model is scaled to 1/4 of its original size (128x128 units)
|
// NOTE: Model is scaled to 1/4 of its original size (128x128 units)
|
||||||
DrawModel(map, mapPosition, 1/4.0f, RED);
|
DrawModel(map, mapPosition, 1.0f, RED);
|
||||||
|
|
||||||
|
DrawGrid(20, 1.0f);
|
||||||
|
|
||||||
End3dMode();
|
End3dMode();
|
||||||
|
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 95 KiB |
|
|
@ -2,20 +2,10 @@
|
||||||
*
|
*
|
||||||
* raylib [physac] physics example - Basic rigidbody
|
* raylib [physac] physics example - Basic rigidbody
|
||||||
*
|
*
|
||||||
* Welcome to raylib!
|
* This example has been created using raylib 1.4 (www.raylib.com)
|
||||||
*
|
|
||||||
* To test examples, just press F6 and execute raylib_compile_execute script
|
|
||||||
* Note that compiled executable is placed in the same folder as .c file
|
|
||||||
*
|
|
||||||
* You can find all basic examples on C:\raylib\raylib\examples folder or
|
|
||||||
* raylib official webpage: www.raylib.com
|
|
||||||
*
|
|
||||||
* Enjoy using raylib. :)
|
|
||||||
*
|
|
||||||
* This example has been created using raylib 1.3 (www.raylib.com)
|
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2015 Ramon Santamaria (@raysan5)
|
* Copyright (c) 2016 Victor Fisac and Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
|
@ -33,13 +23,7 @@ int main()
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [physics] example - basic rigidbody");
|
InitWindow(screenWidth, screenHeight, "raylib [physics] example - basic rigidbody");
|
||||||
|
|
||||||
InitPhysics(); // Initialize internal physics values (max rigidbodies/colliders available: 1024)
|
InitPhysics(3); // Initialize physics system with maximum physic objects
|
||||||
|
|
||||||
// Physics initialization
|
|
||||||
Physics worldPhysics = { true, false, (Vector2){ 0, -9.81f } };
|
|
||||||
|
|
||||||
// Set internal physics settings
|
|
||||||
SetPhysics(worldPhysics);
|
|
||||||
|
|
||||||
// Object initialization
|
// Object initialization
|
||||||
Transform player = (Transform){(Vector2){(screenWidth - OBJECT_SIZE) / 2, (screenHeight - OBJECT_SIZE) / 2}, 0.0f, (Vector2){OBJECT_SIZE, OBJECT_SIZE}};
|
Transform player = (Transform){(Vector2){(screenWidth - OBJECT_SIZE) / 2, (screenHeight - OBJECT_SIZE) / 2}, 0.0f, (Vector2){OBJECT_SIZE, OBJECT_SIZE}};
|
||||||
|
|
@ -55,6 +39,8 @@ int main()
|
||||||
float moveSpeed = 6.0f;
|
float moveSpeed = 6.0f;
|
||||||
float jumpForce = 5.0f;
|
float jumpForce = 5.0f;
|
||||||
|
|
||||||
|
bool physicsDebug = false;
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -91,14 +77,7 @@ int main()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check debug mode toggle button input
|
// Check debug mode toggle button input
|
||||||
if(IsKeyPressed(KEY_P))
|
if (IsKeyPressed(KEY_P)) physicsDebug = !physicsDebug;
|
||||||
{
|
|
||||||
// Update program physics value
|
|
||||||
worldPhysics.debug = !worldPhysics.debug;
|
|
||||||
|
|
||||||
// Update internal physics value
|
|
||||||
SetPhysics(worldPhysics);
|
|
||||||
}
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
@ -112,7 +91,7 @@ int main()
|
||||||
DrawText("Use P to switch DEBUG MODE", (screenWidth - MeasureText("Use P to switch DEBUG MODE", 20)) / 2, screenHeight * 0.3f, 20, LIGHTGRAY);
|
DrawText("Use P to switch DEBUG MODE", (screenWidth - MeasureText("Use P to switch DEBUG MODE", 20)) / 2, screenHeight * 0.3f, 20, LIGHTGRAY);
|
||||||
|
|
||||||
// Check if debug mode is enabled
|
// Check if debug mode is enabled
|
||||||
if (worldPhysics.debug)
|
if (physicsDebug)
|
||||||
{
|
{
|
||||||
// Draw every internal physics stored collider if it is active
|
// Draw every internal physics stored collider if it is active
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
|
|
@ -122,14 +101,11 @@ int main()
|
||||||
DrawRectangleLines(GetCollider(i).bounds.x, GetCollider(i).bounds.y, GetCollider(i).bounds.width, GetCollider(i).bounds.height, GREEN);
|
DrawRectangleLines(GetCollider(i).bounds.x, GetCollider(i).bounds.y, GetCollider(i).bounds.width, GetCollider(i).bounds.height, GREEN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Draw player
|
// Draw player and floor
|
||||||
DrawRectangleRec((Rectangle){player.position.x, player.position.y, player.scale.x, player.scale.y}, GRAY);
|
DrawRectangleRec((Rectangle){player.position.x, player.position.y, player.scale.x, player.scale.y}, GRAY);
|
||||||
|
|
||||||
// Draw floor
|
|
||||||
DrawRectangleRec((Rectangle){floor.position.x, floor.position.y, floor.scale.x, floor.scale.y}, BLACK);
|
DrawRectangleRec((Rectangle){floor.position.x, floor.position.y, floor.scale.x, floor.scale.y}, BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,6 +115,8 @@ int main()
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
UnloadPhysics(); // Unload physic objects
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
*
|
*
|
||||||
* raylib [physac] physics example - Rigidbody forces
|
* raylib [physac] physics example - Rigidbody forces
|
||||||
*
|
*
|
||||||
* This example has been created using raylib 1.3 (www.raylib.com)
|
* This example has been created using raylib 1.4 (www.raylib.com)
|
||||||
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
|
||||||
*
|
*
|
||||||
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
* Copyright (c) 2016 Victor Fisac and Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
|
|
@ -26,15 +26,9 @@ int main()
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [physics] example - rigidbodies forces");
|
InitWindow(screenWidth, screenHeight, "raylib [physics] example - rigidbodies forces");
|
||||||
|
|
||||||
InitPhysics(); // Initialize internal physics values (max rigidbodies/colliders available: 1024)
|
InitPhysics(MAX_OBJECTS + 1); // Initialize physics system with maximum physic objects
|
||||||
|
|
||||||
// Physics initialization
|
// Physic Objects initialization
|
||||||
Physics worldPhysics = {true, false, (Vector2){0, -9.81f}};
|
|
||||||
|
|
||||||
// Set internal physics settings
|
|
||||||
SetPhysics(worldPhysics);
|
|
||||||
|
|
||||||
// Objects initialization
|
|
||||||
Transform objects[MAX_OBJECTS];
|
Transform objects[MAX_OBJECTS];
|
||||||
|
|
||||||
for (int i = 0; i < MAX_OBJECTS; i++)
|
for (int i = 0; i < MAX_OBJECTS; i++)
|
||||||
|
|
@ -49,6 +43,8 @@ int main()
|
||||||
Transform floor = (Transform){(Vector2){0, screenHeight * 0.8f}, 0.0f, (Vector2){screenWidth, screenHeight * 0.2f}};
|
Transform floor = (Transform){(Vector2){0, screenHeight * 0.8f}, 0.0f, (Vector2){screenWidth, screenHeight * 0.2f}};
|
||||||
AddCollider(MAX_OBJECTS, (Collider){true, COLLIDER_RECTANGLE, (Rectangle){floor.position.x, floor.position.y, floor.scale.x, floor.scale.y}, 0});
|
AddCollider(MAX_OBJECTS, (Collider){true, COLLIDER_RECTANGLE, (Rectangle){floor.position.x, floor.position.y, floor.scale.x, floor.scale.y}, 0});
|
||||||
|
|
||||||
|
bool physicsDebug = false;
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -72,14 +68,7 @@ int main()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check debug mode toggle button input
|
// Check debug mode toggle button input
|
||||||
if (IsKeyPressed(KEY_P))
|
if (IsKeyPressed(KEY_P)) physicsDebug = !physicsDebug;
|
||||||
{
|
|
||||||
// Update program physics value
|
|
||||||
worldPhysics.debug = !worldPhysics.debug;
|
|
||||||
|
|
||||||
// Update internal physics value
|
|
||||||
SetPhysics(worldPhysics);
|
|
||||||
}
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
@ -89,10 +78,10 @@ int main()
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
// Check if debug mode is enabled
|
// Check if debug mode is enabled
|
||||||
if (worldPhysics.debug)
|
if (physicsDebug)
|
||||||
{
|
{
|
||||||
// Draw every internal physics stored collider if it is active (floor included)
|
// Draw every internal physics stored collider if it is active (floor included)
|
||||||
for (int i = 0; i < MAX_OBJECTS + 1; i++)
|
for (int i = 0; i < MAX_OBJECTS; i++)
|
||||||
{
|
{
|
||||||
if (GetCollider(i).enabled)
|
if (GetCollider(i).enabled)
|
||||||
{
|
{
|
||||||
|
|
@ -137,6 +126,8 @@ int main()
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
UnloadPhysics(); // Unload physic objects
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||