summaryrefslogtreecommitdiffhomepage
path: root/examples/core/core_loading_thread.c
diff options
context:
space:
mode:
authorRay <[email protected]>2019-05-20 16:36:42 +0200
committerRay <[email protected]>2019-05-20 16:36:42 +0200
commitb525039e0ab8bcaa2fd6bde34c72a6405f88ae49 (patch)
tree08f1c79bfe693643564ed78202c9474b7eb83a79 /examples/core/core_loading_thread.c
parenta43a7980a30a52462956b23f2473e8ef8f38d1fb (diff)
downloadraylib-b525039e0ab8bcaa2fd6bde34c72a6405f88ae49.tar.gz
raylib-b525039e0ab8bcaa2fd6bde34c72a6405f88ae49.zip
Review ALL examples
Diffstat (limited to 'examples/core/core_loading_thread.c')
-rw-r--r--examples/core/core_loading_thread.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/examples/core/core_loading_thread.c b/examples/core/core_loading_thread.c
index 1dacd69f..773ad2ea 100644
--- a/examples/core/core_loading_thread.c
+++ b/examples/core/core_loading_thread.c
@@ -2,7 +2,7 @@
*
* raylib example - loading thread
*
-* NOTE: This example requires linking with pthreads library,
+* NOTE: This example requires linking with pthreads library,
* on MinGW, it can be accomplished passing -static parameter to compiler
*
* This example has been created using raylib 2.5 (www.raylib.com)
@@ -27,21 +27,21 @@ static void *LoadDataThread(void *arg); // Loading data thread function decl
static int dataProgress = 0; // Data progress accumulator
-int main()
+int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
- int screenWidth = 800;
- int screenHeight = 450;
+ const int screenWidth = 800;
+ const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - loading thread");
-
+
pthread_t threadId; // Loading data thread id
enum { STATE_WAITING, STATE_LOADING, STATE_FINISHED } state = STATE_WAITING;
int framesCounter = 0;
- SetTargetFPS(60);
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
@@ -90,25 +90,25 @@ int main()
BeginDrawing();
ClearBackground(RAYWHITE);
-
- switch (state)
+
+ switch (state)
{
case STATE_WAITING: DrawText("PRESS ENTER to START LOADING DATA", 150, 170, 20, DARKGRAY); break;
case STATE_LOADING:
{
DrawRectangle(150, 200, dataProgress, 60, SKYBLUE);
if ((framesCounter/15)%2) DrawText("LOADING DATA...", 240, 210, 40, DARKBLUE);
-
+
} break;
case STATE_FINISHED:
{
DrawRectangle(150, 200, 500, 60, LIME);
DrawText("DATA LOADED!", 250, 210, 40, GREEN);
-
+
} break;
default: break;
}
-
+
DrawRectangleLines(150, 200, 500, 60, DARKGRAY);
EndDrawing();
@@ -130,11 +130,11 @@ static void *LoadDataThread(void *arg)
clock_t prevTime = clock(); // Previous time
// We simulate data loading with a time counter for 5 seconds
- while (timeCounter < 5000)
+ while (timeCounter < 5000)
{
clock_t currentTime = clock() - prevTime;
timeCounter = currentTime*1000/CLOCKS_PER_SEC;
-
+
// We accumulate time over a global variable to be used in
// main thread as a progress bar
dataProgress = timeCounter/10;