aboutsummaryrefslogtreecommitdiff
path: root/examples/audio_module_playing.lua
diff options
context:
space:
mode:
authorghassanpl <kronikarz@gmail.com>2016-08-06 16:58:48 +0200
committerghassanpl <kronikarz@gmail.com>2016-08-06 16:58:48 +0200
commit4960e6b6d7b4cba6125cfb8bb2fef043db8e5ba5 (patch)
tree88dfb074579589a5ea6eba92462bb44863d18798 /examples/audio_module_playing.lua
parentd5f5f0a9302435945b730e5ec001bda39741f3c7 (diff)
downloadraylib-4960e6b6d7b4cba6125cfb8bb2fef043db8e5ba5.tar.gz
raylib-4960e6b6d7b4cba6125cfb8bb2fef043db8e5ba5.zip
Fixes for some Lua bugs
Diffstat (limited to 'examples/audio_module_playing.lua')
-rw-r--r--examples/audio_module_playing.lua17
1 files changed, 9 insertions, 8 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