diff options
| author | Ray <raysan5@gmail.com> | 2016-08-06 17:09:57 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-06 17:09:57 +0200 |
| commit | 7f9513fbf41e9d340307fc0f9aeed8e5f4293a96 (patch) | |
| tree | 197829790c7dd766f2b5f44df6e5b64d895b73e4 /examples | |
| parent | 3b80e2c1e03e0f87d50ca8876b50a11c7df1f56f (diff) | |
| parent | 4960e6b6d7b4cba6125cfb8bb2fef043db8e5ba5 (diff) | |
| download | raylib-7f9513fbf41e9d340307fc0f9aeed8e5f4293a96.tar.gz raylib-7f9513fbf41e9d340307fc0f9aeed8e5f4293a96.zip | |
Merge pull request #173 from ghassanpl/develop
Fixes for some Lua bugs
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/audio_module_playing.lua | 17 | ||||
| -rw-r--r-- | examples/core_3d_picking.lua | 4 | ||||
| -rw-r--r-- | examples/core_input_gamepad.lua | 2 | ||||
| -rw-r--r-- | examples/models_billboard.lua | 8 | ||||
| -rw-r--r-- | examples/models_box_collisions.lua | 8 | ||||
| -rw-r--r-- | examples/models_cubicmap.lua | 6 | ||||
| -rw-r--r-- | examples/models_heightmap.lua | 6 | ||||
| -rw-r--r-- | examples/models_obj_loading.lua | 4 | ||||
| -rw-r--r-- | examples/rlua_execute_file.c | 42 | ||||
| -rw-r--r-- | examples/shaders_custom_uniform.lua | 6 | ||||
| -rw-r--r-- | examples/shaders_model_shader.lua | 6 | ||||
| -rw-r--r-- | examples/shaders_postprocessing.lua | 8 | ||||
| -rw-r--r-- | examples/shaders_shapes_textures.lua | 2 | ||||
| -rw-r--r-- | examples/shaders_standard_lighting.lua | 38 | ||||
| -rw-r--r-- | examples/text_font_select.lua | 2 | ||||
| -rw-r--r-- | examples/text_rbmf_fonts.lua | 2 | ||||
| -rw-r--r-- | examples/text_writing_anim.lua | 2 | ||||
| -rw-r--r-- | examples/textures_particles_trail_blending.lua | 18 |
18 files changed, 87 insertions, 94 deletions
diff --git a/examples/audio_module_playing.lua b/examples/audio_module_playing.lua index c309c253..38cf9afe 100644 --- a/examples/audio_module_playing.lua +++ b/examples/audio_module_playing.lua @@ -11,6 +11,7 @@ MAX_CIRCLES = 64 +--[[ typedef struct { -- TODO: Find a Lua alternative: TABLES? Vector2 position float radius @@ -18,6 +19,7 @@ typedef struct { -- TODO: Find a Lua alternative: TABLES? float speed Color color } CircleWave +--]] -- Initialization ------------------------------------------------------------------------------------------- @@ -35,11 +37,13 @@ local colors = { ORANGE, RED, GOLD, LIME, BLUE, VIOLET, BROWN, LIGHTGRAY, PINK, local circles = {} for i = MAX_CIRCLES, 1, -1 do + circles[i] = {} circles[i].alpha = 0.0 circles[i].radius = GetRandomValue(10, 40) + circles[i].position = Vector2(0, 0) circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius) circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius) - circles[i].speed = (float)GetRandomValue(1, 100)/20000.0 + circles[i].speed = GetRandomValue(1, 100)/20000.0 circles[i].color = colors[GetRandomValue(1, 14)] end @@ -64,8 +68,8 @@ while not WindowShouldClose() do -- Detect window close button or ESC key -- Update --------------------------------------------------------------------------------------- for i = MAX_CIRCLES, 1, -1 do - circles[i].alpha += circles[i].speed - circles[i].radius += circles[i].speed*10.0 + circles[i].alpha = circles[i].alpha + circles[i].speed + circles[i].radius = circles[i].radius + circles[i].speed*10.0 if (circles[i].alpha > 1.0) then circles[i].speed = circles[i].speed*-1 end @@ -75,7 +79,7 @@ while not WindowShouldClose() do -- Detect window close button or ESC key circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius) circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius) circles[i].color = colors[GetRandomValue(0, 13)] - circles[i].speed = (float)GetRandomValue(1, 100)/20000.0 + circles[i].speed = GetRandomValue(1, 100)/20000.0 end end @@ -108,7 +112,7 @@ while not WindowShouldClose() do -- Detect window close button or ESC key -- Draw time bar DrawRectangle(20, screenHeight - 20 - 12, screenWidth - 40, 12, LIGHTGRAY) - DrawRectangle(20, screenHeight - 20 - 12, (int)timePlayed, 12, MAROON) + DrawRectangle(20, screenHeight - 20 - 12, timePlayed, 12, MAROON) DrawRectangleLines(20, screenHeight - 20 - 12, screenWidth - 40, 12, WHITE) EndDrawing() @@ -126,6 +130,3 @@ CloseAudioDevice() -- Close audio device (music streaming is automatically s CloseWindow() -- Close window and OpenGL context ------------------------------------------------------------------------------------------- - -return 0 -}
\ No newline at end of file diff --git a/examples/core_3d_picking.lua b/examples/core_3d_picking.lua index f3f28530..2e1dc7c4 100644 --- a/examples/core_3d_picking.lua +++ b/examples/core_3d_picking.lua @@ -49,8 +49,8 @@ while not WindowShouldClose() do -- Detect window close button or ESC -- Check collision between ray and box collision = CheckCollisionRayBox(ray, - (BoundingBox){(Vector3){ cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2 }, - (Vector3){ cubePosition.x + cubeSize.x/2, cubePosition.y + cubeSize.y/2, cubePosition.z + cubeSize.z/2 }}) + (BoundingBox)((Vector3)(cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2), + (Vector3)(cubePosition.x + cubeSize.x/2, cubePosition.y + cubeSize.y/2, cubePosition.z + cubeSize.z/2))) end --------------------------------------------------------------------------------------- diff --git a/examples/core_input_gamepad.lua b/examples/core_input_gamepad.lua index eea2532c..78d9b84e 100644 --- a/examples/core_input_gamepad.lua +++ b/examples/core_input_gamepad.lua @@ -36,7 +36,7 @@ while not WindowShouldClose() do -- Detect window close button or ESC key ballPosition.x = ballPosition.x + gamepadMovement.x ballPosition.y = ballPosition.y - gamepadMovement.y - if (IsGamepadButtonPressed(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_A)) then + if (IsGamepadButtonPressed(GAMEPAD.PLAYER1, GAMEPAD.BUTTON_A)) then ballPosition.x = screenWidth/2 ballPosition.y = screenHeight/2 end diff --git a/examples/models_billboard.lua b/examples/models_billboard.lua index 22f3a6c3..25b00510 100644 --- a/examples/models_billboard.lua +++ b/examples/models_billboard.lua @@ -22,7 +22,7 @@ local camera = Camera(Vector3(5.0, 4.0, 5.0), Vector3(0.0, 2.0, 0.0), Vector3(0. local bill = LoadTexture("resources/billboard.png") -- Our texture billboard local billPosition = Vector3(0.0, 2.0, 0.0) -- Position where draw billboard -SetCameraMode(CAMERA.ORBITAL) -- Set an orbital camera mode +SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode SetCameraPosition(camera.position) -- Set internal camera position to match our camera position SetCameraTarget(camera.target) -- Set internal camera target to match our camera target SetCameraFovy(camera.fovy) -- Set internal camera field-of-view Y @@ -34,7 +34,7 @@ SetTargetFPS(60) -- Set our game to run at 60 frames-per-secon while not WindowShouldClose() do -- Detect window close button or ESC key -- Update --------------------------------------------------------------------------------------- - UpdateCamera(&camera) -- Update internal camera and our camera + UpdateCamera(camera) -- Update internal camera and our camera --------------------------------------------------------------------------------------- -- Draw @@ -45,9 +45,9 @@ while not WindowShouldClose() do -- Detect window close button or ESC Begin3dMode(camera) - DrawBillboard(camera, bill, billPosition, 2.0f, WHITE) + DrawBillboard(camera, bill, billPosition, 2.0, WHITE) - DrawGrid(10, 1.0f) -- Draw a grid + DrawGrid(10, 1.0) -- Draw a grid End3dMode() diff --git a/examples/models_box_collisions.lua b/examples/models_box_collisions.lua index f2cbb154..d8b2e4b5 100644 --- a/examples/models_box_collisions.lua +++ b/examples/models_box_collisions.lua @@ -40,10 +40,10 @@ while not WindowShouldClose() do -- Detect window close button or ESC --------------------------------------------------------------------------------------- -- Move player - if (IsKeyDown(KEY.RIGHT)) then playerPosition.x = playerPosition.x + 0.2f end - elseif (IsKeyDown(KEY.LEFT)) then playerPosition.x = playerPosition.x - 0.2f end - elseif (IsKeyDown(KEY.DOWN)) then playerPosition.z = playerPosition.z + 0.2f end - elseif (IsKeyDown(KEY.UP)) then playerPosition.z = playerPosition.z - 0.2f end + if (IsKeyDown(KEY.RIGHT)) then playerPosition.x = playerPosition.x + 0.2 + elseif (IsKeyDown(KEY.LEFT)) then playerPosition.x = playerPosition.x - 0.2 + elseif (IsKeyDown(KEY.DOWN)) then playerPosition.z = playerPosition.z + 0.2 + elseif (IsKeyDown(KEY.UP)) then playerPosition.z = playerPosition.z - 0.2 end collision = false diff --git a/examples/models_cubicmap.lua b/examples/models_cubicmap.lua index 293f1b3a..53cb2c12 100644 --- a/examples/models_cubicmap.lua +++ b/examples/models_cubicmap.lua @@ -31,7 +31,7 @@ local mapPosition = Vector3(-16.0, 0.0, -8.0) -- Set model position UnloadImage(image) -- Unload cubesmap image from RAM, already uploaded to VRAM -SetCameraMode(CAMERA.ORBITAL) -- Set an orbital camera mode +SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode SetCameraPosition(camera.position) -- Set internal camera position to match our custom camera position SetCameraFovy(camera.fovy) -- Set internal camera field-of-view Y @@ -42,7 +42,7 @@ SetTargetFPS(60) -- Set our game to run at 60 frames-per-secon while not WindowShouldClose() do -- Detect window close button or ESC key -- Update --------------------------------------------------------------------------------------- - UpdateCamera(&camera) -- Update internal camera and our camera + UpdateCamera(camera) -- Update internal camera and our camera --------------------------------------------------------------------------------------- -- Draw @@ -57,7 +57,7 @@ while not WindowShouldClose() do -- Detect window close button or ESC End3dMode() - DrawTextureEx(cubicmap, (Vector2){ screenWidth - cubicmap.width*4 - 20, 20 }, 0.0, 4.0, WHITE) + DrawTextureEx(cubicmap, (Vector2)(screenWidth - cubicmap.width*4 - 20, 20), 0.0, 4.0, WHITE) DrawRectangleLines(screenWidth - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN) DrawText("cubicmap image used to", 658, 90, 10, GRAY) diff --git a/examples/models_heightmap.lua b/examples/models_heightmap.lua index f78e3af5..6d7f6f3f 100644 --- a/examples/models_heightmap.lua +++ b/examples/models_heightmap.lua @@ -21,13 +21,13 @@ local camera = Camera(Vector3(18.0, 16.0, 18.0), Vector3(0.0, 0.0, 0.0), Vector3 local image = LoadImage("resources/heightmap.png") -- Load heightmap image (RAM) local texture = LoadTextureFromImage(image) -- Convert image to texture (VRAM) -local map = LoadHeightmap(image, Vector3(16, 8, 16) -- Load heightmap model with defined size +local map = LoadHeightmap(image, Vector3(16, 8, 16)) -- Load heightmap model with defined size map.material.texDiffuse = texture -- Set map diffuse texture local mapPosition = Vector3(-8.0, 0.0, -8.0) -- Set model position (depends on model scaling!) UnloadImage(image) -- Unload heightmap image from RAM, already uploaded to VRAM -SetCameraMode(CAMERA.ORBITAL) -- Set an orbital camera mode +SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode SetCameraPosition(camera.position) -- Set internal camera position to match our custom camera position SetTargetFPS(60) -- Set our game to run at 60 frames-per-second @@ -37,7 +37,7 @@ SetTargetFPS(60) -- Set our game to run at 60 frames-per-secon while not WindowShouldClose() do -- Detect window close button or ESC key -- Update --------------------------------------------------------------------------------------- - UpdateCamera(&camera) -- Update internal camera and our camera + UpdateCamera(camera) -- Update internal camera and our camera --------------------------------------------------------------------------------------- -- Draw diff --git a/examples/models_obj_loading.lua b/examples/models_obj_loading.lua index c534ecae..7e5c7c4b 100644 --- a/examples/models_obj_loading.lua +++ b/examples/models_obj_loading.lua @@ -42,9 +42,9 @@ while not WindowShouldClose() do -- Detect window close button or ESC Begin3dMode(camera) - DrawModel(dwarf, position, 2.0f, WHITE) -- Draw 3d model with texture + DrawModel(dwarf, position, 2.0, WHITE) -- Draw 3d model with texture - DrawGrid(10, 1.0f) -- Draw a grid + DrawGrid(10, 1.0) -- Draw a grid DrawGizmo(position) -- Draw gizmo diff --git a/examples/rlua_execute_file.c b/examples/rlua_execute_file.c index 762159f3..5c2d8654 100644 --- a/examples/rlua_execute_file.c +++ b/examples/rlua_execute_file.c @@ -29,8 +29,8 @@ int main() //-------------------------------------------------------------------------------------- // ExecuteLuaFile("core_basic_window.lua"); // OK! - // ExecuteLuaFile("core_input_keys.lua"); // OK! - // ExecuteLuaFile("core_input_mouse.lua"); // OK! + // ExecuteLuaFile("core_input_keys.lua"); // OK! + // ExecuteLuaFile("core_input_mouse.lua"); // OK! // ExecuteLuaFile("core_mouse_wheel.lua"); // OK! // ExecuteLuaFile("core_input_gamepad.lua"); // OK! // ExecuteLuaFile("core_random_values.lua"); // OK! @@ -55,31 +55,31 @@ int main() // ExecuteLuaFile("textures_srcrec_dstrec.lua"); // OK! // ExecuteLuaFile("textures_to_image.lua"); // OK! // ExecuteLuaFile("textures_raw_data.lua"); // ERROR: Lua Error: attempt to index a number value - // ExecuteLuaFile("textures_formats_loading.lua"); // ISSUE: texture.id not exposed to be checked - // ExecuteLuaFile("textures_particles_trail_blending.lua"); // ERROR: Using struct - // ExecuteLuaFile("textures_image_processing.lua"); // ERROR: GetImageData() --> UpdateTexture() - // ExecuteLuaFile("textures_image_drawing.lua"); // OK! - // ExecuteLuaFile("text_sprite_fonts.lua"); // OK! - // ExecuteLuaFile("text_bmfont_ttf.lua"); // OK! - // ExecuteLuaFile("text_rbmf_fonts.lua"); // ERROR: Lua Error: attempt to index a nil value - // ExecuteLuaFile("text_format_text.lua"); // OK! NOTE: Use lua string.format() instead of raylib FormatText() - // ExecuteLuaFile("text_font_select.lua"); // OK! - // ExecuteLuaFile("text_writing_anim.lua"); // ERROR: SubText() - // ExecuteLuaFile("models_geometric_shapes.lua"); // ERROR: Lua Error: attempt to index a number value - Begin3dMode(camera) - // ExecuteLuaFile("models_box_collisions.lua"); // - // ExecuteLuaFile("models_billboard.lua"); // - // ExecuteLuaFile("models_obj_loading.lua"); // - // ExecuteLuaFile("models_heightmap.lua"); // + // ExecuteLuaFile("textures_formats_loading.lua"); // ISSUE: texture.id not exposed to be checked + // ExecuteLuaFile("textures_particles_trail_blending.lua"); // ERROR: Using struct + // ExecuteLuaFile("textures_image_processing.lua"); // ERROR: GetImageData() --> UpdateTexture() + // ExecuteLuaFile("textures_image_drawing.lua"); // OK! + // ExecuteLuaFile("text_sprite_fonts.lua"); // OK! + // ExecuteLuaFile("text_bmfont_ttf.lua"); // OK! + // ExecuteLuaFile("text_rbmf_fonts.lua"); // ERROR: Lua Error: attempt to index a nil value + // ExecuteLuaFile("text_format_text.lua"); // OK! NOTE: Use lua string.format() instead of raylib FormatText() + // ExecuteLuaFile("text_font_select.lua"); // OK! + // ExecuteLuaFile("text_writing_anim.lua"); // ERROR: SubText() + // ExecuteLuaFile("models_geometric_shapes.lua"); // ERROR: Lua Error: attempt to index a number value - Begin3dMode(camera) + // ExecuteLuaFile("models_box_collisions.lua"); // + // ExecuteLuaFile("models_billboard.lua"); // + // ExecuteLuaFile("models_obj_loading.lua"); // + // ExecuteLuaFile("models_heightmap.lua"); // // ExecuteLuaFile("models_cubicmap.lua"); // - // ExecuteLuaFile("shaders_model_shader.lua"); // - // ExecuteLuaFile("shaders_shapes_textures.lua"); // + // ExecuteLuaFile("shaders_model_shader.lua"); // + // ExecuteLuaFile("shaders_shapes_textures.lua"); // // ExecuteLuaFile("shaders_custom_uniform.lua"); // // ExecuteLuaFile("shaders_postprocessing.lua"); // // ExecuteLuaFile("shaders_standard_lighting.lua"); // // ExecuteLuaFile("audio_sound_loading.lua"); // OK! // ExecuteLuaFile("audio_music_stream.lua"); // OK! - // ExecuteLuaFile("audio_module_playing.lua"); // ERROR: Using struct - // ExecuteLuaFile("audio_raw_stream.lua"); // ERROR: UpdateAudioStream() + ExecuteLuaFile("audio_module_playing.lua"); // ERROR: Using struct + ExecuteLuaFile("audio_raw_stream.lua"); // ERROR: UpdateAudioStream() // De-Initialization //-------------------------------------------------------------------------------------- diff --git a/examples/shaders_custom_uniform.lua b/examples/shaders_custom_uniform.lua index dbb672e6..b4e4d483 100644 --- a/examples/shaders_custom_uniform.lua +++ b/examples/shaders_custom_uniform.lua @@ -26,7 +26,7 @@ SetConfigFlags(FLAG.MSAA_4X_HINT) -- Enable Multi Sampling Anti Aliasing 4x InitWindow(screenWidth, screenHeight, "raylib [shaders] example - custom uniform variable") -- Define the camera to look into our 3d world -local camera = Camera(Vector3(3.0, 3.0, 3.0), Vector3(0.0, 1.5, 0.0), Vector3(0.0, 1.0, 0.0), 45.0)) +local camera = Camera(Vector3(3.0, 3.0, 3.0), Vector3(0.0, 1.5, 0.0), Vector3(0.0, 1.0, 0.0), 45.0) local dwarf = LoadModel("resources/model/dwarf.obj") -- Load OBJ model local texture = LoadTexture("resources/model/dwarf_diffuse.png") -- Load model texture (diffuse map) @@ -47,7 +47,7 @@ local swirlCenter = { screenWidth/2, screenHeight/2 } local target = LoadRenderTexture(screenWidth, screenHeight) -- Setup orbital camera -SetCameraMode(CAMERA.ORBITAL) -- Set an orbital camera mode +SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode SetCameraPosition(camera.position) -- Set internal camera position to match our camera position SetCameraTarget(camera.target) -- Set internal camera target to match our camera target @@ -66,7 +66,7 @@ while not WindowShouldClose() do -- Detect window close button or ESC key -- Send new value to the shader to be used on drawing SetShaderValue(shader, swirlCenterLoc, swirlCenter, 2) - UpdateCamera(&camera) -- Update internal camera and our camera + UpdateCamera(camera) -- Update internal camera and our camera --------------------------------------------------------------------------------------- -- Draw diff --git a/examples/shaders_model_shader.lua b/examples/shaders_model_shader.lua index deaca11c..b31c8609 100644 --- a/examples/shaders_model_shader.lua +++ b/examples/shaders_model_shader.lua @@ -26,7 +26,7 @@ SetConfigFlags(FLAG.MSAA_4X_HINT) -- Enable Multi Sampling Anti Aliasing 4x InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader") -- Define the camera to look into our 3d world -local camera = Camera(Vector3(3.0, 3.0, 3.0), Vector3(0.0, 1.5, 0.0), Vector3(0.0, 1.0, 0.0), 45.0)) +local camera = Camera(Vector3(3.0, 3.0, 3.0), Vector3(0.0, 1.5, 0.0), Vector3(0.0, 1.0, 0.0), 45.0) local dwarf = LoadModel("resources/model/dwarf.obj") -- Load OBJ model local texture = LoadTexture("resources/model/dwarf_diffuse.png") -- Load model texture @@ -39,7 +39,7 @@ dwarf.material.texDiffuse = texture -- Bind texture to model local position = Vector3(0.0, 0.0, 0.0) -- Set model position -- Setup orbital camera -SetCameraMode(CAMERA.ORBITAL) -- Set an orbital camera mode +SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode SetCameraPosition(camera.position) -- Set internal camera position to match our camera position SetCameraTarget(camera.target) -- Set internal camera target to match our camera target @@ -50,7 +50,7 @@ SetTargetFPS(60) -- Set our game to run at 60 frames-pe while not WindowShouldClose() do -- Detect window close button or ESC key -- Update --------------------------------------------------------------------------------------- - UpdateCamera(&camera) -- Update internal camera and our camera + UpdateCamera(camera) -- Update internal camera and our camera --------------------------------------------------------------------------------------- -- Draw diff --git a/examples/shaders_postprocessing.lua b/examples/shaders_postprocessing.lua index 9e4dfa00..0913fbbd 100644 --- a/examples/shaders_postprocessing.lua +++ b/examples/shaders_postprocessing.lua @@ -26,7 +26,7 @@ SetConfigFlags(FLAG.MSAA_4X_HINT) -- Enable Multi Sampling Anti Aliasing 4x InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader") -- Define the camera to look into our 3d world -local camera = Camera(Vector3(3.0, 3.0, 3.0), Vector3(0.0, 1.5, 0.0), Vector3(0.0, 1.0, 0.0), 45.0)) +local camera = Camera(Vector3(3.0, 3.0, 3.0), Vector3(0.0, 1.5, 0.0), Vector3(0.0, 1.0, 0.0), 45.0) local dwarf = LoadModel("resources/model/dwarf.obj") -- Load OBJ model local texture = LoadTexture("resources/model/dwarf_diffuse.png") -- Load model texture (diffuse map) @@ -41,7 +41,7 @@ local shader = LoadShader("resources/shaders/glsl330/base.vs", local target = LoadRenderTexture(screenWidth, screenHeight) -- Setup orbital camera -SetCameraMode(CAMERA.ORBITAL) -- Set an orbital camera mode +SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode SetCameraPosition(camera.position) -- Set internal camera position to match our camera position SetCameraTarget(camera.target) -- Set internal camera target to match our camera target @@ -52,7 +52,7 @@ SetTargetFPS(60) -- Set our game to run at 60 frames-per-s while not WindowShouldClose() do -- Detect window close button or ESC key -- Update --------------------------------------------------------------------------------------- - UpdateCamera(&camera) -- Update internal camera and our camera + UpdateCamera(camera) -- Update internal camera and our camera --------------------------------------------------------------------------------------- -- Draw @@ -88,7 +88,7 @@ while not WindowShouldClose() do -- Detect window close button or ESC key EndDrawing() --------------------------------------------------------------------------------------- -} +end -- De-Initialization ------------------------------------------------------------------------------------------- diff --git a/examples/shaders_shapes_textures.lua b/examples/shaders_shapes_textures.lua index 0adbefd2..caaeba1a 100644 --- a/examples/shaders_shapes_textures.lua +++ b/examples/shaders_shapes_textures.lua @@ -90,7 +90,7 @@ while not WindowShouldClose() do -- Detect window close button or ESC key EndDrawing() --------------------------------------------------------------------------------------- -} +end -- De-Initialization ------------------------------------------------------------------------------------------- diff --git a/examples/shaders_standard_lighting.lua b/examples/shaders_standard_lighting.lua index e8171a5f..7c354d54 100644 --- a/examples/shaders_standard_lighting.lua +++ b/examples/shaders_standard_lighting.lua @@ -26,7 +26,7 @@ SetConfigFlags(FLAG.MSAA_4X_HINT) -- Enable Multi Sampling Anti Aliasing 4x InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader") -- Define the camera to look into our 3d world -local camera = Camera(Vector3(4.0, 4.0, 4.0), Vector3(0.0, 1.5, 0.0), Vector3(0.0, 1.0, 0.0), 45.0)) +local camera = Camera(Vector3(4.0, 4.0, 4.0), Vector3(0.0, 1.5, 0.0), Vector3(0.0, 1.0, 0.0), 45.0) local position = Vector3(0.0, 0.0, 0.0) -- Set model position local dwarf = LoadModel("resources/model/dwarf.obj") -- Load OBJ model @@ -37,30 +37,30 @@ material.texDiffuse = LoadTexture("resources/model/dwarf_diffuse.png") -- Load 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.colAmbient = (Color)(0, 0, 10, 255) material.colSpecular = WHITE -material.glossiness = 50.0f +material.glossiness = 50.0 dwarf.material = material -- Apply material to model -local 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 +local spotLight = CreateLight(LIGHT_SPOT, (Vector3)(3.0, 5.0, 2.0), (Color)(255, 255, 255, 255)) +spotLight.target = (Vector3)(0.0, 0.0, 0.0) +spotLight.intensity = 2.0 +spotLight.diffuse = (Color)(255, 100, 100, 255) +spotLight.coneAngle = 60.0 -local 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} +local dirLight = CreateLight(LIGHT_DIRECTIONAL, (Vector3)(0.0, -3.0, -3.0), (Color)(255, 255, 255, 255)) +dirLight.target = (Vector3)(1.0, -2.0, -2.0) +dirLight.intensity = 2.0 +dirLight.diffuse = (Color)(100, 255, 100, 255) -local 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 +local pointLight = CreateLight(LIGHT_POINT, (Vector3)(0.0, 4.0, 5.0), (Color)(255, 255, 255, 255)) +pointLight.intensity = 2.0 +pointLight.diffuse = (Color)(100, 100, 255, 255) +pointLight.radius = 3.0 -- Setup orbital camera -SetCameraMode(CAMERA.ORBITAL) -- Set an orbital camera mode +SetCameraMode(CameraMode.ORBITAL) -- Set an orbital camera mode SetCameraPosition(camera.position) -- Set internal camera position to match our camera position SetCameraTarget(camera.target) -- Set internal camera target to match our camera target @@ -71,7 +71,7 @@ SetTargetFPS(60) -- Set our game to run at 60 frames-per-s while not WindowShouldClose() do -- Detect window close button or ESC key -- Update --------------------------------------------------------------------------------------- - UpdateCamera(&camera) -- Update internal camera and our camera + UpdateCamera(camera) -- Update internal camera and our camera --------------------------------------------------------------------------------------- -- Draw @@ -98,7 +98,7 @@ while not WindowShouldClose() do -- Detect window close button or ESC key EndDrawing() --------------------------------------------------------------------------------------- -} +end -- De-Initialization ------------------------------------------------------------------------------------------- diff --git a/examples/text_font_select.lua b/examples/text_font_select.lua index e04f6024..f6cea881 100644 --- a/examples/text_font_select.lua +++ b/examples/text_font_select.lua @@ -87,7 +87,7 @@ while not WindowShouldClose() do -- Detect window close button or ESC btnNextInColor = PURPLE end - if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) then + if (IsMouseButtonDown(MOUSE.LEFT_BUTTON)) then framesCounter = 20 -- Frames button is 'active' btnNextOutColor = MAROON btnNextInColor = RED diff --git a/examples/text_rbmf_fonts.lua b/examples/text_rbmf_fonts.lua index d89e4071..0e0e4142 100644 --- a/examples/text_rbmf_fonts.lua +++ b/examples/text_rbmf_fonts.lua @@ -50,7 +50,7 @@ for i = 1, 8 do positions[i].y = 60 + fonts[i].size + 50*i end -local colors = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD } +local colors = { MAROON, ORANGE, DARKGREEN, DARKBLUE, DARKPURPLE, LIME, GOLD, BLACK } SetTargetFPS(60) -- Set target frames-per-second ------------------------------------------------------------------------------------------- diff --git a/examples/text_writing_anim.lua b/examples/text_writing_anim.lua index 37f1efba..05195dc4 100644 --- a/examples/text_writing_anim.lua +++ b/examples/text_writing_anim.lua @@ -38,7 +38,7 @@ while not WindowShouldClose() do -- Detect window close button or ESC ClearBackground(RAYWHITE) - DrawText(SubText(message, 0, framesCounter/10), 210, 160, 20, MAROON) + DrawText(string.sub(message, 0, framesCounter/10), 210, 160, 20, MAROON) DrawText("PRESS [ENTER] to RESTART!", 240, 280, 20, LIGHTGRAY) diff --git a/examples/textures_particles_trail_blending.lua b/examples/textures_particles_trail_blending.lua index d5ba7841..38036bcf 100644 --- a/examples/textures_particles_trail_blending.lua +++ b/examples/textures_particles_trail_blending.lua @@ -12,15 +12,6 @@ MAX_PARTICLES = 200 -- Particle structure with basic data -struct.Particle { - position, - color, - alpha, - size, - rotation, - active -- NOTE: Use it to activate/deactive particle -} - -- Initialization ------------------------------------------------------------------------------------------- local screenWidth = 800 @@ -33,6 +24,7 @@ local mouseTail = {} -- Initialize particles for i = 1, MAX_PARTICLES do + mouseTail[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.0 @@ -45,7 +37,7 @@ local gravity = 3.0 local smoke = LoadTexture("resources/smoke.png") -local blending = BLEND.ALPHA +local blending = BlendMode.ALPHA SetTargetFPS(60) ------------------------------------------------------------------------------------------- @@ -80,8 +72,8 @@ while not WindowShouldClose() do -- Detect window close button or ESC end if (IsKeyPressed(KEY.SPACE)) then - if (blending == BLEND.ALPHA) then blending = BLEND_ADDITIVE - else blending = BLEND.ALPHA end + if (blending == BlendMode.ALPHA) then blending = BlendMode.ADDITIVE + else blending = BlendMode.ALPHA end end --------------------------------------------------------------------------------------- @@ -107,7 +99,7 @@ while not WindowShouldClose() do -- Detect window close button or ESC DrawText("PRESS SPACE to CHANGE BLENDING MODE", 180, 20, 20, BLACK) - if (blending == BLEND_ALPHA) then DrawText("ALPHA BLENDING", 290, screenHeight - 40, 20, BLACK) + if (blending == BlendMode.ALPHA) then DrawText("ALPHA BLENDING", 290, screenHeight - 40, 20, BLACK) else DrawText("ADDITIVE BLENDING", 280, screenHeight - 40, 20, RAYWHITE) end EndDrawing() |
