Cleanup bunnymark example.

This commit is contained in:
TSnake41 2020-06-26 13:28:53 +02:00
parent e055b96025
commit 6457550b5a

View File

@ -1,14 +1,4 @@
-------------------------------------------------------------------------------------------- local MAX_BUNNIES = 100000
--
-- raylib [textures] example - Bunnymark
--
-- This example has been created using raylib 1.6 (www.raylib.com)
-- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
--
-- Copyright (c) 2014-2019 Ramon Santamaria (@raysan5)
--
--------------------------------------------------------------------------------------------
local MAX_BUNNIES = 100000 -- 100K bunnies limit
-- This is the maximum amount of elements (quads) per batch -- This is the maximum amount of elements (quads) per batch
-- NOTE: This value is defined in [rlgl] module and can be changed there -- NOTE: This value is defined in [rlgl] module and can be changed there
@ -41,7 +31,6 @@ function Bunny:update(texture)
end end
-- Initialization -- Initialization
----------------------------------------------------------------------------------------
local screenWidth = 800 local screenWidth = 800
local screenHeight = 450 local screenHeight = 450
@ -52,12 +41,10 @@ rl.InitWindow(screenWidth, screenHeight, "raylib [textures] example - bunnymark"
local texBunny = rl.LoadTexture("resources/wabbit_alpha.png") local texBunny = rl.LoadTexture("resources/wabbit_alpha.png")
local bunnies = {} local bunnies = {}
----------------------------------------------------------------------------------------
-- Main game loop -- Main game loop
while not rl.WindowShouldClose() do -- Detect window close button or ESC key while not rl.WindowShouldClose() do -- Detect window close button or ESC key
-- Update -- Update
------------------------------------------------------------------------------------
if rl.IsMouseButtonDown(rl.MOUSE_LEFT_BUTTON) then if rl.IsMouseButtonDown(rl.MOUSE_LEFT_BUTTON) then
-- Create more bunnies -- Create more bunnies
for i = 1, 100 do for i = 1, 100 do
@ -70,13 +57,11 @@ while not rl.WindowShouldClose() do -- Detect window close button or ESC key
end end
-- Update bunnies -- Update bunnies
for i = 1, #bunnies do for i=1,#bunnies do
bunnies[i]:update(texBunny) bunnies[i]:update(texBunny)
end end
------------------------------------------------------------------------------------
-- Draw -- Draw
------------------------------------------------------------------------------------
rl.BeginDrawing() rl.BeginDrawing()
rl.ClearBackground(rl.RAYWHITE) rl.ClearBackground(rl.RAYWHITE)
@ -98,13 +83,8 @@ while not rl.WindowShouldClose() do -- Detect window close button or ESC key
rl.DrawFPS(10, 10) rl.DrawFPS(10, 10)
rl.EndDrawing() rl.EndDrawing()
------------------------------------------------------------------------------------
end end
-- De-Initialization -- De-Initialization
---------------------------------------------------------------------------------------- rl.UnloadTexture(texBunny)
rl.CloseWindow()
rl.UnloadTexture(texBunny) -- Unload bunny texture
rl.CloseWindow() -- Close window and OpenGL context
----------------------------------------------------------------------------------------