Fixes for some Lua bugs
This commit is contained in:
parent
d5f5f0a930
commit
4960e6b6d7
20 changed files with 413 additions and 103 deletions
|
@ -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
|
||||
}
|
|
@ -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
|
||||
---------------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
-------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -90,7 +90,7 @@ while not WindowShouldClose() do -- Detect window close button or ESC key
|
|||
|
||||
EndDrawing()
|
||||
---------------------------------------------------------------------------------------
|
||||
}
|
||||
end
|
||||
|
||||
-- De-Initialization
|
||||
-------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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
|
||||
-------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
-------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue