diff options
| author | Ray <raysan5@gmail.com> | 2017-04-09 23:46:47 +0200 |
|---|---|---|
| committer | Ray <raysan5@gmail.com> | 2017-04-09 23:46:47 +0200 |
| commit | f7bebf9861734c47d0840868f243b186a59a96ba (patch) | |
| tree | f5ca2d320c680ef5926b5455e4498646031cd5ac /docs/examples/src | |
| parent | 8374460c3986b16c68a6dea0643e9af541987d52 (diff) | |
| download | raylib-f7bebf9861734c47d0840868f243b186a59a96ba.tar.gz raylib-f7bebf9861734c47d0840868f243b186a59a96ba.zip | |
Working on web examples
Reorganizing folders
Review examples
Work on makefile and loader.html
Diffstat (limited to 'docs/examples/src')
| -rw-r--r-- | docs/examples/src/audio/audio_module_playing.c (renamed from docs/examples/src/audio_module_playing.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/audio/audio_music_stream.c (renamed from docs/examples/src/audio_music_stream.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/audio/audio_raw_stream.c (renamed from docs/examples/src/audio_raw_stream.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/audio/audio_sound_loading.c (renamed from docs/examples/src/audio_sound_loading.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_2d_camera.c (renamed from docs/examples/src/core_2d_camera.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_3d_camera_first_person.c (renamed from docs/examples/src/core_3d_camera_first_person.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_3d_camera_free.c (renamed from docs/examples/src/core_3d_camera_free.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_3d_mode.c (renamed from docs/examples/src/core_3d_mode.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_3d_picking.c (renamed from docs/examples/src/core_3d_picking.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_basic_window.c (renamed from docs/examples/src/core_basic_window.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_color_select.c (renamed from docs/examples/src/core_color_select.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_drop_files.c (renamed from docs/examples/src/core_drop_files.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_gestures_detection.c (renamed from docs/examples/src/core_gestures_detection.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_input_gamepad.c (renamed from docs/examples/src/core_input_gamepad.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_input_keys.c (renamed from docs/examples/src/core_input_keys.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_input_mouse.c (renamed from docs/examples/src/core_input_mouse.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_mouse_wheel.c (renamed from docs/examples/src/core_mouse_wheel.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_random_values.c (renamed from docs/examples/src/core_random_values.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_storage_values.c (renamed from docs/examples/src/core_storage_values.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_vr_simulator.c (renamed from docs/examples/src/core_oculus_rift.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/core/core_world_screen.c (renamed from docs/examples/src/core_world_screen.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/models/models_billboard.c (renamed from docs/examples/src/models_billboard.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/models/models_box_collisions.c (renamed from docs/examples/src/models_box_collisions.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/models/models_cubicmap.c (renamed from docs/examples/src/models_cubicmap.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/models/models_geometric_shapes.c (renamed from docs/examples/src/models_geometric_shapes.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/models/models_heightmap.c (renamed from docs/examples/src/models_heightmap.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/models/models_obj_loading.c (renamed from docs/examples/src/models_obj_loading.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/physac/physics_demo.c (renamed from docs/examples/src/physics_demo.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/physac/physics_friction.c (renamed from docs/examples/src/physics_friction.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/physac/physics_movement.c (renamed from docs/examples/src/physics_movement.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/physac/physics_restitution.c (renamed from docs/examples/src/physics_restitution.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/physac/physics_shatter.c (renamed from docs/examples/src/physics_shatter.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/shaders/shaders_custom_uniform.c (renamed from docs/examples/src/shaders_custom_uniform.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/shaders/shaders_model_shader.c (renamed from docs/examples/src/shaders_model_shader.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/shaders/shaders_postprocessing.c (renamed from docs/examples/src/shaders_postprocessing.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/shaders/shaders_shapes_textures.c (renamed from docs/examples/src/shaders_shapes_textures.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/shaders_standard_lighting.c | 120 | ||||
| -rw-r--r-- | docs/examples/src/shapes/shapes_basic_shapes.c (renamed from docs/examples/src/shapes_basic_shapes.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/shapes/shapes_colors_palette.c (renamed from docs/examples/src/shapes_colors_palette.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/shapes/shapes_logo_raylib.c (renamed from docs/examples/src/shapes_logo_raylib.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/shapes/shapes_logo_raylib_anim.c (renamed from docs/examples/src/shapes_logo_raylib_anim.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/text/text_bmfont_ttf.c (renamed from docs/examples/src/text_bmfont_ttf.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/text/text_bmfont_unordered.c (renamed from docs/examples/src/text_bmfont_unordered.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/text/text_format_text.c (renamed from docs/examples/src/text_format_text.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/text/text_rbmf_fonts.c (renamed from docs/examples/src/text_rbmf_fonts.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/text/text_sprite_fonts.c (renamed from docs/examples/src/text_sprite_fonts.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/text/text_ttf_loading.c (renamed from docs/examples/src/text_ttf_loading.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/text/text_writing_anim.c (renamed from docs/examples/src/text_writing_anim.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/text_font_select.c | 158 | ||||
| -rw-r--r-- | docs/examples/src/textures/textures_image_drawing.c (renamed from docs/examples/src/textures_image_drawing.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/textures/textures_image_loading.c (renamed from docs/examples/src/textures_image_loading.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/textures/textures_image_processing.c (renamed from docs/examples/src/textures_image_processing.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/textures/textures_logo_raylib.c (renamed from docs/examples/src/textures_logo_raylib.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/textures/textures_raw_data.c (renamed from docs/examples/src/textures_raw_data.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/textures/textures_rectangle.c (renamed from docs/examples/src/textures_rectangle.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/textures/textures_srcrec_dstrec.c (renamed from docs/examples/src/textures_srcrec_dstrec.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/textures/textures_to_image.c (renamed from docs/examples/src/textures_to_image.c) | 0 | ||||
| -rw-r--r-- | docs/examples/src/textures_formats_loading.c | 244 | ||||
| -rw-r--r-- | docs/examples/src/textures_particles_trail_blending.c | 135 |
59 files changed, 0 insertions, 657 deletions
diff --git a/docs/examples/src/audio_module_playing.c b/docs/examples/src/audio/audio_module_playing.c index a9ee4619..a9ee4619 100644 --- a/docs/examples/src/audio_module_playing.c +++ b/docs/examples/src/audio/audio_module_playing.c diff --git a/docs/examples/src/audio_music_stream.c b/docs/examples/src/audio/audio_music_stream.c index dc9d4355..dc9d4355 100644 --- a/docs/examples/src/audio_music_stream.c +++ b/docs/examples/src/audio/audio_music_stream.c diff --git a/docs/examples/src/audio_raw_stream.c b/docs/examples/src/audio/audio_raw_stream.c index c044a7e0..c044a7e0 100644 --- a/docs/examples/src/audio_raw_stream.c +++ b/docs/examples/src/audio/audio_raw_stream.c diff --git a/docs/examples/src/audio_sound_loading.c b/docs/examples/src/audio/audio_sound_loading.c index f081e8ed..f081e8ed 100644 --- a/docs/examples/src/audio_sound_loading.c +++ b/docs/examples/src/audio/audio_sound_loading.c diff --git a/docs/examples/src/core_2d_camera.c b/docs/examples/src/core/core_2d_camera.c index f2f219ef..f2f219ef 100644 --- a/docs/examples/src/core_2d_camera.c +++ b/docs/examples/src/core/core_2d_camera.c diff --git a/docs/examples/src/core_3d_camera_first_person.c b/docs/examples/src/core/core_3d_camera_first_person.c index 3998af81..3998af81 100644 --- a/docs/examples/src/core_3d_camera_first_person.c +++ b/docs/examples/src/core/core_3d_camera_first_person.c diff --git a/docs/examples/src/core_3d_camera_free.c b/docs/examples/src/core/core_3d_camera_free.c index d446e14a..d446e14a 100644 --- a/docs/examples/src/core_3d_camera_free.c +++ b/docs/examples/src/core/core_3d_camera_free.c diff --git a/docs/examples/src/core_3d_mode.c b/docs/examples/src/core/core_3d_mode.c index 5f761655..5f761655 100644 --- a/docs/examples/src/core_3d_mode.c +++ b/docs/examples/src/core/core_3d_mode.c diff --git a/docs/examples/src/core_3d_picking.c b/docs/examples/src/core/core_3d_picking.c index bd5c3347..bd5c3347 100644 --- a/docs/examples/src/core_3d_picking.c +++ b/docs/examples/src/core/core_3d_picking.c diff --git a/docs/examples/src/core_basic_window.c b/docs/examples/src/core/core_basic_window.c index 1db38c95..1db38c95 100644 --- a/docs/examples/src/core_basic_window.c +++ b/docs/examples/src/core/core_basic_window.c diff --git a/docs/examples/src/core_color_select.c b/docs/examples/src/core/core_color_select.c index 002a6931..002a6931 100644 --- a/docs/examples/src/core_color_select.c +++ b/docs/examples/src/core/core_color_select.c diff --git a/docs/examples/src/core_drop_files.c b/docs/examples/src/core/core_drop_files.c index 5c1501b8..5c1501b8 100644 --- a/docs/examples/src/core_drop_files.c +++ b/docs/examples/src/core/core_drop_files.c diff --git a/docs/examples/src/core_gestures_detection.c b/docs/examples/src/core/core_gestures_detection.c index 63a1e6bd..63a1e6bd 100644 --- a/docs/examples/src/core_gestures_detection.c +++ b/docs/examples/src/core/core_gestures_detection.c diff --git a/docs/examples/src/core_input_gamepad.c b/docs/examples/src/core/core_input_gamepad.c index f98885e3..f98885e3 100644 --- a/docs/examples/src/core_input_gamepad.c +++ b/docs/examples/src/core/core_input_gamepad.c diff --git a/docs/examples/src/core_input_keys.c b/docs/examples/src/core/core_input_keys.c index b2305246..b2305246 100644 --- a/docs/examples/src/core_input_keys.c +++ b/docs/examples/src/core/core_input_keys.c diff --git a/docs/examples/src/core_input_mouse.c b/docs/examples/src/core/core_input_mouse.c index 24d2dfcd..24d2dfcd 100644 --- a/docs/examples/src/core_input_mouse.c +++ b/docs/examples/src/core/core_input_mouse.c diff --git a/docs/examples/src/core_mouse_wheel.c b/docs/examples/src/core/core_mouse_wheel.c index 6a5252ee..6a5252ee 100644 --- a/docs/examples/src/core_mouse_wheel.c +++ b/docs/examples/src/core/core_mouse_wheel.c diff --git a/docs/examples/src/core_random_values.c b/docs/examples/src/core/core_random_values.c index 06e550dd..06e550dd 100644 --- a/docs/examples/src/core_random_values.c +++ b/docs/examples/src/core/core_random_values.c diff --git a/docs/examples/src/core_storage_values.c b/docs/examples/src/core/core_storage_values.c index 43f0882f..43f0882f 100644 --- a/docs/examples/src/core_storage_values.c +++ b/docs/examples/src/core/core_storage_values.c diff --git a/docs/examples/src/core_oculus_rift.c b/docs/examples/src/core/core_vr_simulator.c index eb628cd7..eb628cd7 100644 --- a/docs/examples/src/core_oculus_rift.c +++ b/docs/examples/src/core/core_vr_simulator.c diff --git a/docs/examples/src/core_world_screen.c b/docs/examples/src/core/core_world_screen.c index f8c53c70..f8c53c70 100644 --- a/docs/examples/src/core_world_screen.c +++ b/docs/examples/src/core/core_world_screen.c diff --git a/docs/examples/src/models_billboard.c b/docs/examples/src/models/models_billboard.c index bca9faf8..bca9faf8 100644 --- a/docs/examples/src/models_billboard.c +++ b/docs/examples/src/models/models_billboard.c diff --git a/docs/examples/src/models_box_collisions.c b/docs/examples/src/models/models_box_collisions.c index 69cec418..69cec418 100644 --- a/docs/examples/src/models_box_collisions.c +++ b/docs/examples/src/models/models_box_collisions.c diff --git a/docs/examples/src/models_cubicmap.c b/docs/examples/src/models/models_cubicmap.c index 0e613029..0e613029 100644 --- a/docs/examples/src/models_cubicmap.c +++ b/docs/examples/src/models/models_cubicmap.c diff --git a/docs/examples/src/models_geometric_shapes.c b/docs/examples/src/models/models_geometric_shapes.c index a13a1f3b..a13a1f3b 100644 --- a/docs/examples/src/models_geometric_shapes.c +++ b/docs/examples/src/models/models_geometric_shapes.c diff --git a/docs/examples/src/models_heightmap.c b/docs/examples/src/models/models_heightmap.c index 10069e03..10069e03 100644 --- a/docs/examples/src/models_heightmap.c +++ b/docs/examples/src/models/models_heightmap.c diff --git a/docs/examples/src/models_obj_loading.c b/docs/examples/src/models/models_obj_loading.c index 50d42d2e..50d42d2e 100644 --- a/docs/examples/src/models_obj_loading.c +++ b/docs/examples/src/models/models_obj_loading.c diff --git a/docs/examples/src/physics_demo.c b/docs/examples/src/physac/physics_demo.c index bed7c94d..bed7c94d 100644 --- a/docs/examples/src/physics_demo.c +++ b/docs/examples/src/physac/physics_demo.c diff --git a/docs/examples/src/physics_friction.c b/docs/examples/src/physac/physics_friction.c index 28d3c4b8..28d3c4b8 100644 --- a/docs/examples/src/physics_friction.c +++ b/docs/examples/src/physac/physics_friction.c diff --git a/docs/examples/src/physics_movement.c b/docs/examples/src/physac/physics_movement.c index ca18f3df..ca18f3df 100644 --- a/docs/examples/src/physics_movement.c +++ b/docs/examples/src/physac/physics_movement.c diff --git a/docs/examples/src/physics_restitution.c b/docs/examples/src/physac/physics_restitution.c index 3543db69..3543db69 100644 --- a/docs/examples/src/physics_restitution.c +++ b/docs/examples/src/physac/physics_restitution.c diff --git a/docs/examples/src/physics_shatter.c b/docs/examples/src/physac/physics_shatter.c index 2cb9d195..2cb9d195 100644 --- a/docs/examples/src/physics_shatter.c +++ b/docs/examples/src/physac/physics_shatter.c diff --git a/docs/examples/src/shaders_custom_uniform.c b/docs/examples/src/shaders/shaders_custom_uniform.c index 89f87df9..89f87df9 100644 --- a/docs/examples/src/shaders_custom_uniform.c +++ b/docs/examples/src/shaders/shaders_custom_uniform.c diff --git a/docs/examples/src/shaders_model_shader.c b/docs/examples/src/shaders/shaders_model_shader.c index 51e9c1b3..51e9c1b3 100644 --- a/docs/examples/src/shaders_model_shader.c +++ b/docs/examples/src/shaders/shaders_model_shader.c diff --git a/docs/examples/src/shaders_postprocessing.c b/docs/examples/src/shaders/shaders_postprocessing.c index 43d1af72..43d1af72 100644 --- a/docs/examples/src/shaders_postprocessing.c +++ b/docs/examples/src/shaders/shaders_postprocessing.c diff --git a/docs/examples/src/shaders_shapes_textures.c b/docs/examples/src/shaders/shaders_shapes_textures.c index 0a14469f..0a14469f 100644 --- a/docs/examples/src/shaders_shapes_textures.c +++ b/docs/examples/src/shaders/shaders_shapes_textures.c diff --git a/docs/examples/src/shaders_standard_lighting.c b/docs/examples/src/shaders_standard_lighting.c deleted file mode 100644 index e539ec47..00000000 --- a/docs/examples/src/shaders_standard_lighting.c +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************************* -* -* raylib [shaders] example - Standard lighting (materials and lights) -* -* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support, -* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version. -* -* NOTE: Shaders used in this example are #version 330 (OpenGL 3.3), to test this example -* on OpenGL ES 2.0 platforms (Android, Raspberry Pi, HTML5), use #version 100 shaders -* raylib comes with shaders ready for both versions, check raylib/shaders install folder -* -* 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) -* -* Copyright (c) 2016 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; - - SetConfigFlags(FLAG_MSAA_4X_HINT); // Enable Multi Sampling Anti Aliasing 4x (if available) - - InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader"); - - // Define the camera to look into our 3d world - Camera camera = {{ 4.0f, 4.0f, 4.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; - Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position - - Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model - - Material material = LoadStandardMaterial(); - - material.texDiffuse = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model diffuse texture - material.texNormal = LoadTexture("resources/model/dwarf_normal.png"); // Load model normal texture - material.texSpecular = LoadTexture("resources/model/dwarf_specular.png"); // Load model specular texture - material.colDiffuse = WHITE; - material.colAmbient = (Color){0, 0, 10, 255}; - material.colSpecular = WHITE; - material.glossiness = 50.0f; - - dwarf.material = material; // Apply material to model - - Light spotLight = CreateLight(LIGHT_SPOT, (Vector3){3.0f, 5.0f, 2.0f}, (Color){255, 255, 255, 255}); - spotLight->target = (Vector3){0.0f, 0.0f, 0.0f}; - spotLight->intensity = 2.0f; - spotLight->diffuse = (Color){255, 100, 100, 255}; - spotLight->coneAngle = 60.0f; - - Light dirLight = CreateLight(LIGHT_DIRECTIONAL, (Vector3){0.0f, -3.0f, -3.0f}, (Color){255, 255, 255, 255}); - dirLight->target = (Vector3){1.0f, -2.0f, -2.0f}; - dirLight->intensity = 2.0f; - dirLight->diffuse = (Color){100, 255, 100, 255}; - - Light pointLight = CreateLight(LIGHT_POINT, (Vector3){0.0f, 4.0f, 5.0f}, (Color){255, 255, 255, 255}); - pointLight->intensity = 2.0f; - pointLight->diffuse = (Color){100, 100, 255, 255}; - pointLight->radius = 3.0f; - - // Setup orbital camera - SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - UpdateCamera(&camera); // Update camera - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - Begin3dMode(camera); - - DrawModel(dwarf, position, 2.0f, WHITE); // Draw 3d model with texture - - DrawLight(spotLight); // Draw spot light - DrawLight(dirLight); // Draw directional light - DrawLight(pointLight); // Draw point light - - DrawGrid(10, 1.0f); // Draw a grid - - End3dMode(); - - DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY); - - DrawFPS(10, 10); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadMaterial(material); // Unload material and assigned textures - UnloadModel(dwarf); // Unload model - - // Destroy all created lights - DestroyLight(pointLight); - DestroyLight(dirLight); - DestroyLight(spotLight); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/docs/examples/src/shapes_basic_shapes.c b/docs/examples/src/shapes/shapes_basic_shapes.c index 6b2719fc..6b2719fc 100644 --- a/docs/examples/src/shapes_basic_shapes.c +++ b/docs/examples/src/shapes/shapes_basic_shapes.c diff --git a/docs/examples/src/shapes_colors_palette.c b/docs/examples/src/shapes/shapes_colors_palette.c index dcab862e..dcab862e 100644 --- a/docs/examples/src/shapes_colors_palette.c +++ b/docs/examples/src/shapes/shapes_colors_palette.c diff --git a/docs/examples/src/shapes_logo_raylib.c b/docs/examples/src/shapes/shapes_logo_raylib.c index be94988c..be94988c 100644 --- a/docs/examples/src/shapes_logo_raylib.c +++ b/docs/examples/src/shapes/shapes_logo_raylib.c diff --git a/docs/examples/src/shapes_logo_raylib_anim.c b/docs/examples/src/shapes/shapes_logo_raylib_anim.c index c6d3796e..c6d3796e 100644 --- a/docs/examples/src/shapes_logo_raylib_anim.c +++ b/docs/examples/src/shapes/shapes_logo_raylib_anim.c diff --git a/docs/examples/src/text_bmfont_ttf.c b/docs/examples/src/text/text_bmfont_ttf.c index caece548..caece548 100644 --- a/docs/examples/src/text_bmfont_ttf.c +++ b/docs/examples/src/text/text_bmfont_ttf.c diff --git a/docs/examples/src/text_bmfont_unordered.c b/docs/examples/src/text/text_bmfont_unordered.c index b29c5f8b..b29c5f8b 100644 --- a/docs/examples/src/text_bmfont_unordered.c +++ b/docs/examples/src/text/text_bmfont_unordered.c diff --git a/docs/examples/src/text_format_text.c b/docs/examples/src/text/text_format_text.c index ca28be74..ca28be74 100644 --- a/docs/examples/src/text_format_text.c +++ b/docs/examples/src/text/text_format_text.c diff --git a/docs/examples/src/text_rbmf_fonts.c b/docs/examples/src/text/text_rbmf_fonts.c index b4bd851b..b4bd851b 100644 --- a/docs/examples/src/text_rbmf_fonts.c +++ b/docs/examples/src/text/text_rbmf_fonts.c diff --git a/docs/examples/src/text_sprite_fonts.c b/docs/examples/src/text/text_sprite_fonts.c index c73eda85..c73eda85 100644 --- a/docs/examples/src/text_sprite_fonts.c +++ b/docs/examples/src/text/text_sprite_fonts.c diff --git a/docs/examples/src/text_ttf_loading.c b/docs/examples/src/text/text_ttf_loading.c index 33cda7f5..33cda7f5 100644 --- a/docs/examples/src/text_ttf_loading.c +++ b/docs/examples/src/text/text_ttf_loading.c diff --git a/docs/examples/src/text_writing_anim.c b/docs/examples/src/text/text_writing_anim.c index 5563b561..5563b561 100644 --- a/docs/examples/src/text_writing_anim.c +++ b/docs/examples/src/text/text_writing_anim.c diff --git a/docs/examples/src/text_font_select.c b/docs/examples/src/text_font_select.c deleted file mode 100644 index fe586db8..00000000 --- a/docs/examples/src/text_font_select.c +++ /dev/null @@ -1,158 +0,0 @@ -/******************************************************************************************* -* -* raylib [text] example - Font selector -* -* 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) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [text] example - font selector"); - - // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - SpriteFont fonts[8]; // SpriteFont array - - fonts[0] = LoadSpriteFont("resources/fonts/alagard.rbmf"); // SpriteFont loading - fonts[1] = LoadSpriteFont("resources/fonts/pixelplay.rbmf"); // SpriteFont loading - fonts[2] = LoadSpriteFont("resources/fonts/mecha.rbmf"); // SpriteFont loading - fonts[3] = LoadSpriteFont("resources/fonts/setback.rbmf"); // SpriteFont loading - fonts[4] = LoadSpriteFont("resources/fonts/romulus.rbmf"); // SpriteFont loading - fonts[5] = LoadSpriteFont("resources/fonts/pixantiqua.rbmf"); // SpriteFont loading - fonts[6] = LoadSpriteFont("resources/fonts/alpha_beta.rbmf"); // SpriteFont loading - fonts[7] = LoadSpriteFont("resources/fonts/jupiter_crash.rbmf"); // SpriteFont loading - - int currentFont = 0; // Selected font - - Color colors[8] = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, RED }; - - const char fontNames[8][20] = { "[0] Alagard", "[1] PixelPlay", "[2] MECHA", "[3] Setback", - "[4] Romulus", "[5] PixAntiqua", "[6] Alpha Beta", "[7] Jupiter Crash" }; - - const char text[50] = "THIS is THE FONT you SELECTED!"; // Main text - - Vector2 textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].size*3, 1); - - Vector2 mousePoint; - - Color btnNextOutColor = DARKBLUE; // Button color (outside line) - Color btnNextInColor = SKYBLUE; // Button color (inside) - - int framesCounter = 0; // Useful to count frames button is 'active' = clicked - - int positionY = 180; // Text selector and button Y position - - Rectangle btnNextRec = { 673, positionY, 109, 44 }; // Button rectangle (useful for collision) - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - - // Keyboard-based font selection (easy) - if (IsKeyPressed(KEY_RIGHT)) - { - if (currentFont < 7) currentFont++; - } - - if (IsKeyPressed(KEY_LEFT)) - { - if (currentFont > 0) currentFont--; - } - - if (IsKeyPressed('0')) currentFont = 0; - else if (IsKeyPressed('1')) currentFont = 1; - else if (IsKeyPressed('2')) currentFont = 2; - else if (IsKeyPressed('3')) currentFont = 3; - else if (IsKeyPressed('4')) currentFont = 4; - else if (IsKeyPressed('5')) currentFont = 5; - else if (IsKeyPressed('6')) currentFont = 6; - else if (IsKeyPressed('7')) currentFont = 7; - - // Mouse-based font selection (NEXT button logic) - mousePoint = GetMousePosition(); - - if (CheckCollisionPointRec(mousePoint, btnNextRec)) - { - // Mouse hover button logic - if (framesCounter == 0) - { - btnNextOutColor = DARKPURPLE; - btnNextInColor = PURPLE; - } - - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) - { - framesCounter = 20; // Frames button is 'active' - btnNextOutColor = MAROON; - btnNextInColor = RED; - } - } - else - { - // Mouse not hover button - btnNextOutColor = DARKBLUE; - btnNextInColor = SKYBLUE; - } - - if (framesCounter > 0) framesCounter--; - - if (framesCounter == 1) // We change font on frame 1 - { - currentFont++; - if (currentFont > 7) currentFont = 0; - } - - // Text measurement for better positioning on screen - textSize = MeasureTextEx(fonts[currentFont], text, fonts[currentFont].size*3, 1); - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("font selector - use arroys, button or numbers", 160, 80, 20, DARKGRAY); - DrawLine(120, 120, 680, 120, DARKGRAY); - - DrawRectangle(18, positionY, 644, 44, DARKGRAY); - DrawRectangle(20, positionY + 2, 640, 40, LIGHTGRAY); - DrawText(fontNames[currentFont], 30, positionY + 13, 20, BLACK); - DrawText("< >", 610, positionY + 8, 30, BLACK); - - DrawRectangleRec(btnNextRec, btnNextOutColor); - DrawRectangle(675, positionY + 2, 105, 40, btnNextInColor); - DrawText("NEXT", 700, positionY + 13, 20, btnNextOutColor); - - DrawTextEx(fonts[currentFont], text, (Vector2){ screenWidth/2 - textSize.x/2, - 260 + (70 - textSize.y)/2 }, fonts[currentFont].size*3, - 1, colors[currentFont]); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - for (int i = 0; i < 8; i++) UnloadSpriteFont(fonts[i]); // SpriteFont(s) unloading - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/docs/examples/src/textures_image_drawing.c b/docs/examples/src/textures/textures_image_drawing.c index 1c6a1fb9..1c6a1fb9 100644 --- a/docs/examples/src/textures_image_drawing.c +++ b/docs/examples/src/textures/textures_image_drawing.c diff --git a/docs/examples/src/textures_image_loading.c b/docs/examples/src/textures/textures_image_loading.c index 54c73586..54c73586 100644 --- a/docs/examples/src/textures_image_loading.c +++ b/docs/examples/src/textures/textures_image_loading.c diff --git a/docs/examples/src/textures_image_processing.c b/docs/examples/src/textures/textures_image_processing.c index 58b746e0..58b746e0 100644 --- a/docs/examples/src/textures_image_processing.c +++ b/docs/examples/src/textures/textures_image_processing.c diff --git a/docs/examples/src/textures_logo_raylib.c b/docs/examples/src/textures/textures_logo_raylib.c index f2f93128..f2f93128 100644 --- a/docs/examples/src/textures_logo_raylib.c +++ b/docs/examples/src/textures/textures_logo_raylib.c diff --git a/docs/examples/src/textures_raw_data.c b/docs/examples/src/textures/textures_raw_data.c index d1922180..d1922180 100644 --- a/docs/examples/src/textures_raw_data.c +++ b/docs/examples/src/textures/textures_raw_data.c diff --git a/docs/examples/src/textures_rectangle.c b/docs/examples/src/textures/textures_rectangle.c index cca5b216..cca5b216 100644 --- a/docs/examples/src/textures_rectangle.c +++ b/docs/examples/src/textures/textures_rectangle.c diff --git a/docs/examples/src/textures_srcrec_dstrec.c b/docs/examples/src/textures/textures_srcrec_dstrec.c index 6d824ce6..6d824ce6 100644 --- a/docs/examples/src/textures_srcrec_dstrec.c +++ b/docs/examples/src/textures/textures_srcrec_dstrec.c diff --git a/docs/examples/src/textures_to_image.c b/docs/examples/src/textures/textures_to_image.c index 37c3b5a0..37c3b5a0 100644 --- a/docs/examples/src/textures_to_image.c +++ b/docs/examples/src/textures/textures_to_image.c diff --git a/docs/examples/src/textures_formats_loading.c b/docs/examples/src/textures_formats_loading.c deleted file mode 100644 index f416ce38..00000000 --- a/docs/examples/src/textures_formats_loading.c +++ /dev/null @@ -1,244 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - texture formats loading (compressed and uncompressed) -* -* NOTE: This example requires raylib OpenGL 3.3+ or ES2 versions for compressed textures, -* OpenGL 1.1 does not support compressed textures, only uncompressed ones. -* -* 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) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define NUM_TEXTURES 24 - -typedef enum { - PNG_R8G8B8A8 = 0, - PVR_GRAYSCALE, - PVR_GRAY_ALPHA, - PVR_R5G6B5, - PVR_R5G5B5A1, - PVR_R4G4B4A4, - DDS_R5G6B5, - DDS_R5G5B5A1, - DDS_R4G4B4A4, - DDS_R8G8B8A8, - DDS_DXT1_RGB, - DDS_DXT1_RGBA, - DDS_DXT3_RGBA, - DDS_DXT5_RGBA, - PKM_ETC1_RGB, - PKM_ETC2_RGB, - PKM_ETC2_EAC_RGBA, - KTX_ETC1_RGB, - KTX_ETC2_RGB, - KTX_ETC2_EAC_RGBA, - ASTC_4x4_LDR, - ASTC_8x8_LDR, - PVR_PVRT_RGB, - PVR_PVRT_RGBA - -} TextureFormats; - -static const char *formatText[] = { - "PNG_R8G8B8A8", - "PVR_GRAYSCALE", - "PVR_GRAY_ALPHA", - "PVR_R5G6B5", - "PVR_R5G5B5A1", - "PVR_R4G4B4A4", - "DDS_R5G6B5", - "DDS_R5G5B5A1", - "DDS_R4G4B4A4", - "DDS_R8G8B8A8", - "DDS_DXT1_RGB", - "DDS_DXT1_RGBA", - "DDS_DXT3_RGBA", - "DDS_DXT5_RGBA", - "PKM_ETC1_RGB", - "PKM_ETC2_RGB", - "PKM_ETC2_EAC_RGBA", - "KTX_ETC1_RGB", - "KTX_ETC2_RGB", - "KTX_ETC2_EAC_RGBA", - "ASTC_4x4_LDR", - "ASTC_8x8_LDR", - "PVR_PVRT_RGB", - "PVR_PVRT_RGBA" -}; - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture formats loading"); - - // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - - Texture2D sonic[NUM_TEXTURES]; - - sonic[PNG_R8G8B8A8] = LoadTexture("resources/texture_formats/sonic.png"); - - // Load UNCOMPRESSED PVR texture data - sonic[PVR_GRAYSCALE] = LoadTexture("resources/texture_formats/sonic_GRAYSCALE.pvr"); - sonic[PVR_GRAY_ALPHA] = LoadTexture("resources/texture_formats/sonic_L8A8.pvr"); - sonic[PVR_R5G6B5] = LoadTexture("resources/texture_formats/sonic_R5G6B5.pvr"); - sonic[PVR_R5G5B5A1] = LoadTexture("resources/texture_formats/sonic_R5G5B5A1.pvr"); - sonic[PVR_R4G4B4A4] = LoadTexture("resources/texture_formats/sonic_R4G4B4A4.pvr"); - - // Load UNCOMPRESSED DDS texture data - sonic[DDS_R5G6B5] = LoadTexture("resources/texture_formats/sonic_R5G6B5.dds"); - sonic[DDS_R5G5B5A1] = LoadTexture("resources/texture_formats/sonic_A1R5G5B5.dds"); - sonic[DDS_R4G4B4A4] = LoadTexture("resources/texture_formats/sonic_A4R4G4B4.dds"); - sonic[DDS_R8G8B8A8] = LoadTexture("resources/texture_formats/sonic_A8R8G8B8.dds"); - - // Load COMPRESSED DXT DDS texture data (if supported) - sonic[DDS_DXT1_RGB] = LoadTexture("resources/texture_formats/sonic_DXT1_RGB.dds"); - sonic[DDS_DXT1_RGBA] = LoadTexture("resources/texture_formats/sonic_DXT1_RGBA.dds"); - sonic[DDS_DXT3_RGBA] = LoadTexture("resources/texture_formats/sonic_DXT3_RGBA.dds"); - sonic[DDS_DXT5_RGBA] = LoadTexture("resources/texture_formats/sonic_DXT5_RGBA.dds"); - - // Load COMPRESSED ETC texture data (if supported) - sonic[PKM_ETC1_RGB] = LoadTexture("resources/texture_formats/sonic_ETC1_RGB.pkm"); - sonic[PKM_ETC2_RGB] = LoadTexture("resources/texture_formats/sonic_ETC2_RGB.pkm"); - sonic[PKM_ETC2_EAC_RGBA] = LoadTexture("resources/texture_formats/sonic_ETC2_EAC_RGBA.pkm"); - - sonic[KTX_ETC1_RGB] = LoadTexture("resources/texture_formats/sonic_ETC1_RGB.ktx"); - sonic[KTX_ETC2_RGB] = LoadTexture("resources/texture_formats/sonic_ETC2_RGB.ktx"); - sonic[KTX_ETC2_EAC_RGBA] = LoadTexture("resources/texture_formats/sonic_ETC2_EAC_RGBA.ktx"); - - // Load COMPRESSED ASTC texture data (if supported) - sonic[ASTC_4x4_LDR] = LoadTexture("resources/texture_formats/sonic_ASTC_4x4_ldr.astc"); - sonic[ASTC_8x8_LDR] = LoadTexture("resources/texture_formats/sonic_ASTC_8x8_ldr.astc"); - - // Load COMPRESSED PVR texture data (if supported) - sonic[PVR_PVRT_RGB] = LoadTexture("resources/texture_formats/sonic_PVRT_RGB.pvr"); - sonic[PVR_PVRT_RGBA] = LoadTexture("resources/texture_formats/sonic_PVRT_RGBA.pvr"); - - int selectedFormat = PNG_R8G8B8A8; - - Rectangle selectRecs[NUM_TEXTURES]; - - for (int i = 0; i < NUM_TEXTURES; i++) - { - if (i < NUM_TEXTURES/2) selectRecs[i] = (Rectangle){ 40, 30 + 32*i, 150, 30 }; - else selectRecs[i] = (Rectangle){ 40 + 152, 30 + 32*(i - NUM_TEXTURES/2), 150, 30 }; - } - - // Texture sizes in KB - float textureSizes[NUM_TEXTURES] = { - 512*512*32/8/1024, //PNG_R8G8B8A8 (32 bpp) - 512*512*8/8/1024, //PVR_GRAYSCALE (8 bpp) - 512*512*16/8/1024, //PVR_GRAY_ALPHA (16 bpp) - 512*512*16/8/1024, //PVR_R5G6B5 (16 bpp) - 512*512*16/8/1024, //PVR_R5G5B5A1 (16 bpp) - 512*512*16/8/1024, //PVR_R4G4B4A4 (16 bpp) - 512*512*16/8/1024, //DDS_R5G6B5 (16 bpp) - 512*512*16/8/1024, //DDS_R5G5B5A1 (16 bpp) - 512*512*16/8/1024, //DDS_R4G4B4A4 (16 bpp) - 512*512*32/8/1024, //DDS_R8G8B8A8 (32 bpp) - 512*512*4/8/1024, //DDS_DXT1_RGB (4 bpp) -Compressed- - 512*512*4/8/1024, //DDS_DXT1_RGBA (4 bpp) -Compressed- - 512*512*8/8/1024, //DDS_DXT3_RGBA (8 bpp) -Compressed- - 512*512*8/8/1024, //DDS_DXT5_RGBA (8 bpp) -Compressed- - 512*512*4/8/1024, //PKM_ETC1_RGB (4 bpp) -Compressed- - 512*512*4/8/1024, //PKM_ETC2_RGB (4 bpp) -Compressed- - 512*512*8/8/1024, //PKM_ETC2_EAC_RGBA (8 bpp) -Compressed- - 512*512*4/8/1024, //KTX_ETC1_RGB (4 bpp) -Compressed- - 512*512*4/8/1024, //KTX_ETC2_RGB (4 bpp) -Compressed- - 512*512*8/8/1024, //KTX_ETC2_EAC_RGBA (8 bpp) -Compressed- - 512*512*8/8/1024, //ASTC_4x4_LDR (8 bpp) -Compressed- - 512*512*2/8/1024, //ASTC_8x8_LDR (2 bpp) -Compressed- - 512*512*4/8/1024, //PVR_PVRT_RGB (4 bpp) -Compressed- - 512*512*4/8/1024, //PVR_PVRT_RGBA (4 bpp) -Compressed- - }; - - SetTargetFPS(60); // Set our game to run at 60 frames-per-second - //--------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - if (IsKeyPressed(KEY_DOWN)) - { - selectedFormat++; - if (selectedFormat >= NUM_TEXTURES) selectedFormat = 0; - } - else if (IsKeyPressed(KEY_UP)) - { - selectedFormat--; - if (selectedFormat < 0) selectedFormat = NUM_TEXTURES - 1; - } - else if (IsKeyPressed(KEY_RIGHT)) - { - if (selectedFormat < NUM_TEXTURES/2) selectedFormat += NUM_TEXTURES/2; - } - else if (IsKeyPressed(KEY_LEFT)) - { - if (selectedFormat >= NUM_TEXTURES/2) selectedFormat -= NUM_TEXTURES/2; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // Draw rectangles - for (int i = 0; i < NUM_TEXTURES; i++) - { - if (i == selectedFormat) - { - DrawRectangleRec(selectRecs[i], SKYBLUE); - DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, BLUE); - DrawText(formatText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(formatText[i], 10)/2, selectRecs[i].y + 11, 10, DARKBLUE); - } - else - { - DrawRectangleRec(selectRecs[i], LIGHTGRAY); - DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, GRAY); - DrawText(formatText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(formatText[i], 10)/2, selectRecs[i].y + 11, 10, DARKGRAY); - } - } - - // Draw selected texture - if (sonic[selectedFormat].id != 0) - { - DrawTexture(sonic[selectedFormat], 350, -10, WHITE); - } - else - { - DrawRectangleLines(488, 165, 200, 110, DARKGRAY); - DrawText("FORMAT", 550, 180, 20, MAROON); - DrawText("NOT SUPPORTED", 500, 210, 20, MAROON); - DrawText("ON YOUR GPU", 520, 240, 20, MAROON); - } - - DrawText("Select texture format (use cursor keys):", 40, 10, 10, DARKGRAY); - DrawText("Required GPU memory size (VRAM):", 40, 427, 10, DARKGRAY); - DrawText(FormatText("%4.0f KB", textureSizes[selectedFormat]), 240, 420, 20, DARKBLUE); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - for (int i = 0; i < NUM_TEXTURES; i++) UnloadTexture(sonic[i]); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file diff --git a/docs/examples/src/textures_particles_trail_blending.c b/docs/examples/src/textures_particles_trail_blending.c deleted file mode 100644 index 0b47c790..00000000 --- a/docs/examples/src/textures_particles_trail_blending.c +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************************* -* -* raylib example - particles trail blending -* -* 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) -* -* Copyright (c) 2015 Ramon Santamaria (@raysan5) -* -********************************************************************************************/ - -#include "raylib.h" - -#define MAX_PARTICLES 200 - -// Particle structure with basic data -typedef struct { - Vector2 position; - Color color; - float alpha; - float size; - float rotation; - bool active; // NOTE: Use it to activate/deactive particle -} Particle; - -int main() -{ - // Initialization - //-------------------------------------------------------------------------------------- - int screenWidth = 800; - int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] example - particles trail blending"); - - // Particles pool, reuse them! - Particle mouseTail[MAX_PARTICLES]; - - // Initialize particles - for (int i = 0; i < MAX_PARTICLES; i++) - { - mouseTail[i].position = (Vector2){ 0, 0 }; - mouseTail[i].color = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 }; - mouseTail[i].alpha = 1.0f; - mouseTail[i].size = (float)GetRandomValue(1, 30)/20.0f; - mouseTail[i].rotation = GetRandomValue(0, 360); - mouseTail[i].active = false; - } - - float gravity = 3.0f; - - Texture2D smoke = LoadTexture("resources/smoke.png"); - - int blending = BLEND_ALPHA; - - SetTargetFPS(60); - //-------------------------------------------------------------------------------------- - - // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { - // Update - //---------------------------------------------------------------------------------- - - // Activate one particle every frame and Update active particles - // NOTE: Particles initial position should be mouse position when activated - // NOTE: Particles fall down with gravity and rotation... and disappear after 2 seconds (alpha = 0) - // NOTE: When a particle disappears, active = false and it can be reused. - for (int i = 0; i < MAX_PARTICLES; i++) - { - if (!mouseTail[i].active) - { - mouseTail[i].active = true; - mouseTail[i].alpha = 1.0f; - mouseTail[i].position = GetMousePosition(); - i = MAX_PARTICLES; - } - } - - for (int i = 0; i < MAX_PARTICLES; i++) - { - if (mouseTail[i].active) - { - mouseTail[i].position.y += gravity; - mouseTail[i].alpha -= 0.01f; - - if (mouseTail[i].alpha <= 0.0f) mouseTail[i].active = false; - - mouseTail[i].rotation += 5.0f; - } - } - - if (IsKeyPressed(KEY_SPACE)) - { - if (blending == BLEND_ALPHA) blending = BLEND_ADDITIVE; - else blending = BLEND_ALPHA; - } - //---------------------------------------------------------------------------------- - - // Draw - //---------------------------------------------------------------------------------- - BeginDrawing(); - - ClearBackground(DARKGRAY); - - BeginBlendMode(blending); - - // Draw active particles - for (int i = 0; i < MAX_PARTICLES; i++) - { - if (mouseTail[i].active) DrawTexturePro(smoke, (Rectangle){ 0, 0, smoke.width, smoke.height }, - (Rectangle){ mouseTail[i].position.x, mouseTail[i].position.y, smoke.width*mouseTail[i].size, smoke.height*mouseTail[i].size }, - (Vector2){ smoke.width*mouseTail[i].size/2, smoke.height*mouseTail[i].size/2 }, mouseTail[i].rotation, - Fade(mouseTail[i].color, mouseTail[i].alpha)); - } - - EndBlendMode(); - - DrawText("PRESS SPACE to CHANGE BLENDING MODE", 180, 20, 20, BLACK); - - if (blending == BLEND_ALPHA) DrawText("ALPHA BLENDING", 290, screenHeight - 40, 20, BLACK); - else DrawText("ADDITIVE BLENDING", 280, screenHeight - 40, 20, RAYWHITE); - - EndDrawing(); - //---------------------------------------------------------------------------------- - } - - // De-Initialization - //-------------------------------------------------------------------------------------- - UnloadTexture(smoke); - - CloseWindow(); // Close window and OpenGL context - //-------------------------------------------------------------------------------------- - - return 0; -}
\ No newline at end of file |
