Merge branch 'master' into master
This commit is contained in:
commit
0842aabe5c
163 changed files with 2557 additions and 769 deletions
6
.github/workflows/linux.yml
vendored
6
.github/workflows/linux.yml
vendored
|
|
@ -30,17 +30,17 @@ jobs:
|
||||||
- bits: 32
|
- bits: 32
|
||||||
ARCH: "i386"
|
ARCH: "i386"
|
||||||
ARCH_NAME: "i386"
|
ARCH_NAME: "i386"
|
||||||
COMPILER_PATH: "/user/bin"
|
COMPILER_PATH: "/usr/bin"
|
||||||
runner: "ubuntu-latest"
|
runner: "ubuntu-latest"
|
||||||
- bits: 64
|
- bits: 64
|
||||||
ARCH: "x86_64"
|
ARCH: "x86_64"
|
||||||
ARCH_NAME: "amd64"
|
ARCH_NAME: "amd64"
|
||||||
COMPILER_PATH: "/user/bin"
|
COMPILER_PATH: "/usr/bin"
|
||||||
runner: "ubuntu-latest"
|
runner: "ubuntu-latest"
|
||||||
- bits: 64
|
- bits: 64
|
||||||
ARCH: "aarch64"
|
ARCH: "aarch64"
|
||||||
ARCH_NAME: "arm64"
|
ARCH_NAME: "arm64"
|
||||||
COMPILER_PATH: "/user/bin"
|
COMPILER_PATH: "/usr/bin"
|
||||||
runner: "ubuntu-24.04-arm"
|
runner: "ubuntu-24.04-arm"
|
||||||
|
|
||||||
runs-on: ${{ matrix.runner }}
|
runs-on: ${{ matrix.runner }}
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,6 @@ These are older raylib bindings that are more than 2 versions old or have not be
|
||||||
| [clj-raylib](https://github.com/lsevero/clj-raylib) | 3.0 | [Clojure](https://clojure.org) |
|
| [clj-raylib](https://github.com/lsevero/clj-raylib) | 3.0 | [Clojure](https://clojure.org) |
|
||||||
| [QuickJS-raylib](https://github.com/sntg-p/QuickJS-raylib) | 3.0 | [QuickJS](https://bellard.org/quickjs) |
|
| [QuickJS-raylib](https://github.com/sntg-p/QuickJS-raylib) | 3.0 | [QuickJS](https://bellard.org/quickjs) |
|
||||||
| [raylib-duktape](https://github.com/RobLoach/raylib-duktape) | 2.6 | [JavaScript (Duktape)](https://en.wikipedia.org/wiki/JavaScript) |
|
| [raylib-duktape](https://github.com/RobLoach/raylib-duktape) | 2.6 | [JavaScript (Duktape)](https://en.wikipedia.org/wiki/JavaScript) |
|
||||||
| [raylib-v7](https://github.com/Rabios/raylib-v7) | 3.5 | [JavaScript (v7)](https://en.wikipedia.org/wiki/JavaScript) |
|
|
||||||
| [raylib-chaiscript](https://github.com/RobLoach/raylib-chaiscript) | 2.6 | [ChaiScript](http://chaiscript.com) |
|
| [raylib-chaiscript](https://github.com/RobLoach/raylib-chaiscript) | 2.6 | [ChaiScript](http://chaiscript.com) |
|
||||||
| [raylib-squirrel](https://github.com/RobLoach/raylib-squirrel) | 2.5 | [Squirrel](http://www.squirrel-lang.org) |
|
| [raylib-squirrel](https://github.com/RobLoach/raylib-squirrel) | 2.5 | [Squirrel](http://www.squirrel-lang.org) |
|
||||||
| [racket-raylib-2d](https://github.com/arvyy/racket-raylib-2d) | 2.5 | [Racket](https://racket-lang.org) |
|
| [racket-raylib-2d](https://github.com/arvyy/racket-raylib-2d) | 2.5 | [Racket](https://racket-lang.org) |
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,10 @@ Some other conventions to follow:
|
||||||
- **ALWAYS** initialize all defined variables.
|
- **ALWAYS** initialize all defined variables.
|
||||||
- **Do not use TABS**, use 4 spaces instead.
|
- **Do not use TABS**, use 4 spaces instead.
|
||||||
- Avoid trailing spaces, please, avoid them
|
- Avoid trailing spaces, please, avoid them
|
||||||
|
- Comments always start with space + capital letter and never end with a '.', place them **before** the line(s) they refer to
|
||||||
|
```c
|
||||||
|
// This is a comment in raylib or raylib examples
|
||||||
|
```
|
||||||
- Control flow statements always are followed **by a space**:
|
- Control flow statements always are followed **by a space**:
|
||||||
```c
|
```c
|
||||||
if (condition) value = 0;
|
if (condition) value = 0;
|
||||||
|
|
|
||||||
|
|
@ -639,6 +639,7 @@ SHADERS = \
|
||||||
shaders/shaders_mesh_instancing \
|
shaders/shaders_mesh_instancing \
|
||||||
shaders/shaders_model_shader \
|
shaders/shaders_model_shader \
|
||||||
shaders/shaders_multi_sample2d \
|
shaders/shaders_multi_sample2d \
|
||||||
|
shaders/shaders_normalmap \
|
||||||
shaders/shaders_palette_switch \
|
shaders/shaders_palette_switch \
|
||||||
shaders/shaders_postprocessing \
|
shaders/shaders_postprocessing \
|
||||||
shaders/shaders_raymarching \
|
shaders/shaders_raymarching \
|
||||||
|
|
|
||||||
|
|
@ -639,6 +639,7 @@ SHADERS = \
|
||||||
shaders/shaders_mesh_instancing \
|
shaders/shaders_mesh_instancing \
|
||||||
shaders/shaders_model_shader \
|
shaders/shaders_model_shader \
|
||||||
shaders/shaders_multi_sample2d \
|
shaders/shaders_multi_sample2d \
|
||||||
|
shaders/shaders_normalmap \
|
||||||
shaders/shaders_palette_switch \
|
shaders/shaders_palette_switch \
|
||||||
shaders/shaders_postprocessing \
|
shaders/shaders_postprocessing \
|
||||||
shaders/shaders_raymarching \
|
shaders/shaders_raymarching \
|
||||||
|
|
@ -1201,6 +1202,14 @@ shaders/shaders_multi_sample2d: shaders/shaders_multi_sample2d.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||||
--preload-file shaders/resources/shaders/glsl100/color_mix.fs@resources/shaders/glsl100/color_mix.fs
|
--preload-file shaders/resources/shaders/glsl100/color_mix.fs@resources/shaders/glsl100/color_mix.fs
|
||||||
|
|
||||||
|
shaders/shaders_normalmap: shaders/shaders_normalmap.c
|
||||||
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||||
|
--preload-file shaders/resources/shaders/glsl100/normalmap.vs@resources/shaders/glsl100/normalmap.vs \
|
||||||
|
--preload-file shaders/resources/shaders/glsl100/normalmap.fs@resources/shaders/glsl100/normalmap.fs \
|
||||||
|
--preload-file shaders/resources/models/plane.glb@resources/models/plane.glb \
|
||||||
|
--preload-file shaders/resources/tiles_diffuse.png@resources/tiles_diffuse.png \
|
||||||
|
--preload-file shaders/resources/tiles_normal.png@resources/tiles_normal.png
|
||||||
|
|
||||||
shaders/shaders_palette_switch: shaders/shaders_palette_switch.c
|
shaders/shaders_palette_switch: shaders/shaders_palette_switch.c
|
||||||
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \
|
||||||
--preload-file shaders/resources/shaders/glsl100/palette_switch.fs@resources/shaders/glsl100/palette_switch.fs
|
--preload-file shaders/resources/shaders/glsl100/palette_switch.fs@resources/shaders/glsl100/palette_switch.fs
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,7 @@ You may find it easier to use than other toolchains, especially when it comes to
|
||||||
- `zig build [module]` to compile all examples for a module (e.g. `zig build core`)
|
- `zig build [module]` to compile all examples for a module (e.g. `zig build core`)
|
||||||
- `zig build [example]` to compile _and run_ a particular example (e.g. `zig build core_basic_window`)
|
- `zig build [example]` to compile _and run_ a particular example (e.g. `zig build core_basic_window`)
|
||||||
|
|
||||||
## EXAMPLES COLLECTION [TOTAL: 159]
|
## EXAMPLES COLLECTION [TOTAL: 160]
|
||||||
|
|
||||||
|
|
||||||
### category: core [36]
|
### category: core [36]
|
||||||
|
|
||||||
|
|
@ -171,7 +170,7 @@ Examples using raylib models functionality, including models loading/generation
|
||||||
| [models_bone_socket](models/models_bone_socket.c) | <img src="models/models_bone_socket.png" alt="models_bone_socket" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [iP](https://github.com/ipzaur) |
|
| [models_bone_socket](models/models_bone_socket.c) | <img src="models/models_bone_socket.png" alt="models_bone_socket" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [iP](https://github.com/ipzaur) |
|
||||||
| [models_tesseract_view](models/models_tesseract_view.c) | <img src="models/models_tesseract_view.png" alt="models_tesseract_view" width="80"> | ⭐⭐☆☆ | 5.6 | 5.6 | [Timothy van der Valk](https://github.com/arceryz) |
|
| [models_tesseract_view](models/models_tesseract_view.c) | <img src="models/models_tesseract_view.png" alt="models_tesseract_view" width="80"> | ⭐⭐☆☆ | 5.6 | 5.6 | [Timothy van der Valk](https://github.com/arceryz) |
|
||||||
|
|
||||||
### category: shaders [28]
|
### category: shaders [29]
|
||||||
|
|
||||||
Examples using raylib shaders functionality, including shaders loading, parameters configuration and drawing using them (model shaders and postprocessing shaders). This functionality is directly provided by raylib [rlgl](../src/rlgl.c) module.
|
Examples using raylib shaders functionality, including shaders loading, parameters configuration and drawing using them (model shaders and postprocessing shaders). This functionality is directly provided by raylib [rlgl](../src/rlgl.c) module.
|
||||||
|
|
||||||
|
|
@ -194,6 +193,7 @@ Examples using raylib shaders functionality, including shaders loading, paramete
|
||||||
| [shaders_hot_reloading](shaders/shaders_hot_reloading.c) | <img src="shaders/shaders_hot_reloading.png" alt="shaders_hot_reloading" width="80"> | ⭐⭐⭐☆ | 3.0 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
| [shaders_hot_reloading](shaders/shaders_hot_reloading.c) | <img src="shaders/shaders_hot_reloading.png" alt="shaders_hot_reloading" width="80"> | ⭐⭐⭐☆ | 3.0 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
||||||
| [shaders_mesh_instancing](shaders/shaders_mesh_instancing.c) | <img src="shaders/shaders_mesh_instancing.png" alt="shaders_mesh_instancing" width="80"> | ⭐⭐⭐⭐️ | 3.7 | 4.2 | [seanpringle](https://github.com/seanpringle) |
|
| [shaders_mesh_instancing](shaders/shaders_mesh_instancing.c) | <img src="shaders/shaders_mesh_instancing.png" alt="shaders_mesh_instancing" width="80"> | ⭐⭐⭐⭐️ | 3.7 | 4.2 | [seanpringle](https://github.com/seanpringle) |
|
||||||
| [shaders_multi_sample2d](shaders/shaders_multi_sample2d.c) | <img src="shaders/shaders_multi_sample2d.png" alt="shaders_multi_sample2d" width="80"> | ⭐⭐☆☆ | 3.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
| [shaders_multi_sample2d](shaders/shaders_multi_sample2d.c) | <img src="shaders/shaders_multi_sample2d.png" alt="shaders_multi_sample2d" width="80"> | ⭐⭐☆☆ | 3.5 | 3.5 | [Ramon Santamaria](https://github.com/raysan5) |
|
||||||
|
| [shaders_normalmap](shaders/shaders_normalmap.c) | <img src="shaders/shaders_normalmap.png" alt="shaders_normalmap" width="80"> | ⭐⭐⭐⭐️ | 5.6 | 5.6 | [Jeremy Montgomery](https://github.com/Sir_Irk) |
|
||||||
| [shaders_spotlight](shaders/shaders_spotlight.c) | <img src="shaders/shaders_spotlight.png" alt="shaders_spotlight" width="80"> | ⭐⭐☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
|
| [shaders_spotlight](shaders/shaders_spotlight.c) | <img src="shaders/shaders_spotlight.png" alt="shaders_spotlight" width="80"> | ⭐⭐☆☆ | 2.5 | 3.7 | [Chris Camacho](https://github.com/chriscamacho) |
|
||||||
| [shaders_deferred_render](shaders/shaders_deferred_render.c) | <img src="shaders/shaders_deferred_render.png" alt="shaders_deferred_render" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [Justin Andreas Lacoste](https://github.com/27justin) |
|
| [shaders_deferred_render](shaders/shaders_deferred_render.c) | <img src="shaders/shaders_deferred_render.png" alt="shaders_deferred_render" width="80"> | ⭐⭐⭐⭐️ | 4.5 | 4.5 | [Justin Andreas Lacoste](https://github.com/27justin) |
|
||||||
| [shaders_hybrid_render](shaders/shaders_hybrid_render.c) | <img src="shaders/shaders_hybrid_render.png" alt="shaders_hybrid_render" width="80"> | ⭐⭐⭐⭐️ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) |
|
| [shaders_hybrid_render](shaders/shaders_hybrid_render.c) | <img src="shaders/shaders_hybrid_render.png" alt="shaders_hybrid_render" width="80"> | ⭐⭐⭐⭐️ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) |
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [audio] example - Mixed audio processing
|
* raylib [audio] example - mixed audio processing
|
||||||
*
|
*
|
||||||
* Example complexity rating: [★★★★] 4/4
|
* Example complexity rating: [★★★★] 4/4
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ int main(void)
|
||||||
// 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))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -108,8 +108,6 @@ int main(void)
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Sample mouse input.
|
|
||||||
mousePosition = GetMousePosition();
|
mousePosition = GetMousePosition();
|
||||||
|
|
||||||
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
|
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
|
||||||
|
|
@ -125,7 +123,7 @@ int main(void)
|
||||||
// Compute two cycles to allow the buffer padding, simplifying any modulation, resampling, etc.
|
// Compute two cycles to allow the buffer padding, simplifying any modulation, resampling, etc.
|
||||||
if (frequency != oldFrequency)
|
if (frequency != oldFrequency)
|
||||||
{
|
{
|
||||||
// Compute wavelength. Limit size in both directions.
|
// Compute wavelength. Limit size in both directions
|
||||||
//int oldWavelength = waveLength;
|
//int oldWavelength = waveLength;
|
||||||
waveLength = (int)(22050/frequency);
|
waveLength = (int)(22050/frequency);
|
||||||
if (waveLength > MAX_SAMPLES/2) waveLength = MAX_SAMPLES/2;
|
if (waveLength > MAX_SAMPLES/2) waveLength = MAX_SAMPLES/2;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [audio] example - Playing sound multiple times
|
* raylib [audio] example - sound alias
|
||||||
*
|
*
|
||||||
* Example complexity rating: [★★☆☆] 2/4
|
* Example complexity rating: [★★☆☆] 2/4
|
||||||
*
|
*
|
||||||
|
|
@ -31,18 +31,18 @@ int main(void)
|
||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - playing sound multiple times");
|
InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound alias");
|
||||||
|
|
||||||
InitAudioDevice(); // Initialize audio device
|
InitAudioDevice(); // Initialize audio device
|
||||||
|
|
||||||
// load the sound list
|
// Load audio file into the first slot as the 'source' sound,
|
||||||
soundArray[0] = LoadSound("resources/sound.wav"); // Load WAV audio file into the first slot as the 'source' sound
|
// this sound owns the sample data
|
||||||
// this sound owns the sample data
|
soundArray[0] = LoadSound("resources/sound.wav");
|
||||||
for (int i = 1; i < MAX_SOUNDS; i++)
|
|
||||||
{
|
// Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played
|
||||||
soundArray[i] = LoadSoundAlias(soundArray[0]); // Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played
|
for (int i = 1; i < MAX_SOUNDS; i++) soundArray[i] = LoadSoundAlias(soundArray[0]);
|
||||||
}
|
|
||||||
currentSound = 0; // set the sound list to the start
|
currentSound = 0; // Set the sound list to the start
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
@ -54,14 +54,15 @@ int main(void)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (IsKeyPressed(KEY_SPACE))
|
if (IsKeyPressed(KEY_SPACE))
|
||||||
{
|
{
|
||||||
PlaySound(soundArray[currentSound]); // play the next open sound slot
|
PlaySound(soundArray[currentSound]); // Play the next open sound slot
|
||||||
currentSound++; // increment the sound slot
|
currentSound++; // Increment the sound slot
|
||||||
if (currentSound >= MAX_SOUNDS) // if the sound slot is out of bounds, go back to 0
|
|
||||||
currentSound = 0;
|
|
||||||
|
|
||||||
// Note: a better way would be to look at the list for the first sound that is not playing and use that slot
|
// If the sound slot is out of bounds, go back to 0
|
||||||
|
if (currentSound >= MAX_SOUNDS) currentSound = 0;
|
||||||
|
|
||||||
|
// NOTE: Another approach would be to look at the list for the first sound
|
||||||
|
// that is not playing and use that slot
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
@ -78,9 +79,8 @@ int main(void)
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
for (int i = 1; i < MAX_SOUNDS; i++)
|
for (int i = 1; i < MAX_SOUNDS; i++) UnloadSoundAlias(soundArray[i]); // Unload sound aliases
|
||||||
UnloadSoundAlias(soundArray[i]); // Unload sound aliases
|
UnloadSound(soundArray[0]); // Unload source sound data
|
||||||
UnloadSound(soundArray[0]); // Unload source sound data
|
|
||||||
|
|
||||||
CloseAudioDevice(); // Close audio device
|
CloseAudioDevice(); // Close audio device
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [audio] example - Playing spatialized 3D sound
|
* raylib [audio] example - spatialized 3D sound
|
||||||
*
|
*
|
||||||
* Example complexity rating: [★★☆☆] 2/4
|
* Example complexity rating: [★★☆☆] 2/4
|
||||||
*
|
*
|
||||||
|
|
@ -31,9 +31,9 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - Playing spatialized 3D sound");
|
InitWindow(screenWidth, screenHeight, "raylib [audio] example - spatialized 3D sound");
|
||||||
|
|
||||||
InitAudioDevice();
|
InitAudioDevice();
|
||||||
|
|
||||||
Sound sound = LoadSound("resources/coin.wav");
|
Sound sound = LoadSound("resources/coin.wav");
|
||||||
|
|
@ -45,9 +45,9 @@ int main(void)
|
||||||
.fovy = 60,
|
.fovy = 60,
|
||||||
.projection = CAMERA_PERSPECTIVE
|
.projection = CAMERA_PERSPECTIVE
|
||||||
};
|
};
|
||||||
|
|
||||||
DisableCursor();
|
DisableCursor();
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
UnloadSound(sound);
|
UnloadSound(sound);
|
||||||
CloseAudioDevice(); // Close audio device
|
CloseAudioDevice(); // Close audio device
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
@ -100,23 +100,23 @@ static void SetSoundPosition(Camera listener, Sound sound, Vector3 position, flo
|
||||||
// Calculate direction vector and distance between listener and sound source
|
// Calculate direction vector and distance between listener and sound source
|
||||||
Vector3 direction = Vector3Subtract(position, listener.position);
|
Vector3 direction = Vector3Subtract(position, listener.position);
|
||||||
float distance = Vector3Length(direction);
|
float distance = Vector3Length(direction);
|
||||||
|
|
||||||
// Apply logarithmic distance attenuation and clamp between 0-1
|
// Apply logarithmic distance attenuation and clamp between 0-1
|
||||||
float attenuation = 1.0f/(1.0f + (distance/maxDist));
|
float attenuation = 1.0f/(1.0f + (distance/maxDist));
|
||||||
attenuation = Clamp(attenuation, 0.0f, 1.0f);
|
attenuation = Clamp(attenuation, 0.0f, 1.0f);
|
||||||
|
|
||||||
// Calculate normalized vectors for spatial positioning
|
// Calculate normalized vectors for spatial positioning
|
||||||
Vector3 normalizedDirection = Vector3Normalize(direction);
|
Vector3 normalizedDirection = Vector3Normalize(direction);
|
||||||
Vector3 forward = Vector3Normalize(Vector3Subtract(listener.target, listener.position));
|
Vector3 forward = Vector3Normalize(Vector3Subtract(listener.target, listener.position));
|
||||||
Vector3 right = Vector3Normalize(Vector3CrossProduct(listener.up, forward));
|
Vector3 right = Vector3Normalize(Vector3CrossProduct(listener.up, forward));
|
||||||
|
|
||||||
// Reduce volume for sounds behind the listener
|
// Reduce volume for sounds behind the listener
|
||||||
float dotProduct = Vector3DotProduct(forward, normalizedDirection);
|
float dotProduct = Vector3DotProduct(forward, normalizedDirection);
|
||||||
if (dotProduct < 0.0f) attenuation *= (1.0f + dotProduct*0.5f);
|
if (dotProduct < 0.0f) attenuation *= (1.0f + dotProduct*0.5f);
|
||||||
|
|
||||||
// Set stereo panning based on sound position relative to listener
|
// Set stereo panning based on sound position relative to listener
|
||||||
float pan = 0.5f + 0.5f*Vector3DotProduct(normalizedDirection, right);
|
float pan = 0.5f + 0.5f*Vector3DotProduct(normalizedDirection, right);
|
||||||
|
|
||||||
// Apply final sound properties
|
// Apply final sound properties
|
||||||
SetSoundVolume(sound, attenuation);
|
SetSoundVolume(sound, attenuation);
|
||||||
SetSoundPan(sound, pan);
|
SetSoundPan(sound, pan);
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ int main(void)
|
||||||
|
|
||||||
float timePlayed = 0.0f; // Time played normalized [0.0f..1.0f]
|
float timePlayed = 0.0f; // Time played normalized [0.0f..1.0f]
|
||||||
bool pause = false; // Music playing paused
|
bool pause = false; // Music playing paused
|
||||||
|
|
||||||
bool enableEffectLPF = false; // Enable effect low-pass-filter
|
bool enableEffectLPF = false; // Enable effect low-pass-filter
|
||||||
bool enableEffectDelay = false; // Enable effect delay (1 second)
|
bool enableEffectDelay = false; // Enable effect delay (1 second)
|
||||||
|
|
||||||
|
|
@ -98,7 +98,7 @@ int main(void)
|
||||||
if (enableEffectDelay) AttachAudioStreamProcessor(music.stream, AudioProcessEffectDelay);
|
if (enableEffectDelay) AttachAudioStreamProcessor(music.stream, AudioProcessEffectDelay);
|
||||||
else DetachAudioStreamProcessor(music.stream, AudioProcessEffectDelay);
|
else DetachAudioStreamProcessor(music.stream, AudioProcessEffectDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get normalized time played for current music stream
|
// Get normalized time played for current music stream
|
||||||
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music);
|
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music);
|
||||||
|
|
||||||
|
|
@ -119,7 +119,7 @@ int main(void)
|
||||||
|
|
||||||
DrawText("PRESS SPACE TO RESTART MUSIC", 215, 230, 20, LIGHTGRAY);
|
DrawText("PRESS SPACE TO RESTART MUSIC", 215, 230, 20, LIGHTGRAY);
|
||||||
DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 260, 20, LIGHTGRAY);
|
DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 260, 20, LIGHTGRAY);
|
||||||
|
|
||||||
DrawText(TextFormat("PRESS F TO TOGGLE LPF EFFECT: %s", enableEffectLPF? "ON" : "OFF"), 200, 320, 20, GRAY);
|
DrawText(TextFormat("PRESS F TO TOGGLE LPF EFFECT: %s", enableEffectLPF? "ON" : "OFF"), 200, 320, 20, GRAY);
|
||||||
DrawText(TextFormat("PRESS D TO TOGGLE DELAY EFFECT: %s", enableEffectDelay? "ON" : "OFF"), 180, 350, 20, GRAY);
|
DrawText(TextFormat("PRESS D TO TOGGLE DELAY EFFECT: %s", enableEffectDelay? "ON" : "OFF"), 180, 350, 20, GRAY);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ int main ()
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (IsKeyPressed(KEY_ONE)) zoomMode = 0;
|
if (IsKeyPressed(KEY_ONE)) zoomMode = 0;
|
||||||
else if (IsKeyPressed(KEY_TWO)) zoomMode = 1;
|
else if (IsKeyPressed(KEY_TWO)) zoomMode = 1;
|
||||||
|
|
||||||
// Translate based on mouse right click
|
// Translate based on mouse right click
|
||||||
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
|
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
|
||||||
{
|
{
|
||||||
|
|
@ -68,7 +68,7 @@ int main ()
|
||||||
// Set the offset to where the mouse is
|
// Set the offset to where the mouse is
|
||||||
camera.offset = GetMousePosition();
|
camera.offset = GetMousePosition();
|
||||||
|
|
||||||
// Set the target to match, so that the camera maps the world space point
|
// Set the target to match, so that the camera maps the world space point
|
||||||
// under the cursor to the screen space point under the cursor at any zoom
|
// under the cursor to the screen space point under the cursor at any zoom
|
||||||
camera.target = mouseWorldPos;
|
camera.target = mouseWorldPos;
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ int main ()
|
||||||
// Set the offset to where the mouse is
|
// Set the offset to where the mouse is
|
||||||
camera.offset = GetMousePosition();
|
camera.offset = GetMousePosition();
|
||||||
|
|
||||||
// Set the target to match, so that the camera maps the world space point
|
// Set the target to match, so that the camera maps the world space point
|
||||||
// under the cursor to the screen space point under the cursor at any zoom
|
// under the cursor to the screen space point under the cursor at any zoom
|
||||||
camera.target = mouseWorldPos;
|
camera.target = mouseWorldPos;
|
||||||
}
|
}
|
||||||
|
|
@ -111,7 +111,7 @@ int main ()
|
||||||
|
|
||||||
BeginMode2D(camera);
|
BeginMode2D(camera);
|
||||||
|
|
||||||
// Draw the 3d grid, rotated 90 degrees and centered around 0,0
|
// Draw the 3d grid, rotated 90 degrees and centered around 0,0
|
||||||
// just so we have something in the XY plane
|
// just so we have something in the XY plane
|
||||||
rlPushMatrix();
|
rlPushMatrix();
|
||||||
rlTranslatef(0, 25*50, 0);
|
rlTranslatef(0, 25*50, 0);
|
||||||
|
|
@ -121,19 +121,19 @@ int main ()
|
||||||
|
|
||||||
// Draw a reference circle
|
// Draw a reference circle
|
||||||
DrawCircle(GetScreenWidth()/2, GetScreenHeight()/2, 50, MAROON);
|
DrawCircle(GetScreenWidth()/2, GetScreenHeight()/2, 50, MAROON);
|
||||||
|
|
||||||
EndMode2D();
|
EndMode2D();
|
||||||
|
|
||||||
// Draw mouse reference
|
// Draw mouse reference
|
||||||
//Vector2 mousePos = GetWorldToScreen2D(GetMousePosition(), camera)
|
//Vector2 mousePos = GetWorldToScreen2D(GetMousePosition(), camera)
|
||||||
DrawCircleV(GetMousePosition(), 4, DARKGRAY);
|
DrawCircleV(GetMousePosition(), 4, DARKGRAY);
|
||||||
DrawTextEx(GetFontDefault(), TextFormat("[%i, %i]", GetMouseX(), GetMouseY()),
|
DrawTextEx(GetFontDefault(), TextFormat("[%i, %i]", GetMouseX(), GetMouseY()),
|
||||||
Vector2Add(GetMousePosition(), (Vector2){ -44, -24 }), 20, 2, BLACK);
|
Vector2Add(GetMousePosition(), (Vector2){ -44, -24 }), 20, 2, BLACK);
|
||||||
|
|
||||||
DrawText("[1][2] Select mouse zoom mode (Wheel or Move)", 20, 20, 20, DARKGRAY);
|
DrawText("[1][2] Select mouse zoom mode (Wheel or Move)", 20, 20, 20, DARKGRAY);
|
||||||
if (zoomMode == 0) DrawText("Mouse left button drag to move, mouse wheel to zoom", 20, 50, 20, DARKGRAY);
|
if (zoomMode == 0) DrawText("Mouse left button drag to move, mouse wheel to zoom", 20, 50, 20, DARKGRAY);
|
||||||
else DrawText("Mouse left button drag to move, mouse press and move to zoom", 20, 50, 20, DARKGRAY);
|
else DrawText("Mouse left button drag to move, mouse press and move to zoom", 20, 50, 20, DARKGRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ int main(void)
|
||||||
|
|
||||||
Rectangle playerRect = { player.position.x - 20, player.position.y - 40, 40.0f, 40.0f };
|
Rectangle playerRect = { player.position.x - 20, player.position.y - 40, 40.0f, 40.0f };
|
||||||
DrawRectangleRec(playerRect, RED);
|
DrawRectangleRec(playerRect, RED);
|
||||||
|
|
||||||
DrawCircleV(player.position, 5.0f, GOLD);
|
DrawCircleV(player.position, 5.0f, GOLD);
|
||||||
|
|
||||||
EndMode2D();
|
EndMode2D();
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* Example complexity rating: [★★★★] 4/4
|
* Example complexity rating: [★★★★] 4/4
|
||||||
*
|
*
|
||||||
* Addapted from the core_3d_camera_split_screen example:
|
* Addapted from the core_3d_camera_split_screen example:
|
||||||
* https://github.com/raysan5/raylib/blob/master/examples/core/core_3d_camera_split_screen.c
|
* https://github.com/raysan5/raylib/blob/master/examples/core/core_3d_camera_split_screen.c
|
||||||
*
|
*
|
||||||
* Example originally created with raylib 4.5, last time updated with raylib 4.5
|
* Example originally created with raylib 4.5, last time updated with raylib 4.5
|
||||||
|
|
@ -81,9 +81,9 @@ int main(void)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
BeginTextureMode(screenCamera1);
|
BeginTextureMode(screenCamera1);
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
BeginMode2D(camera1);
|
BeginMode2D(camera1);
|
||||||
|
|
||||||
// Draw full scene with first camera
|
// Draw full scene with first camera
|
||||||
for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
|
for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -106,17 +106,17 @@ int main(void)
|
||||||
DrawRectangleRec(player1, RED);
|
DrawRectangleRec(player1, RED);
|
||||||
DrawRectangleRec(player2, BLUE);
|
DrawRectangleRec(player2, BLUE);
|
||||||
EndMode2D();
|
EndMode2D();
|
||||||
|
|
||||||
DrawRectangle(0, 0, GetScreenWidth()/2, 30, Fade(RAYWHITE, 0.6f));
|
DrawRectangle(0, 0, GetScreenWidth()/2, 30, Fade(RAYWHITE, 0.6f));
|
||||||
DrawText("PLAYER1: W/S/A/D to move", 10, 10, 10, MAROON);
|
DrawText("PLAYER1: W/S/A/D to move", 10, 10, 10, MAROON);
|
||||||
|
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
BeginTextureMode(screenCamera2);
|
BeginTextureMode(screenCamera2);
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
BeginMode2D(camera2);
|
BeginMode2D(camera2);
|
||||||
|
|
||||||
// Draw full scene with second camera
|
// Draw full scene with second camera
|
||||||
for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
|
for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -138,21 +138,21 @@ int main(void)
|
||||||
|
|
||||||
DrawRectangleRec(player1, RED);
|
DrawRectangleRec(player1, RED);
|
||||||
DrawRectangleRec(player2, BLUE);
|
DrawRectangleRec(player2, BLUE);
|
||||||
|
|
||||||
EndMode2D();
|
EndMode2D();
|
||||||
|
|
||||||
DrawRectangle(0, 0, GetScreenWidth()/2, 30, Fade(RAYWHITE, 0.6f));
|
DrawRectangle(0, 0, GetScreenWidth()/2, 30, Fade(RAYWHITE, 0.6f));
|
||||||
DrawText("PLAYER2: UP/DOWN/LEFT/RIGHT to move", 10, 10, 10, DARKBLUE);
|
DrawText("PLAYER2: UP/DOWN/LEFT/RIGHT to move", 10, 10, 10, DARKBLUE);
|
||||||
|
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
// Draw both views render textures to the screen side by side
|
// Draw both views render textures to the screen side by side
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(BLACK);
|
ClearBackground(BLACK);
|
||||||
|
|
||||||
DrawTextureRec(screenCamera1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE);
|
DrawTextureRec(screenCamera1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE);
|
||||||
DrawTextureRec(screenCamera2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE);
|
DrawTextureRec(screenCamera2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE);
|
||||||
|
|
||||||
DrawRectangle(GetScreenWidth()/2 - 2, 0, 4, GetScreenHeight(), LIGHTGRAY);
|
DrawRectangle(GetScreenWidth()/2 - 2, 0, 4, GetScreenHeight(), LIGHTGRAY);
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ int main(void)
|
||||||
UpdateCameraPro(&camera,
|
UpdateCameraPro(&camera,
|
||||||
(Vector3){
|
(Vector3){
|
||||||
(IsKeyDown(KEY_W) || IsKeyDown(KEY_UP))*0.1f - // Move forward-backward
|
(IsKeyDown(KEY_W) || IsKeyDown(KEY_UP))*0.1f - // Move forward-backward
|
||||||
(IsKeyDown(KEY_S) || IsKeyDown(KEY_DOWN))*0.1f,
|
(IsKeyDown(KEY_S) || IsKeyDown(KEY_DOWN))*0.1f,
|
||||||
(IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT))*0.1f - // Move right-left
|
(IsKeyDown(KEY_D) || IsKeyDown(KEY_RIGHT))*0.1f - // Move right-left
|
||||||
(IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT))*0.1f,
|
(IsKeyDown(KEY_A) || IsKeyDown(KEY_LEFT))*0.1f,
|
||||||
0.0f // Move up-down
|
0.0f // Move up-down
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ int main(void)
|
||||||
|
|
||||||
// Build a flipped rectangle the size of the split view to use for drawing later
|
// Build a flipped rectangle the size of the split view to use for drawing later
|
||||||
Rectangle splitScreenRect = { 0.0f, 0.0f, (float)screenPlayer1.texture.width, (float)-screenPlayer1.texture.height };
|
Rectangle splitScreenRect = { 0.0f, 0.0f, (float)screenPlayer1.texture.width, (float)-screenPlayer1.texture.height };
|
||||||
|
|
||||||
// Grid data
|
// Grid data
|
||||||
int count = 5;
|
int count = 5;
|
||||||
float spacing = 4;
|
float spacing = 4;
|
||||||
|
|
@ -98,9 +98,9 @@ int main(void)
|
||||||
// Draw Player1 view to the render texture
|
// Draw Player1 view to the render texture
|
||||||
BeginTextureMode(screenPlayer1);
|
BeginTextureMode(screenPlayer1);
|
||||||
ClearBackground(SKYBLUE);
|
ClearBackground(SKYBLUE);
|
||||||
|
|
||||||
BeginMode3D(cameraPlayer1);
|
BeginMode3D(cameraPlayer1);
|
||||||
|
|
||||||
// Draw scene: grid of cube trees on a plane to make a "world"
|
// Draw scene: grid of cube trees on a plane to make a "world"
|
||||||
DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 50, 50 }, BEIGE); // Simple world plane
|
DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 50, 50 }, BEIGE); // Simple world plane
|
||||||
|
|
||||||
|
|
@ -116,20 +116,20 @@ int main(void)
|
||||||
// Draw a cube at each player's position
|
// Draw a cube at each player's position
|
||||||
DrawCube(cameraPlayer1.position, 1, 1, 1, RED);
|
DrawCube(cameraPlayer1.position, 1, 1, 1, RED);
|
||||||
DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE);
|
DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE);
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawRectangle(0, 0, GetScreenWidth()/2, 40, Fade(RAYWHITE, 0.8f));
|
DrawRectangle(0, 0, GetScreenWidth()/2, 40, Fade(RAYWHITE, 0.8f));
|
||||||
DrawText("PLAYER1: W/S to move", 10, 10, 20, MAROON);
|
DrawText("PLAYER1: W/S to move", 10, 10, 20, MAROON);
|
||||||
|
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
// Draw Player2 view to the render texture
|
// Draw Player2 view to the render texture
|
||||||
BeginTextureMode(screenPlayer2);
|
BeginTextureMode(screenPlayer2);
|
||||||
ClearBackground(SKYBLUE);
|
ClearBackground(SKYBLUE);
|
||||||
|
|
||||||
BeginMode3D(cameraPlayer2);
|
BeginMode3D(cameraPlayer2);
|
||||||
|
|
||||||
// Draw scene: grid of cube trees on a plane to make a "world"
|
// Draw scene: grid of cube trees on a plane to make a "world"
|
||||||
DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 50, 50 }, BEIGE); // Simple world plane
|
DrawPlane((Vector3){ 0, 0, 0 }, (Vector2){ 50, 50 }, BEIGE); // Simple world plane
|
||||||
|
|
||||||
|
|
@ -145,21 +145,21 @@ int main(void)
|
||||||
// Draw a cube at each player's position
|
// Draw a cube at each player's position
|
||||||
DrawCube(cameraPlayer1.position, 1, 1, 1, RED);
|
DrawCube(cameraPlayer1.position, 1, 1, 1, RED);
|
||||||
DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE);
|
DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE);
|
||||||
|
|
||||||
EndMode3D();
|
EndMode3D();
|
||||||
|
|
||||||
DrawRectangle(0, 0, GetScreenWidth()/2, 40, Fade(RAYWHITE, 0.8f));
|
DrawRectangle(0, 0, GetScreenWidth()/2, 40, Fade(RAYWHITE, 0.8f));
|
||||||
DrawText("PLAYER2: UP/DOWN to move", 10, 10, 20, DARKBLUE);
|
DrawText("PLAYER2: UP/DOWN to move", 10, 10, 20, DARKBLUE);
|
||||||
|
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
// Draw both views render textures to the screen side by side
|
// Draw both views render textures to the screen side by side
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(BLACK);
|
ClearBackground(BLACK);
|
||||||
|
|
||||||
DrawTextureRec(screenPlayer1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE);
|
DrawTextureRec(screenPlayer1.texture, splitScreenRect, (Vector2){ 0, 0 }, WHITE);
|
||||||
DrawTextureRec(screenPlayer2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE);
|
DrawTextureRec(screenPlayer2.texture, splitScreenRect, (Vector2){ screenWidth/2.0f, 0 }, WHITE);
|
||||||
|
|
||||||
DrawRectangle(GetScreenWidth()/2 - 2, 0, 4, GetScreenHeight(), LIGHTGRAY);
|
DrawRectangle(GetScreenWidth()/2 - 2, 0, 4, GetScreenHeight(), LIGHTGRAY);
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ int main(void)
|
||||||
player.position = (Vector2){ 400, 280 };
|
player.position = (Vector2){ 400, 280 };
|
||||||
player.speed = 0;
|
player.speed = 0;
|
||||||
player.canJump = false;
|
player.canJump = false;
|
||||||
|
|
||||||
// Define environment elements (platforms)
|
// Define environment elements (platforms)
|
||||||
EnvElement envElements[MAX_ENVIRONMENT_ELEMENTS] = {
|
EnvElement envElements[MAX_ENVIRONMENT_ELEMENTS] = {
|
||||||
{{ 0, 0, 1000, 400 }, 0, LIGHTGRAY },
|
{{ 0, 0, 1000, 400 }, 0, LIGHTGRAY },
|
||||||
|
|
@ -70,13 +70,13 @@ int main(void)
|
||||||
camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f };
|
camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f };
|
||||||
camera.rotation = 0.0f;
|
camera.rotation = 0.0f;
|
||||||
camera.zoom = 1.0f;
|
camera.zoom = 1.0f;
|
||||||
|
|
||||||
// Automation events
|
// Automation events
|
||||||
AutomationEventList aelist = LoadAutomationEventList(0); // Initialize list of automation events to record new events
|
AutomationEventList aelist = LoadAutomationEventList(0); // Initialize list of automation events to record new events
|
||||||
SetAutomationEventList(&aelist);
|
SetAutomationEventList(&aelist);
|
||||||
bool eventRecording = false;
|
bool eventRecording = false;
|
||||||
bool eventPlaying = false;
|
bool eventPlaying = false;
|
||||||
|
|
||||||
unsigned int frameCounter = 0;
|
unsigned int frameCounter = 0;
|
||||||
unsigned int playFrameCounter = 0;
|
unsigned int playFrameCounter = 0;
|
||||||
unsigned int currentPlayFrame = 0;
|
unsigned int currentPlayFrame = 0;
|
||||||
|
|
@ -90,7 +90,7 @@ int main(void)
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
float deltaTime = 0.015f;//GetFrameTime();
|
float deltaTime = 0.015f;//GetFrameTime();
|
||||||
|
|
||||||
// Dropped files logic
|
// Dropped files logic
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (IsFileDropped())
|
if (IsFileDropped())
|
||||||
|
|
@ -102,14 +102,14 @@ int main(void)
|
||||||
{
|
{
|
||||||
UnloadAutomationEventList(aelist);
|
UnloadAutomationEventList(aelist);
|
||||||
aelist = LoadAutomationEventList(droppedFiles.paths[0]);
|
aelist = LoadAutomationEventList(droppedFiles.paths[0]);
|
||||||
|
|
||||||
eventRecording = false;
|
eventRecording = false;
|
||||||
|
|
||||||
// Reset scene state to play
|
// Reset scene state to play
|
||||||
eventPlaying = true;
|
eventPlaying = true;
|
||||||
playFrameCounter = 0;
|
playFrameCounter = 0;
|
||||||
currentPlayFrame = 0;
|
currentPlayFrame = 0;
|
||||||
|
|
||||||
player.position = (Vector2){ 400, 280 };
|
player.position = (Vector2){ 400, 280 };
|
||||||
player.speed = 0;
|
player.speed = 0;
|
||||||
player.canJump = false;
|
player.canJump = false;
|
||||||
|
|
@ -174,7 +174,7 @@ int main(void)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Events playing
|
// Events playing
|
||||||
// NOTE: Logic must be before Camera update because it depends on mouse-wheel value,
|
// NOTE: Logic must be before Camera update because it depends on mouse-wheel value,
|
||||||
// that can be set by the played event... but some other inputs could be affected
|
// that can be set by the played event... but some other inputs could be affected
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (eventPlaying)
|
if (eventPlaying)
|
||||||
|
|
@ -228,7 +228,7 @@ int main(void)
|
||||||
if (min.x > 0) camera.offset.x = screenWidth/2 - min.x;
|
if (min.x > 0) camera.offset.x = screenWidth/2 - min.x;
|
||||||
if (min.y > 0) camera.offset.y = screenHeight/2 - min.y;
|
if (min.y > 0) camera.offset.y = screenHeight/2 - min.y;
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Events management
|
// Events management
|
||||||
if (IsKeyPressed(KEY_S)) // Toggle events recording
|
if (IsKeyPressed(KEY_S)) // Toggle events recording
|
||||||
{
|
{
|
||||||
|
|
@ -238,12 +238,12 @@ int main(void)
|
||||||
{
|
{
|
||||||
StopAutomationEventRecording();
|
StopAutomationEventRecording();
|
||||||
eventRecording = false;
|
eventRecording = false;
|
||||||
|
|
||||||
ExportAutomationEventList(aelist, "automation.rae");
|
ExportAutomationEventList(aelist, "automation.rae");
|
||||||
|
|
||||||
TraceLog(LOG_INFO, "RECORDED FRAMES: %i", aelist.count);
|
TraceLog(LOG_INFO, "RECORDED FRAMES: %i", aelist.count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetAutomationEventBaseFrame(180);
|
SetAutomationEventBaseFrame(180);
|
||||||
StartAutomationEventRecording();
|
StartAutomationEventRecording();
|
||||||
|
|
@ -293,7 +293,7 @@ int main(void)
|
||||||
DrawRectangleRec((Rectangle){ player.position.x - 20, player.position.y - 40, 40, 40 }, RED);
|
DrawRectangleRec((Rectangle){ player.position.x - 20, player.position.y - 40, 40, 40 }, RED);
|
||||||
|
|
||||||
EndMode2D();
|
EndMode2D();
|
||||||
|
|
||||||
// Draw game controls
|
// Draw game controls
|
||||||
DrawRectangle(10, 10, 290, 145, Fade(SKYBLUE, 0.5f));
|
DrawRectangle(10, 10, 290, 145, Fade(SKYBLUE, 0.5f));
|
||||||
DrawRectangleLines(10, 10, 290, 145, Fade(BLUE, 0.8f));
|
DrawRectangleLines(10, 10, 290, 145, Fade(BLUE, 0.8f));
|
||||||
|
|
@ -323,7 +323,7 @@ int main(void)
|
||||||
|
|
||||||
if (((frameCounter/15)%2) == 1) DrawText(TextFormat("PLAYING RECORDED EVENTS... [%i]", currentPlayFrame), 50, 170, 10, DARKGREEN);
|
if (((frameCounter/15)%2) == 1) DrawText(TextFormat("PLAYING RECORDED EVENTS... [%i]", currentPlayFrame), 50, 170, 10, DARKGREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
* 4. PollInputEvents()
|
* 4. PollInputEvents()
|
||||||
*
|
*
|
||||||
* To avoid steps 2, 3 and 4, flag SUPPORT_CUSTOM_FRAME_CONTROL can be enabled in
|
* To avoid steps 2, 3 and 4, flag SUPPORT_CUSTOM_FRAME_CONTROL can be enabled in
|
||||||
* config.h (it requires recompiling raylib). This way those steps are up to the user.
|
* config.h (it requires recompiling raylib). This way those steps are up to the user
|
||||||
*
|
*
|
||||||
* Note that enabling this flag invalidates some functions:
|
* Note that enabling this flag invalidates some functions:
|
||||||
* - GetFrameTime()
|
* - GetFrameTime()
|
||||||
|
|
@ -39,7 +39,7 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - custom frame control");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - custom frame control");
|
||||||
|
|
||||||
// Custom timming variables
|
// Custom timming variables
|
||||||
|
|
@ -48,11 +48,11 @@ int main(void)
|
||||||
double updateDrawTime = 0.0; // Update + Draw time
|
double updateDrawTime = 0.0; // Update + Draw time
|
||||||
double waitTime = 0.0; // Wait time (if target fps required)
|
double waitTime = 0.0; // Wait time (if target fps required)
|
||||||
float deltaTime = 0.0f; // Frame time (Update + Draw + Wait time)
|
float deltaTime = 0.0f; // Frame time (Update + Draw + Wait time)
|
||||||
|
|
||||||
float timeCounter = 0.0f; // Accumulative time counter (seconds)
|
float timeCounter = 0.0f; // Accumulative time counter (seconds)
|
||||||
float position = 0.0f; // Circle position
|
float position = 0.0f; // Circle position
|
||||||
bool pause = false; // Pause control flag
|
bool pause = false; // Pause control flag
|
||||||
|
|
||||||
int targetFPS = 60; // Our initial target fps
|
int targetFPS = 60; // Our initial target fps
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -64,12 +64,12 @@ int main(void)
|
||||||
#ifndef PLATFORM_WEB // NOTE: On non web platforms the PollInputEvents just works before the inputs checks
|
#ifndef PLATFORM_WEB // NOTE: On non web platforms the PollInputEvents just works before the inputs checks
|
||||||
PollInputEvents(); // Poll input events (SUPPORT_CUSTOM_FRAME_CONTROL)
|
PollInputEvents(); // Poll input events (SUPPORT_CUSTOM_FRAME_CONTROL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_SPACE)) pause = !pause;
|
if (IsKeyPressed(KEY_SPACE)) pause = !pause;
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_UP)) targetFPS += 20;
|
if (IsKeyPressed(KEY_UP)) targetFPS += 20;
|
||||||
else if (IsKeyPressed(KEY_DOWN)) targetFPS -= 20;
|
else if (IsKeyPressed(KEY_DOWN)) targetFPS -= 20;
|
||||||
|
|
||||||
if (targetFPS < 0) targetFPS = 0;
|
if (targetFPS < 0) targetFPS = 0;
|
||||||
|
|
||||||
if (!pause)
|
if (!pause)
|
||||||
|
|
@ -91,12 +91,12 @@ int main(void)
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
for (int i = 0; i < GetScreenWidth()/200; i++) DrawRectangle(200*i, 0, 1, GetScreenHeight(), SKYBLUE);
|
for (int i = 0; i < GetScreenWidth()/200; i++) DrawRectangle(200*i, 0, 1, GetScreenHeight(), SKYBLUE);
|
||||||
|
|
||||||
DrawCircle((int)position, GetScreenHeight()/2 - 25, 50, RED);
|
DrawCircle((int)position, GetScreenHeight()/2 - 25, 50, RED);
|
||||||
|
|
||||||
DrawText(TextFormat("%03.0f ms", timeCounter*1000.0f), (int)position - 40, GetScreenHeight()/2 - 100, 20, MAROON);
|
DrawText(TextFormat("%03.0f ms", timeCounter*1000.0f), (int)position - 40, GetScreenHeight()/2 - 100, 20, MAROON);
|
||||||
DrawText(TextFormat("PosX: %03.0f", position), (int)position - 50, GetScreenHeight()/2 + 40, 20, BLACK);
|
DrawText(TextFormat("PosX: %03.0f", position), (int)position - 50, GetScreenHeight()/2 + 40, 20, BLACK);
|
||||||
|
|
||||||
DrawText("Circle is moving at a constant 200 pixels/sec,\nindependently of the frame rate.", 10, 10, 20, DARKGRAY);
|
DrawText("Circle is moving at a constant 200 pixels/sec,\nindependently of the frame rate.", 10, 10, 20, DARKGRAY);
|
||||||
DrawText("PRESS SPACE to PAUSE MOVEMENT", 10, GetScreenHeight() - 60, 20, GRAY);
|
DrawText("PRESS SPACE to PAUSE MOVEMENT", 10, GetScreenHeight() - 60, 20, GRAY);
|
||||||
DrawText("PRESS UP | DOWN to CHANGE TARGET FPS", 10, GetScreenHeight() - 30, 20, GRAY);
|
DrawText("PRESS UP | DOWN to CHANGE TARGET FPS", 10, GetScreenHeight() - 30, 20, GRAY);
|
||||||
|
|
@ -108,18 +108,18 @@ int main(void)
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
||||||
// NOTE: In case raylib is configured to SUPPORT_CUSTOM_FRAME_CONTROL,
|
// NOTE: In case raylib is configured to SUPPORT_CUSTOM_FRAME_CONTROL,
|
||||||
// Events polling, screen buffer swap and frame time control must be managed by the user
|
// Events polling, screen buffer swap and frame time control must be managed by the user
|
||||||
|
|
||||||
SwapScreenBuffer(); // Flip the back buffer to screen (front buffer)
|
SwapScreenBuffer(); // Flip the back buffer to screen (front buffer)
|
||||||
|
|
||||||
currentTime = GetTime();
|
currentTime = GetTime();
|
||||||
updateDrawTime = currentTime - previousTime;
|
updateDrawTime = currentTime - previousTime;
|
||||||
|
|
||||||
if (targetFPS > 0) // We want a fixed frame rate
|
if (targetFPS > 0) // We want a fixed frame rate
|
||||||
{
|
{
|
||||||
waitTime = (1.0f/(float)targetFPS) - updateDrawTime;
|
waitTime = (1.0f/(float)targetFPS) - updateDrawTime;
|
||||||
if (waitTime > 0.0)
|
if (waitTime > 0.0)
|
||||||
{
|
{
|
||||||
WaitTime((float)waitTime);
|
WaitTime((float)waitTime);
|
||||||
currentTime = GetTime();
|
currentTime = GetTime();
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,10 @@
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color)
|
//------------------------------------------------------------------------------------
|
||||||
{
|
// Module functions declaration
|
||||||
Vector2 size = MeasureTextEx(GetFontDefault(), text, (float)fontSize, 3);
|
//------------------------------------------------------------------------------------
|
||||||
Vector2 pos = (Vector2){x - size.x/2, y - size.y/2 };
|
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color);
|
||||||
DrawTextEx(GetFontDefault(), text, pos, (float)fontSize, 3, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
|
|
@ -31,10 +29,20 @@ int main(void)
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
SetConfigFlags(FLAG_WINDOW_HIGHDPI | FLAG_WINDOW_RESIZABLE);
|
SetConfigFlags(FLAG_WINDOW_HIGHDPI | FLAG_WINDOW_RESIZABLE);
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - highdpi");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - highdpi");
|
||||||
SetWindowMinSize(450, 450);
|
SetWindowMinSize(450, 450);
|
||||||
|
|
||||||
|
int logicalGridDescY = 120;
|
||||||
|
int logicalGridLabelY = logicalGridDescY + 30;
|
||||||
|
int logicalGridTop = logicalGridLabelY + 30;
|
||||||
|
int logicalGridBottom = logicalGridTop + 80;
|
||||||
|
int pixelGridTop = logicalGridBottom - 20;
|
||||||
|
int pixelGridBottom = pixelGridTop + 80;
|
||||||
|
int pixelGridLabelY = pixelGridBottom + 30;
|
||||||
|
int pixelGridDescY = pixelGridLabelY + 30;
|
||||||
|
int cellSize = 50;
|
||||||
|
float cellSizePx = (float)cellSize;
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -44,67 +52,60 @@ int main(void)
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
int monitorCount = GetMonitorCount();
|
int monitorCount = GetMonitorCount();
|
||||||
if (monitorCount > 1 && IsKeyPressed(KEY_N)) {
|
|
||||||
SetWindowMonitor((GetCurrentMonitor() + 1) % monitorCount);
|
if ((monitorCount > 1) && IsKeyPressed(KEY_N))
|
||||||
|
{
|
||||||
|
SetWindowMonitor((GetCurrentMonitor() + 1)%monitorCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
int currentMonitor = GetCurrentMonitor();
|
int currentMonitor = GetCurrentMonitor();
|
||||||
|
Vector2 dpiScale = GetWindowScaleDPI();
|
||||||
|
cellSizePx = ((float)cellSize)/dpiScale.x;
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
Vector2 dpiScale = GetWindowScaleDPI();
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
int windowCenter = GetScreenWidth() / 2;
|
int windowCenter = GetScreenWidth()/2;
|
||||||
DrawTextCenter(TextFormat("Dpi Scale: %f", dpiScale.x), windowCenter, 30, 40, DARKGRAY);
|
DrawTextCenter(TextFormat("Dpi Scale: %f", dpiScale.x), windowCenter, 30, 40, DARKGRAY);
|
||||||
DrawTextCenter(TextFormat("Monitor: %d/%d ([N] next monitor)", currentMonitor+1, monitorCount), windowCenter, 70, 16, LIGHTGRAY);
|
DrawTextCenter(TextFormat("Monitor: %d/%d ([N] next monitor)", currentMonitor+1, monitorCount), windowCenter, 70, 20, LIGHTGRAY);
|
||||||
|
|
||||||
const int logicalGridDescY = 120;
|
|
||||||
const int logicalGridLabelY = logicalGridDescY + 30;
|
|
||||||
const int logicalGridTop = logicalGridLabelY + 30;
|
|
||||||
const int logicalGridBottom = logicalGridTop + 80;
|
|
||||||
const int pixelGridTop = logicalGridBottom - 20;
|
|
||||||
const int pixelGridBottom = pixelGridTop + 80;
|
|
||||||
const int pixelGridLabelY = pixelGridBottom + 30;
|
|
||||||
const int pixelGridDescY = pixelGridLabelY + 30;
|
|
||||||
|
|
||||||
const int cellSize = 50;
|
|
||||||
const float cellSizePx = ((float)cellSize) / dpiScale.x;
|
|
||||||
|
|
||||||
DrawTextCenter(TextFormat("Window is %d \"logical points\" wide", GetScreenWidth()), windowCenter, logicalGridDescY, 20, ORANGE);
|
DrawTextCenter(TextFormat("Window is %d \"logical points\" wide", GetScreenWidth()), windowCenter, logicalGridDescY, 20, ORANGE);
|
||||||
|
|
||||||
bool odd = true;
|
bool odd = true;
|
||||||
for (int i = cellSize; i < GetScreenWidth(); i += cellSize, odd = !odd) {
|
for (int i = cellSize; i < GetScreenWidth(); i += cellSize, odd = !odd)
|
||||||
if (odd) {
|
{
|
||||||
DrawRectangle(i, logicalGridTop, cellSize, logicalGridBottom-logicalGridTop, ORANGE);
|
if (odd) DrawRectangle(i, logicalGridTop, cellSize, logicalGridBottom-logicalGridTop, ORANGE);
|
||||||
}
|
|
||||||
DrawTextCenter(TextFormat("%d", i), i, logicalGridLabelY, 12, LIGHTGRAY);
|
DrawTextCenter(TextFormat("%d", i), i, logicalGridLabelY, 10, LIGHTGRAY);
|
||||||
DrawLine(i, logicalGridLabelY + 10, i, logicalGridBottom, GRAY);
|
DrawLine(i, logicalGridLabelY + 10, i, logicalGridBottom, GRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
odd = true;
|
odd = true;
|
||||||
const int minTextSpace = 30;
|
const int minTextSpace = 30;
|
||||||
int last_text_x = -minTextSpace;
|
int lastTextX = -minTextSpace;
|
||||||
for (int i = cellSize; i < GetRenderWidth(); i += cellSize, odd = !odd) {
|
for (int i = cellSize; i < GetRenderWidth(); i += cellSize, odd = !odd)
|
||||||
int x = (int)(((float)i) / dpiScale.x);
|
{
|
||||||
if (odd) {
|
int x = (int)(((float)i)/dpiScale.x);
|
||||||
DrawRectangle(x, pixelGridTop, (int)cellSizePx, pixelGridBottom-pixelGridTop, CLITERAL(Color){ 0, 121, 241, 100 });
|
if (odd) DrawRectangle(x, pixelGridTop, (int)cellSizePx, pixelGridBottom - pixelGridTop, CLITERAL(Color){ 0, 121, 241, 100 });
|
||||||
}
|
|
||||||
DrawLine(x, pixelGridTop, (int)(((float)i) / dpiScale.x), pixelGridLabelY - 10, GRAY);
|
DrawLine(x, pixelGridTop, (int)(((float)i) / dpiScale.x), pixelGridLabelY - 10, GRAY);
|
||||||
if (x - last_text_x >= minTextSpace) {
|
|
||||||
DrawTextCenter(TextFormat("%d", i), x, pixelGridLabelY, 12, LIGHTGRAY);
|
if ((x - lastTextX) >= minTextSpace)
|
||||||
last_text_x = x;
|
{
|
||||||
|
DrawTextCenter(TextFormat("%d", i), x, pixelGridLabelY, 10, LIGHTGRAY);
|
||||||
|
lastTextX = x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawTextCenter(TextFormat("Window is %d \"physical pixels\" wide", GetRenderWidth()), windowCenter, pixelGridDescY, 20, BLUE);
|
DrawTextCenter(TextFormat("Window is %d \"physical pixels\" wide", GetRenderWidth()), windowCenter, pixelGridDescY, 20, BLUE);
|
||||||
|
|
||||||
{
|
const char *text = "Can you see this?";
|
||||||
const char *text = "Can you see this?";
|
Vector2 size = MeasureTextEx(GetFontDefault(), text, 20, 3);
|
||||||
Vector2 size = MeasureTextEx(GetFontDefault(), text, 16, 3);
|
Vector2 pos = (Vector2){ GetScreenWidth() - size.x - 5, GetScreenHeight() - size.y - 5 };
|
||||||
Vector2 pos = (Vector2){GetScreenWidth() - size.x - 5, GetScreenHeight() - size.y - 5};
|
DrawTextEx(GetFontDefault(), text, pos, 20, 3, LIGHTGRAY);
|
||||||
DrawTextEx(GetFontDefault(), text, pos, 16, 3, LIGHTGRAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
@ -117,3 +118,13 @@ int main(void)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Module functions definition
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color)
|
||||||
|
{
|
||||||
|
Vector2 size = MeasureTextEx(GetFontDefault(), text, (float)fontSize, 3);
|
||||||
|
Vector2 pos = (Vector2){ x - size.x/2, y - size.y/2 };
|
||||||
|
DrawTextEx(GetFontDefault(), text, pos, (float)fontSize, 3, color);
|
||||||
|
}
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue