Review ALL examples

This commit is contained in:
Ray 2019-05-20 16:36:42 +02:00
parent a43a7980a3
commit b525039e0a
96 changed files with 1301 additions and 1317 deletions

View file

@ -23,12 +23,12 @@ typedef struct {
Color color; Color color;
} CircleWave; } CircleWave;
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X SetConfigFlags(FLAG_MSAA_4X_HINT); // NOTE: Try to enable MSAA 4X

View file

@ -4,7 +4,7 @@
* *
* NOTE: This example requires OpenAL Soft library installed * NOTE: This example requires OpenAL Soft library installed
* *
* This example has been created using raylib 1.7 (www.raylib.com) * 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) 2015 Ramon Santamaria (@raysan5)
@ -13,12 +13,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)"); InitWindow(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)");
@ -39,7 +39,7 @@ int main()
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
UpdateMusicStream(music); // Update music buffer with new stream data UpdateMusicStream(music); // Update music buffer with new stream data
// Restart music playing (stop and play) // Restart music playing (stop and play)
if (IsKeyPressed(KEY_SPACE)) if (IsKeyPressed(KEY_SPACE))

View file

@ -20,12 +20,12 @@
#define MAX_SAMPLES 512 #define MAX_SAMPLES 512
#define MAX_SAMPLES_PER_UPDATE 4096 #define MAX_SAMPLES_PER_UPDATE 4096
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - raw audio streaming"); InitWindow(screenWidth, screenHeight, "raylib [audio] example - raw audio streaming");

View file

@ -4,21 +4,21 @@
* *
* NOTE: This example requires OpenAL Soft library installed * NOTE: This example requires OpenAL Soft library installed
* *
* This example has been created using raylib 1.3 (www.raylib.com) * 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) * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* *
* Copyright (c) 2015 Ramon Santamaria (@raysan5) * Copyright (c) 2014 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing"); InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing");
@ -27,7 +27,7 @@ int main()
Sound fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file Sound fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file
Sound fxOgg = LoadSound("resources/tanatana.ogg"); // Load OGG audio file Sound fxOgg = LoadSound("resources/tanatana.ogg"); // Load OGG audio file
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -13,12 +13,12 @@
#define MAX_BUILDINGS 100 #define MAX_BUILDINGS 100
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera"); InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera");
@ -40,18 +40,18 @@ int main()
buildColors[i] = (Color){ GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255 }; buildColors[i] = (Color){ GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255 };
} }
Camera2D camera; Camera2D camera = { 0 };
camera.target = (Vector2){ player.x + 20, player.y + 20 }; camera.target = (Vector2){ player.x + 20, player.y + 20 };
camera.offset = (Vector2){ 0, 0 }; camera.offset = (Vector2){ 0, 0 };
camera.rotation = 0.0f; camera.rotation = 0.0f;
camera.zoom = 1.0f; camera.zoom = 1.0f;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View file

@ -13,12 +13,12 @@
#define MAX_COLUMNS 20 #define MAX_COLUMNS 20
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person"); InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera first person");

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");

View file

@ -11,7 +11,7 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -30,7 +30,7 @@ int main()
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f }; Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking"); InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d picking");

View file

@ -21,16 +21,16 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window"); InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -19,66 +19,66 @@
// Custom logging funtion // Custom logging funtion
void LogCustom(int msgType, const char *text, va_list args) void LogCustom(int msgType, const char *text, va_list args)
{ {
char timeStr[64]; char timeStr[64];
time_t now = time(NULL); time_t now = time(NULL);
struct tm *tm_info = localtime(&now); struct tm *tm_info = localtime(&now);
strftime(timeStr, sizeof(timeStr), "%Y-%m-%d %H:%M:%S", tm_info); strftime(timeStr, sizeof(timeStr), "%Y-%m-%d %H:%M:%S", tm_info);
printf("[%s] ", timeStr); printf("[%s] ", timeStr);
switch (msgType) switch (msgType)
{ {
case LOG_INFO: printf("[INFO] : "); break; case LOG_INFO: printf("[INFO] : "); break;
case LOG_ERROR: printf("[ERROR]: "); break; case LOG_ERROR: printf("[ERROR]: "); break;
case LOG_WARNING: printf("[WARN] : "); break; case LOG_WARNING: printf("[WARN] : "); break;
case LOG_DEBUG: printf("[DEBUG]: "); break; case LOG_DEBUG: printf("[DEBUG]: "); break;
default: break; default: break;
} }
vprintf(text, args); vprintf(text, args);
printf("\n"); printf("\n");
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
// First thing we do is setting our custom logger to ensure everything raylib logs // First thing we do is setting our custom logger to ensure everything raylib logs
// will use our own logger instead of its internal one // will use our own logger instead of its internal one
SetTraceLogCallback(LogCustom); SetTraceLogCallback(LogCustom);
InitWindow(screenWidth, screenHeight, "raylib [core] example - custom logging"); InitWindow(screenWidth, screenHeight, "raylib [core] example - custom logging");
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// TODO: Update your variables here // TODO: Update your variables here
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
DrawText("Check out the console output to see the custom logger in action!", 60, 200, 20, LIGHTGRAY); DrawText("Check out the console output to see the custom logger in action!", 60, 200, 20, LIGHTGRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View file

@ -13,19 +13,19 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files"); InitWindow(screenWidth, screenHeight, "raylib [core] example - drop files");
int count = 0; int count = 0;
char **droppedFiles = { 0 }; char **droppedFiles = { 0 };
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -8,10 +8,10 @@
* - PLAYSTATION(R)3 Controller * - PLAYSTATION(R)3 Controller
* Check raylib.h for buttons configuration * Check raylib.h for buttons configuration
* *
* This example has been created using raylib 1.6 (www.raylib.com) * This example has been created using raylib 2.5 (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) 2013-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2013-2019 Ramon Santamaria (@raysan5)
* *
********************************************************************************************/ ********************************************************************************************/
@ -26,12 +26,12 @@
#define PS3_NAME_ID "PLAYSTATION(R)3 Controller" #define PS3_NAME_ID "PLAYSTATION(R)3 Controller"
#endif #endif
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation SetConfigFlags(FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation
@ -40,7 +40,7 @@ int main()
Texture2D texPs3Pad = LoadTexture("resources/ps3.png"); Texture2D texPs3Pad = LoadTexture("resources/ps3.png");
Texture2D texXboxPad = LoadTexture("resources/xbox.png"); Texture2D texXboxPad = LoadTexture("resources/xbox.png");
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -14,12 +14,12 @@
#define MAX_GESTURE_STRINGS 20 #define MAX_GESTURE_STRINGS 20
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures"); InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures");
@ -34,7 +34,7 @@ int main()
//SetGesturesEnabled(0b0000000000001001); // Enable only some gestures to be detected //SetGesturesEnabled(0b0000000000001001); // Enable only some gestures to be detected
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,18 +11,18 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input"); InitWindow(screenWidth, screenHeight, "raylib [core] example - keyboard input");
Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 }; Vector2 ballPosition = { (float)screenWidth/2, (float)screenHeight/2 };
SetTargetFPS(60); // Set target frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,19 +11,19 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
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; Color ballColor = DARKBLUE;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,19 +11,19 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - input mouse wheel"); InitWindow(screenWidth, screenHeight, "raylib [core] example - input mouse wheel");
int boxPositionY = screenHeight/2 - 40; int boxPositionY = screenHeight/2 - 40;
int scrollSpeed = 4; // Scrolling speed in pixels int scrollSpeed = 4; // Scrolling speed in pixels
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -13,12 +13,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - input multitouch"); InitWindow(screenWidth, screenHeight, "raylib [core] example - input multitouch");
@ -26,9 +26,9 @@ int main()
Color ballColor = BEIGE; Color ballColor = BEIGE;
int touchCounter = 0; int touchCounter = 0;
Vector2 touchPosition; Vector2 touchPosition = { 0.0f };
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -27,12 +27,12 @@ static void *LoadDataThread(void *arg); // Loading data thread function decl
static int dataProgress = 0; // Data progress accumulator static int dataProgress = 0; // Data progress accumulator
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - loading thread"); InitWindow(screenWidth, screenHeight, "raylib [core] example - loading thread");
@ -41,7 +41,7 @@ int main()
enum { STATE_WAITING, STATE_LOADING, STATE_FINISHED } state = STATE_WAITING; enum { STATE_WAITING, STATE_LOADING, STATE_FINISHED } state = STATE_WAITING;
int framesCounter = 0; int framesCounter = 0;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,20 +11,20 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - generate random values"); InitWindow(screenWidth, screenHeight, "raylib [core] example - generate random values");
int framesCounter = 0; // Variable used to count frames int framesCounter = 0; // Variable used to count frames
int randValue = GetRandomValue(-8, 5); // Get a random integer number between -8 and 5 (both included) int randValue = GetRandomValue(-8, 5); // Get a random integer number between -8 and 5 (both included)
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -14,21 +14,20 @@
// NOTE: Storage positions must start with 0, directly related to file memory layout // NOTE: Storage positions must start with 0, directly related to file memory layout
typedef enum { STORAGE_SCORE = 0, STORAGE_HISCORE } StorageData; typedef enum { STORAGE_SCORE = 0, STORAGE_HISCORE } StorageData;
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - storage save/load values"); InitWindow(screenWidth, screenHeight, "raylib [core] example - storage save/load values");
int score = 0; int score = 0;
int hiscore = 0; int hiscore = 0;
int framesCounter = 0; int framesCounter = 0;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -17,12 +17,12 @@
#define GLSL_VERSION 100 #define GLSL_VERSION 100
#endif #endif
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 1080; const int screenWidth = 1080;
int screenHeight = 600; const int screenHeight = 600;
// NOTE: screenWidth/screenHeight should match VR device aspect ratio // NOTE: screenWidth/screenHeight should match VR device aspect ratio

View file

@ -16,7 +16,7 @@
#define max(a, b) ((a)>(b)? (a) : (b)) #define max(a, b) ((a)>(b)? (a) : (b))
#define min(a, b) ((a)<(b)? (a) : (b)) #define min(a, b) ((a)<(b)? (a) : (b))
int main() int main(void)
{ {
const int windowWidth = 800; const int windowWidth = 800;
const int windowHeight = 450; const int windowHeight = 450;
@ -36,11 +36,11 @@ int main()
Color colors[10] = { 0 }; Color colors[10] = { 0 };
for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 }; for (int i = 0; i < 10; i++) colors[i] = (Color){ GetRandomValue(100, 250), GetRandomValue(50, 150), GetRandomValue(10, 100), 255 };
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while( !WindowShouldClose() ) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free"); InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - model animation"); InitWindow(screenWidth, screenHeight, "raylib [models] example - model animation");

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards"); InitWindow(screenWidth, screenHeight, "raylib [models] example - drawing billboards");

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions"); InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions");
@ -35,7 +35,7 @@ int main()
bool collision = false; bool collision = false;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing"); InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing");

View file

@ -13,12 +13,12 @@
#include <stdlib.h> // Required for: free() #include <stdlib.h> // Required for: free()
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - first person maze"); InitWindow(screenWidth, screenHeight, "raylib [models] example - first person maze");

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes"); InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
@ -28,7 +28,7 @@ int main()
camera.fovy = 45.0f; camera.fovy = 45.0f;
camera.type = CAMERA_PERSPECTIVE; camera.type = CAMERA_PERSPECTIVE;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing"); InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");

View file

@ -25,12 +25,12 @@
// PBR material loading // PBR material loading
static Material LoadMaterialPBR(Color albedo, float metalness, float roughness); static Material LoadMaterialPBR(Color albedo, float metalness, float roughness);
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available) SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
InitWindow(screenWidth, screenHeight, "raylib [models] example - pbr material"); InitWindow(screenWidth, screenHeight, "raylib [models] example - pbr material");

View file

@ -11,14 +11,14 @@
#include "raylib.h" #include "raylib.h"
#define NUM_MODELS 8 // We generate 8 parametric 3d shapes #define NUM_MODELS 8 // Parametric 3d shapes to generate
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh generation"); InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh generation");
@ -51,7 +51,7 @@ int main()
SetCameraMode(camera, CAMERA_ORBITAL); // Set a orbital camera mode SetCameraMode(camera, CAMERA_ORBITAL); // Set a orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -15,12 +15,12 @@
#define FLT_MAX 340282346638528859811704183484516925440.0f // Maximum value of a float, from bit pattern 01111111011111111111111111111111 #define FLT_MAX 340282346638528859811704183484516925440.0f // Maximum value of a float, from bit pattern 01111111011111111111111111111111
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh picking"); InitWindow(screenWidth, screenHeight, "raylib [models] example - mesh picking");
@ -112,7 +112,6 @@ int main()
cursorColor = ORANGE; cursorColor = ORANGE;
hitObjectName = "Mesh"; hitObjectName = "Mesh";
} }
} }
hitMeshBBox = false; hitMeshBBox = false;

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading"); InitWindow(screenWidth, screenHeight, "raylib [models] example - obj model loading");
@ -33,7 +33,7 @@ int main()
model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture model.materials[0].maps[MAP_DIFFUSE].texture = texture; // Set map diffuse texture
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -13,12 +13,12 @@
#include <string.h> // Required for: strcpy() #include <string.h> // Required for: strcpy()
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib example - obj viewer"); InitWindow(screenWidth, screenHeight, "raylib example - obj viewer");
@ -37,7 +37,7 @@ int main()
char objFilename[64] = "turret.obj"; char objFilename[64] = "turret.obj";
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -18,19 +18,19 @@
#define FOVY_PERSPECTIVE 45.0f #define FOVY_PERSPECTIVE 45.0f
#define WIDTH_ORTHOGRAPHIC 10.0f #define WIDTH_ORTHOGRAPHIC 10.0f
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes"); InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
// 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 }, FOVY_PERSPECTIVE, CAMERA_PERSPECTIVE }; Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, FOVY_PERSPECTIVE, CAMERA_PERSPECTIVE };
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -22,7 +22,7 @@ void DrawSphereBasic(Color color); // Draw sphere without any matrix transf
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -54,11 +54,11 @@ int main()
float moonRotation = 0.0f; // Rotation of moon around itself float moonRotation = 0.0f; // Rotation of moon around itself
float moonOrbitRotation = 0.0f; // Rotation of moon around earth in degrees float moonOrbitRotation = 0.0f; // Rotation of moon around earth in degrees
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - skybox loading and drawing"); InitWindow(screenWidth, screenHeight, "raylib [models] example - skybox loading and drawing");

View file

@ -17,10 +17,7 @@
// Draw angle gauge controls // Draw angle gauge controls
void DrawAngleGauge(Texture2D angleGauge, int x, int y, float angle, char title[], Color color); void DrawAngleGauge(Texture2D angleGauge, int x, int y, float angle, char title[], Color color);
//---------------------------------------------------------------------------------- int main(void)
// Main entry point
//----------------------------------------------------------------------------------
int main()
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -53,10 +50,10 @@ int main()
float roll = 0.0f; float roll = 0.0f;
float yaw = 0.0f; float yaw = 0.0f;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update

View file

@ -21,12 +21,12 @@
#define PHYSAC_NO_THREADS #define PHYSAC_NO_THREADS
#include "physac.h" #include "physac.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics demo"); InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics demo");
@ -41,13 +41,13 @@ int main()
// Create floor rectangle physics body // Create floor rectangle physics body
PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10); PhysicsBody floor = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight }, 500, 100, 10);
floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) floor->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
// Create obstacle circle physics body // Create obstacle circle physics body
PhysicsBody circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2, screenHeight/2 }, 45, 10); PhysicsBody circle = CreatePhysicsBodyCircle((Vector2){ screenWidth/2, screenHeight/2 }, 45, 10);
circle->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions) circle->enabled = false; // Disable body state to convert it to static (no dynamics, but collisions)
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -21,12 +21,12 @@
#define PHYSAC_NO_THREADS #define PHYSAC_NO_THREADS
#include "physac.h" #include "physac.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics friction"); InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics friction");
@ -65,7 +65,7 @@ int main()
bodyB->dynamicFriction = 1; bodyB->dynamicFriction = 1;
SetPhysicsBodyRotation(bodyB, 330*DEG2RAD); SetPhysicsBodyRotation(bodyB, 330*DEG2RAD);
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -23,12 +23,12 @@
#define VELOCITY 0.5f #define VELOCITY 0.5f
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics movement"); InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics movement");
@ -56,9 +56,9 @@ int main()
// Create movement physics body // Create movement physics body
PhysicsBody body = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight/2 }, 50, 50, 1); PhysicsBody body = CreatePhysicsBodyRectangle((Vector2){ screenWidth/2, screenHeight/2 }, 50, 50, 1);
body->freezeOrient = true; // Constrain body rotation to avoid little collision torque amounts body->freezeOrient = true; // Constrain body rotation to avoid little collision torque amounts
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -21,12 +21,12 @@
#define PHYSAC_NO_THREADS #define PHYSAC_NO_THREADS
#include "physac.h" #include "physac.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics restitution"); InitWindow(screenWidth, screenHeight, "Physac [raylib] - Physics restitution");
@ -51,10 +51,10 @@ int main()
PhysicsBody circleC = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.75f, screenHeight/2 }, 30, 10); PhysicsBody circleC = CreatePhysicsBodyCircle((Vector2){ screenWidth*0.75f, screenHeight/2 }, 30, 10);
circleC->restitution = 1; circleC->restitution = 1;
SetTargetFPS(60);
// Restitution demo needs a very tiny physics time step for a proper simulation // Restitution demo needs a very tiny physics time step for a proper simulation
SetPhysicsTimeStep(1.0/60.0/100 * 1000); SetPhysicsTimeStep(1.0/60.0/100*1000);
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -21,12 +21,12 @@
#define PHYSAC_NO_THREADS #define PHYSAC_NO_THREADS
#include "physac.h" #include "physac.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "Physac [raylib] - Body shatter"); InitWindow(screenWidth, screenHeight, "Physac [raylib] - Body shatter");
@ -43,7 +43,7 @@ int main()
// Create random polygon physics body to shatter // Create random polygon physics body to shatter
CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10); CreatePhysicsBodyPolygon((Vector2){ screenWidth/2, screenHeight/2 }, GetRandomValue(80, 200), GetRandomValue(3, 8), 10);
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -24,12 +24,12 @@
#define GLSL_VERSION 100 #define GLSL_VERSION 100
#endif #endif
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available) SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)

View file

@ -31,7 +31,7 @@
#define GLSL_VERSION 100 #define GLSL_VERSION 100
#endif #endif
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -46,11 +46,11 @@ int main()
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader // NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/eratosthenes.fs", GLSL_VERSION)); Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/eratosthenes.fs", GLSL_VERSION));
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -64,7 +64,7 @@ int main()
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
BeginTextureMode(target); // Enable drawing to texture BeginTextureMode(target); // Enable drawing to texture
ClearBackground(BLACK); // Clear the render texture ClearBackground(BLACK); // Clear the render texture
// Draw a rectangle in shader mode to be used as shader canvas // Draw a rectangle in shader mode to be used as shader canvas
// NOTE: Rectangle uses font white character texture coordinates, // NOTE: Rectangle uses font white character texture coordinates,

View file

@ -35,7 +35,7 @@ const float POINTS_OF_INTEREST[6][2] =
{ -0.70176, -0.3842 }, { -0.70176, -0.3842 },
}; };
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -64,7 +64,7 @@ int main()
int offsetLoc = GetShaderLocation(shader, "offset"); int offsetLoc = GetShaderLocation(shader, "offset");
// Tell the shader what the screen dimensions, zoom, offset and c are // Tell the shader what the screen dimensions, zoom, offset and c are
float screenDims[2] = { (float)GetScreenWidth(), (float)GetScreenHeight() }; float screenDims[2] = { (float)screenWidth, (float)screenHeight };
SetShaderValue(shader, GetShaderLocation(shader, "screenDims"), screenDims, UNIFORM_VEC2); SetShaderValue(shader, GetShaderLocation(shader, "screenDims"), screenDims, UNIFORM_VEC2);
SetShaderValue(shader, cLoc, c, UNIFORM_VEC2); SetShaderValue(shader, cLoc, c, UNIFORM_VEC2);
@ -74,19 +74,18 @@ int main()
// Create a RenderTexture2D to be used for render to texture // Create a RenderTexture2D to be used for render to texture
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight); RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
int incrementSpeed = 0; // Multiplier of speed to change c value int incrementSpeed = 0; // Multiplier of speed to change c value
bool showControls = true; // Show controls bool showControls = true; // Show controls
bool pause = false; // Pause animation bool pause = false; // Pause animation
SetTargetFPS(60); // Set the window to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Press [1 - 6] to reset c to a point of interest // Press [1 - 6] to reset c to a point of interest
if (IsKeyPressed(KEY_ONE) || if (IsKeyPressed(KEY_ONE) ||
IsKeyPressed(KEY_TWO) || IsKeyPressed(KEY_TWO) ||

View file

@ -24,12 +24,12 @@
#define GLSL_VERSION 100 #define GLSL_VERSION 100
#endif #endif
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available) SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)
@ -84,9 +84,6 @@ int main()
DrawText("(c) Watermill 3D model by Alberto Cano", screenWidth - 210, screenHeight - 20, 10, GRAY); DrawText("(c) Watermill 3D model by Alberto Cano", screenWidth - 210, screenHeight - 20, 10, GRAY);
DrawText(FormatText("Camera position: (%.2f, %.2f, %.2f)", camera.position.x, camera.position.y, camera.position.z), 600, 20, 10, BLACK);
DrawText(FormatText("Camera target: (%.2f, %.2f, %.2f)", camera.target.x, camera.target.y, camera.target.z), 600, 40, 10, GRAY);
DrawFPS(10, 10); DrawFPS(10, 10);
EndDrawing(); EndDrawing();

View file

@ -69,12 +69,12 @@ static const char *paletteText[] = {
"RKBV (2-strip film)" "RKBV (2-strip film)"
}; };
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - color palette switch"); InitWindow(screenWidth, screenHeight, "raylib [shaders] example - color palette switch");

View file

@ -58,12 +58,12 @@ static const char *postproShaderText[] = {
//"FXAA" //"FXAA"
}; };
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available) SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available)

View file

@ -24,12 +24,12 @@
#define GLSL_VERSION 100 #define GLSL_VERSION 100
#endif #endif
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - raymarching shapes"); InitWindow(screenWidth, screenHeight, "raylib [shaders] example - raymarching shapes");

View file

@ -24,12 +24,12 @@
#define GLSL_VERSION 100 #define GLSL_VERSION 100
#endif #endif
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shapes and texture shaders"); InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shapes and texture shaders");
@ -40,7 +40,7 @@ int main()
// NOTE 2: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader // NOTE 2: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION)); Shader shader = LoadShader(0, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION));
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -21,12 +21,12 @@
#define GLSL_VERSION 100 #define GLSL_VERSION 100
#endif #endif
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture drawing"); InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture drawing");
@ -41,10 +41,11 @@ int main()
int timeLoc = GetShaderLocation(shader, "uTime"); int timeLoc = GetShaderLocation(shader, "uTime");
SetShaderValue(shader, timeLoc, &time, UNIFORM_FLOAT); SetShaderValue(shader, timeLoc, &time, UNIFORM_FLOAT);
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------
while (!WindowShouldClose()) // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View file

@ -26,10 +26,7 @@
#define GLSL_VERSION 100 #define GLSL_VERSION 100
#endif #endif
// ------------------------------------------------------------------------------------------------------------- int main(void)
// Main Entry point
// -------------------------------------------------------------------------------------------------------------
int main()
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -69,13 +66,13 @@ int main()
SetShaderValue(shader, speedXLoc, &speedX, UNIFORM_FLOAT); SetShaderValue(shader, speedXLoc, &speedX, UNIFORM_FLOAT);
SetShaderValue(shader, speedYLoc, &speedY, UNIFORM_FLOAT); SetShaderValue(shader, speedYLoc, &speedY, UNIFORM_FLOAT);
float seconds = 0.0f; float seconds = 0.0f;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
// ------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------
// Main game loop // Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -86,9 +83,9 @@ int main()
// Draw // Draw
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
BeginDrawing(); BeginDrawing();
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
BeginShaderMode(shader); BeginShaderMode(shader);
@ -97,7 +94,7 @@ int main()
EndShaderMode(); EndShaderMode();
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
@ -109,5 +106,5 @@ int main()
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }

View file

@ -11,16 +11,16 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing"); InitWindow(screenWidth, screenHeight, "raylib [shapes] example - basic shapes drawing");
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,7 +11,7 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//--------------------------------------------------------- //---------------------------------------------------------
@ -20,14 +20,14 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - bouncing ball"); InitWindow(screenWidth, screenHeight, "raylib [shapes] example - bouncing ball");
Vector2 ballPosition = { GetScreenWidth()/2, GetScreenHeight()/2 }; Vector2 ballPosition = { GetScreenWidth()/2, GetScreenHeight()/2 };
Vector2 ballSpeed = { 5.0f, 4.0f }; Vector2 ballSpeed = { 5.0f, 4.0f };
int ballRadius = 20; int ballRadius = 20;
bool pause = 0; bool pause = 0;
int framesCounter = 0; int framesCounter = 0;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//---------------------------------------------------------- //----------------------------------------------------------
// Main game loop // Main game loop

View file

@ -12,30 +12,30 @@
#include "raylib.h" #include "raylib.h"
#include <stdlib.h> // Required for abs() #include <stdlib.h> // Required for abs()
int main() int main(void)
{ {
// Initialization // Initialization
//--------------------------------------------------------- //---------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - collision area"); InitWindow(screenWidth, screenHeight, "raylib [shapes] example - collision area");
// Box A: Moving box // Box A: Moving box
Rectangle boxA = { 10, GetScreenHeight()/2 - 50, 200, 100 }; Rectangle boxA = { 10, GetScreenHeight()/2 - 50, 200, 100 };
int boxASpeedX = 4; int boxASpeedX = 4;
// Box B: Mouse moved box // Box B: Mouse moved box
Rectangle boxB = { GetScreenWidth()/2 - 30, GetScreenHeight()/2 - 30, 60, 60 }; Rectangle boxB = { GetScreenWidth()/2 - 30, GetScreenHeight()/2 - 30, 60, 60 };
Rectangle boxCollision = { 0 }; // Collision rectangle Rectangle boxCollision = { 0 }; // Collision rectangle
int screenUpperLimit = 40; // Top menu limits int screenUpperLimit = 40; // Top menu limits
bool pause = false; // Movement pause bool pause = false; // Movement pause
bool collision = false; // Collision detection bool collision = false; // Collision detection
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//---------------------------------------------------------- //----------------------------------------------------------
// Main game loop // Main game loop
@ -44,30 +44,30 @@ int main()
// Update // Update
//----------------------------------------------------- //-----------------------------------------------------
// Move box if not paused // Move box if not paused
if (!pause) boxA.x += boxASpeedX; if (!pause) boxA.x += boxASpeedX;
// Bounce box on x screen limits // Bounce box on x screen limits
if (((boxA.x + boxA.width) >= GetScreenWidth()) || (boxA.x <= 0)) boxASpeedX *= -1; if (((boxA.x + boxA.width) >= GetScreenWidth()) || (boxA.x <= 0)) boxASpeedX *= -1;
// Update player-controlled-box (box02) // Update player-controlled-box (box02)
boxB.x = GetMouseX() - boxB.width/2; boxB.x = GetMouseX() - boxB.width/2;
boxB.y = GetMouseY() - boxB.height/2; boxB.y = GetMouseY() - boxB.height/2;
// Make sure Box B does not go out of move area limits // Make sure Box B does not go out of move area limits
if ((boxB.x + boxB.width) >= GetScreenWidth()) boxB.x = GetScreenWidth() - boxB.width; if ((boxB.x + boxB.width) >= GetScreenWidth()) boxB.x = GetScreenWidth() - boxB.width;
else if (boxB.x <= 0) boxB.x = 0; else if (boxB.x <= 0) boxB.x = 0;
if ((boxB.y + boxB.height) >= GetScreenHeight()) boxB.y = GetScreenHeight() - boxB.height; if ((boxB.y + boxB.height) >= GetScreenHeight()) boxB.y = GetScreenHeight() - boxB.height;
else if (boxB.y <= screenUpperLimit) boxB.y = screenUpperLimit; else if (boxB.y <= screenUpperLimit) boxB.y = screenUpperLimit;
// Check boxes collision // Check boxes collision
collision = CheckCollisionRecs(boxA, boxB); collision = CheckCollisionRecs(boxA, boxB);
// Get collision rectangle (only on collision) // Get collision rectangle (only on collision)
if (collision) boxCollision = GetCollisionRec(boxA, boxB); if (collision) boxCollision = GetCollisionRec(boxA, boxB);
// Pause Box A movement // Pause Box A movement
if (IsKeyPressed(KEY_SPACE)) pause = !pause; if (IsKeyPressed(KEY_SPACE)) pause = !pause;
//----------------------------------------------------- //-----------------------------------------------------
// Draw // Draw

View file

@ -13,7 +13,7 @@
#define MAX_COLORS_COUNT 21 // Number of colors available #define MAX_COLORS_COUNT 21 // Number of colors available
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View file

@ -16,7 +16,7 @@
#define RAYGUI_IMPLEMENTATION #define RAYGUI_IMPLEMENTATION
#include "raygui.h" // Required for GUI controls #include "raygui.h" // Required for GUI controls
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -32,7 +32,7 @@ int main()
int endAngle = 180; int endAngle = 180;
int segments = 0; int segments = 0;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -35,7 +35,7 @@ int main(void)
bool drawRoundedRect = true; bool drawRoundedRect = true;
bool drawRoundedLines = false; bool drawRoundedLines = false;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -16,7 +16,7 @@
#define RAYGUI_IMPLEMENTATION #define RAYGUI_IMPLEMENTATION
#include "raygui.h" // Required for GUI controls #include "raygui.h" // Required for GUI controls
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -38,7 +38,7 @@ int main()
bool drawRingLines = false; bool drawRingLines = false;
bool drawCircleLines = false; bool drawCircleLines = false;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,9 +11,9 @@
#include "raylib.h" #include "raylib.h"
#include "easings.h" // Required for easing functions #include "easings.h" // Required for easing functions
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -30,7 +30,7 @@ int main()
int state = 0; int state = 0;
int framesCounter = 0; int framesCounter = 0;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -13,7 +13,7 @@
#include "easings.h" // Required for easing functions #include "easings.h" // Required for easing functions
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -30,7 +30,7 @@ int main()
int state = 0; int state = 0;
int framesCounter = 0; int framesCounter = 0;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -24,12 +24,12 @@
#define PLAY_TIME_IN_FRAMES 240 // At 60 fps = 4 seconds #define PLAY_TIME_IN_FRAMES 240 // At 60 fps = 4 seconds
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - easings rectangle array"); InitWindow(screenWidth, screenHeight, "raylib [shapes] example - easings rectangle array");
@ -50,7 +50,7 @@ int main()
int framesCounter = 0; int framesCounter = 0;
int state = 0; // Rectangles animation state: 0-Playing, 1-Finished int state = 0; // Rectangles animation state: 0-Playing, 1-Finished
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -13,7 +13,7 @@
#include <math.h> // Required for: atan2f() #include <math.h> // Required for: atan2f()
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -30,10 +30,10 @@ int main()
Vector2 irisRightPosition = { GetScreenWidth()/2 + 100, GetScreenHeight()/2}; Vector2 irisRightPosition = { GetScreenWidth()/2 + 100, GetScreenHeight()/2};
float irisRadius = 24; float irisRadius = 24;
float angle; float angle = 0.0f;
float dx, dy, dxx, dyy; float dx = 0.0f, dy = 0.0f, dxx = 0.0f, dyy = 0.0f;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
SetConfigFlags(FLAG_MSAA_4X_HINT); SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - cubic-bezier lines"); InitWindow(screenWidth, screenHeight, "raylib [shapes] example - cubic-bezier lines");
@ -24,7 +24,7 @@ int main()
Vector2 start = { 0, 0 }; Vector2 start = { 0, 0 };
Vector2 end = { screenWidth, screenHeight }; Vector2 end = { screenWidth, screenHeight };
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,16 +11,16 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo using shapes"); InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo using shapes");
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo animation"); InitWindow(screenWidth, screenHeight, "raylib [shapes] example - raylib logo animation");
@ -35,7 +35,7 @@ int main()
int state = 0; // Tracking animation states (State Machine) int state = 0; // Tracking animation states (State Machine)
float alpha = 1.0f; // Useful for fading float alpha = 1.0f; // Useful for fading
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -15,12 +15,12 @@
#define MOUSE_SCALE_MARK_SIZE 12 #define MOUSE_SCALE_MARK_SIZE 12
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - rectangle scaling mouse"); InitWindow(screenWidth, screenHeight, "raylib [shapes] example - rectangle scaling mouse");
@ -31,7 +31,7 @@ int main()
bool mouseScaleReady = false; bool mouseScaleReady = false;
bool mouseScaleMode = false; bool mouseScaleMode = false;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont and ttf sprite fonts loading"); InitWindow(screenWidth, screenHeight, "raylib [text] example - bmfont and ttf sprite fonts loading");
@ -35,7 +35,7 @@ int main()
bool useTtf = false; bool useTtf = false;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -17,12 +17,12 @@
#define GLSL_VERSION 100 #define GLSL_VERSION 100
#endif #endif
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - SDF fonts"); InitWindow(screenWidth, screenHeight, "raylib [text] example - SDF fonts");
@ -59,9 +59,9 @@ int main()
Vector2 fontPosition = { 40, screenHeight/2 - 50 }; Vector2 fontPosition = { 40, screenHeight/2 - 50 };
Vector2 textSize = { 0.0f }; Vector2 textSize = { 0.0f };
float fontSize = 16.0f; float fontSize = 16.0f;
int currentFont = 0; // 0 - fontDefault, 1 - fontSDF int currentFont = 0; // 0 - fontDefault, 1 - fontSDF
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - text formatting"); InitWindow(screenWidth, screenHeight, "raylib [text] example - text formatting");
@ -24,7 +24,7 @@ int main()
int hiscore = 200450; int hiscore = 200450;
int lives = 5; int lives = 5;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -13,12 +13,12 @@
#define MAX_INPUT_CHARS 9 #define MAX_INPUT_CHARS 9
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - input box"); InitWindow(screenWidth, screenHeight, "raylib [text] example - input box");
@ -30,7 +30,7 @@ int main()
int framesCounter = 0; int framesCounter = 0;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -16,12 +16,12 @@
#define MAX_FONTS 8 #define MAX_FONTS 8
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - raylib fonts"); InitWindow(screenWidth, screenHeight, "raylib [text] example - raylib fonts");
@ -62,6 +62,8 @@ int main()
positions[7].y -= 8; positions[7].y -= 8;
Color colors[MAX_FONTS] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED }; Color colors[MAX_FONTS] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED };
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -13,18 +13,18 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - draw text inside a rectangle"); InitWindow(screenWidth, screenHeight, "raylib [text] example - draw text inside a rectangle");
char text[] = "Text cannot escape\tthis container\t...word wrap also works when active so here's\ char text[] = "Text cannot escape\tthis container\t...word wrap also works when active so here's\
a long text for testing.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\ a long text for testing.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\
tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet risus nullam eget felis eget."; tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet risus nullam eget felis eget.";
bool resizing = false; bool resizing = false;
bool wordWrap = true; bool wordWrap = true;
@ -42,7 +42,7 @@ int main()
Color borderColor = MAROON; // Container border color Color borderColor = MAROON; // Container border color
Font font = GetFontDefault(); // Get default system font Font font = GetFontDefault(); // Get default system font
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - sprite fonts usage"); InitWindow(screenWidth, screenHeight, "raylib [text] example - sprite fonts usage");
@ -40,6 +40,7 @@ int main()
fontPosition3.x = screenWidth/2 - MeasureTextEx(font3, msg3, font3.baseSize, 2).x/2; fontPosition3.x = screenWidth/2 - MeasureTextEx(font3, msg3, font3.baseSize, 2).x/2;
fontPosition3.y = screenHeight/2 - font3.baseSize/2 + 50; fontPosition3.y = screenHeight/2 - font3.baseSize/2 + 50;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - ttf loading"); InitWindow(screenWidth, screenHeight, "raylib [text] example - ttf loading");
@ -35,16 +35,11 @@ int main()
Vector2 fontPosition = { 40, screenHeight/2 - 80 }; Vector2 fontPosition = { 40, screenHeight/2 - 80 };
Vector2 textSize; Vector2 textSize;
// Setup texture scaling filter
SetTextureFilter(font.texture, FILTER_POINT); SetTextureFilter(font.texture, FILTER_POINT);
int currentFontFilter = 0; // FILTER_POINT int currentFontFilter = 0; // FILTER_POINT
// NOTE: Drag and drop support only available for desktop platforms: Windows, Linux, OSX SetTargetFPS(60); // Set our game to run at 60 frames-per-second
#if defined(PLATFORM_DESKTOP)
int count = 0;
char **droppedFiles;
#endif
SetTargetFPS(60);
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop
@ -77,11 +72,11 @@ int main()
if (IsKeyDown(KEY_LEFT)) fontPosition.x -= 10; if (IsKeyDown(KEY_LEFT)) fontPosition.x -= 10;
else if (IsKeyDown(KEY_RIGHT)) fontPosition.x += 10; else if (IsKeyDown(KEY_RIGHT)) fontPosition.x += 10;
#if defined(PLATFORM_DESKTOP)
// Load a dropped TTF file dynamically (at current fontSize) // Load a dropped TTF file dynamically (at current fontSize)
if (IsFileDropped()) if (IsFileDropped())
{ {
droppedFiles = GetDroppedFiles(&count); int count = 0;
char **droppedFiles = GetDroppedFiles(&count);
if (count == 1) // Only support one ttf file dropped if (count == 1) // Only support one ttf file dropped
{ {
@ -90,7 +85,6 @@ int main()
ClearDroppedFiles(); ClearDroppedFiles();
} }
} }
#endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
@ -124,10 +118,9 @@ int main()
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
#if defined(PLATFORM_DESKTOP)
ClearDroppedFiles(); // Clear internal buffers ClearDroppedFiles(); // Clear internal buffers
#endif
UnloadFont(font); // Font unloading UnloadFont(font); // Font unloading
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View file

@ -145,9 +145,6 @@ struct {
static int hovered = -1, selected = -1; static int hovered = -1, selected = -1;
//--------------------------------------------------------------------------------------
// Main entry point
//--------------------------------------------------------------------------------------
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
// Initialization // Initialization
@ -171,11 +168,11 @@ int main(int argc, char **argv)
// Set a random set of emojis when starting up // Set a random set of emojis when starting up
RandomizeEmoji(); RandomizeEmoji();
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main loop // Main loop
while (!WindowShouldClose()) while (!WindowShouldClose()) // Detect window close button or ESC key
{ {
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -286,9 +283,9 @@ int main(int argc, char **argv)
DrawText("These emojis have something to tell you, click each to find out!", (screenWidth - 650)/2, screenHeight - 40, 20, GRAY); DrawText("These emojis have something to tell you, click each to find out!", (screenWidth - 650)/2, screenHeight - 40, 20, GRAY);
DrawText("Each emoji is a unicode character from a font, not a texture... Press [SPACEBAR] to refresh", (screenWidth - 484)/2, screenHeight - 16, 10, GRAY); DrawText("Each emoji is a unicode character from a font, not a texture... Press [SPACEBAR] to refresh", (screenWidth - 484)/2, screenHeight - 16, 10, GRAY);
EndDrawing(); EndDrawing();
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
} }
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -296,10 +293,10 @@ int main(int argc, char **argv)
UnloadFont(fontAsian); // Unload font resource UnloadFont(fontAsian); // Unload font resource
UnloadFont(fontEmoji); // Unload font resource UnloadFont(fontEmoji); // Unload font resource
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0; return 0;
} }
// Fills the emoji array with random emoji (only those emojis present in fontEmoji) // Fills the emoji array with random emoji (only those emojis present in fontEmoji)

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [text] example - text writing anim"); InitWindow(screenWidth, screenHeight, "raylib [text] example - text writing anim");
@ -24,7 +24,7 @@ int main()
int framesCounter = 0; int framesCounter = 0;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [textures] example - background scrolling"); InitWindow(screenWidth, screenHeight, "raylib [textures] example - background scrolling");
@ -30,7 +30,7 @@ int main()
float scrollingMid = 0; float scrollingMid = 0;
float scrollingFore = 0; float scrollingFore = 0;
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -25,7 +25,7 @@ typedef struct Bunny {
Color color; Color color;
} Bunny; } Bunny;
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -34,13 +34,14 @@ int main()
InitWindow(screenWidth, screenHeight, "raylib [textures] example - bunnymark"); InitWindow(screenWidth, screenHeight, "raylib [textures] example - bunnymark");
// Load bunny texture
Texture2D texBunny = LoadTexture("resources/wabbit_alpha.png"); Texture2D texBunny = LoadTexture("resources/wabbit_alpha.png");
Bunny *bunnies = (Bunny *)malloc(MAX_BUNNIES*sizeof(Bunny)); // Bunnies array Bunny *bunnies = (Bunny *)malloc(MAX_BUNNIES*sizeof(Bunny)); // Bunnies array
int bunniesCount = 0; // Bunnies counter int bunniesCount = 0; // Bunnies counter
SetTargetFPS(60); SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -13,12 +13,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [textures] example - image drawing"); InitWindow(screenWidth, screenHeight, "raylib [textures] example - image drawing");

View file

@ -13,12 +13,12 @@
#define NUM_TEXTURES 7 // Currently we have 7 generation algorithms #define NUM_TEXTURES 7 // Currently we have 7 generation algorithms
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [textures] example - procedural images generation"); InitWindow(screenWidth, screenHeight, "raylib [textures] example - procedural images generation");

View file

@ -13,12 +13,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [textures] example - image loading"); InitWindow(screenWidth, screenHeight, "raylib [textures] example - image loading");

View file

@ -13,7 +13,7 @@
#include "raylib.h" #include "raylib.h"
#include <stdlib.h> // Required for: free() #include <stdlib.h> // Required for: free()
#define NUM_PROCESSES 8 #define NUM_PROCESSES 8
@ -39,12 +39,12 @@ static const char *processText[] = {
"FLIP HORIZONTAL" "FLIP HORIZONTAL"
}; };
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [textures] example - image processing"); InitWindow(screenWidth, screenHeight, "raylib [textures] example - image processing");

View file

@ -11,20 +11,20 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [texture] example - image text drawing"); InitWindow(screenWidth, screenHeight, "raylib [texture] example - image text drawing");
Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM)
// TTF Font loading with custom generation parameters // TTF Font loading with custom generation parameters
Font font = LoadFontEx("resources/KAISG.ttf", 64, 0, 0); Font font = LoadFontEx("resources/KAISG.ttf", 64, 0, 0);
Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM)
// Draw over image using custom font // Draw over image using custom font
ImageDrawTextEx(&parrots, (Vector2){ 20.0f, 20.0f }, font, "[Parrots font drawing]", (float)font.baseSize, 0.0f, RED); ImageDrawTextEx(&parrots, (Vector2){ 20.0f, 20.0f }, font, "[Parrots font drawing]", (float)font.baseSize, 0.0f, RED);
@ -74,7 +74,7 @@ int main()
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadTexture(texture); // Texture unloading UnloadTexture(texture); // Texture unloading
UnloadFont(font); // Unload custom spritefont UnloadFont(font); // Unload custom spritefont
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View file

@ -11,12 +11,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture loading and drawing"); InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture loading and drawing");

View file

@ -15,12 +15,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [textures] example - N-patch drawing"); InitWindow(screenWidth, screenHeight, "raylib [textures] example - N-patch drawing");

View file

@ -23,12 +23,12 @@ typedef struct {
bool active; // NOTE: Use it to activate/deactive particle bool active; // NOTE: Use it to activate/deactive particle
} Particle; } Particle;
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [textures] example - particles blending"); InitWindow(screenWidth, screenHeight, "raylib [textures] example - particles blending");

View file

@ -13,14 +13,14 @@
#include "raylib.h" #include "raylib.h"
#include <stdlib.h> // Required for malloc() and free() #include <stdlib.h> // Required for: malloc() and free()
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture from raw data"); InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture from raw data");
@ -28,8 +28,8 @@ int main()
// Load RAW image data (512x512, 32bit RGBA, no file header) // Load RAW image data (512x512, 32bit RGBA, no file header)
Image fudesumiRaw = LoadImageRaw("resources/fudesumi.raw", 384, 512, UNCOMPRESSED_R8G8B8A8, 0); Image fudesumiRaw = LoadImageRaw("resources/fudesumi.raw", 384, 512, UNCOMPRESSED_R8G8B8A8, 0);
Texture2D fudesumi = LoadTextureFromImage(fudesumiRaw); // Upload CPU (RAM) image to GPU (VRAM) Texture2D fudesumi = LoadTextureFromImage(fudesumiRaw); // Upload CPU (RAM) image to GPU (VRAM)
UnloadImage(fudesumiRaw); // Unload CPU (RAM) image data UnloadImage(fudesumiRaw); // Unload CPU (RAM) image data
// Generate a checked texture by code (1024x1024 pixels) // Generate a checked texture by code (1024x1024 pixels)
int width = 960; int width = 960;
@ -50,10 +50,10 @@ int main()
// Load pixels data into an image structure and create texture // Load pixels data into an image structure and create texture
Image checkedIm = LoadImageEx(pixels, width, height); Image checkedIm = LoadImageEx(pixels, width, height);
Texture2D checked = LoadTextureFromImage(checkedIm); Texture2D checked = LoadTextureFromImage(checkedIm);
UnloadImage(checkedIm); // Unload CPU (RAM) image data UnloadImage(checkedIm); // Unload CPU (RAM) image data
// Dynamic memory must be freed after using it // Dynamic memory must be freed after using it
free(pixels); // Unload CPU (RAM) pixels data free(pixels); // Unload CPU (RAM) pixels data
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
// Main game loop // Main game loop

View file

@ -14,12 +14,12 @@
#define MAX_FRAME_SPEED 15 #define MAX_FRAME_SPEED 15
#define MIN_FRAME_SPEED 1 #define MIN_FRAME_SPEED 1
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [texture] example - texture rectangle"); InitWindow(screenWidth, screenHeight, "raylib [texture] example - texture rectangle");
@ -31,7 +31,7 @@ int main()
int currentFrame = 0; int currentFrame = 0;
int framesCounter = 0; int framesCounter = 0;
int framesSpeed = 8; // Number of spritesheet frames shown by second int framesSpeed = 8; // Number of spritesheet frames shown by second
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View file

@ -13,7 +13,7 @@
#define NUM_FRAMES 3 // Number of frames (rectangles) for the button sprite texture #define NUM_FRAMES 3 // Number of frames (rectangles) for the button sprite texture
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View file

@ -11,10 +11,10 @@
#include "raylib.h" #include "raylib.h"
#define NUM_FRAMES 8 #define NUM_FRAMES 8
#define NUM_LINES 6 #define NUM_LINES 6
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -109,7 +109,7 @@ int main()
// De-Initialization // De-Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
UnloadTexture(explosion); // Unload texture UnloadTexture(explosion); // Unload texture
UnloadSound(fxBoom); // Unload sound UnloadSound(fxBoom); // Unload sound
CloseAudioDevice(); CloseAudioDevice();

View file

@ -11,28 +11,29 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [textures] examples - texture source and destination rectangles"); InitWindow(screenWidth, screenHeight, "raylib [textures] examples - texture source and destination rectangles");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture2D scarfy = LoadTexture("resources/scarfy.png"); // Texture loading Texture2D scarfy = LoadTexture("resources/scarfy.png"); // Texture loading
int frameWidth = scarfy.width/6; int frameWidth = scarfy.width/6;
int frameHeight = scarfy.height; int frameHeight = scarfy.height;
// NOTE: Source rectangle (part of the texture to use for drawing) // Source rectangle (part of the texture to use for drawing)
Rectangle sourceRec = { 0.0f, 0.0f, frameWidth, frameHeight }; Rectangle sourceRec = { 0.0f, 0.0f, frameWidth, frameHeight };
// NOTE: Destination rectangle (screen rectangle where drawing part of texture) // Destination rectangle (screen rectangle where drawing part of texture)
Rectangle destRec = { screenWidth/2, screenHeight/2, frameWidth*2, frameHeight*2 }; Rectangle destRec = { screenWidth/2, screenHeight/2, frameWidth*2, frameHeight*2 };
// NOTE: Origin of the texture (rotation/scale point), it's relative to destination rectangle size // Origin of the texture (rotation/scale point), it's relative to destination rectangle size
Vector2 origin = { frameWidth, frameHeight }; Vector2 origin = { frameWidth, frameHeight };
int rotation = 0; int rotation = 0;

View file

@ -13,12 +13,12 @@
#include "raylib.h" #include "raylib.h"
int main() int main(void)
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
int screenWidth = 800; const int screenWidth = 800;
int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture to image"); InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture to image");