Browse Source

Create Beginners_-_voidFunctions.c

Rudy Boudewijn van Etten 5 years ago
parent
commit
94b7403f51
1 changed files with 57 additions and 0 deletions
  1. 57 0
      Beginners_-_voidFunctions.c

+ 57 - 0
Beginners_-_voidFunctions.c

@@ -0,0 +1,57 @@
+
+#include "raylib.h"
+
+// Let the compiler know we are using a function outside the main function.
+void drawmessage(int x,int y);
+
+
+int main(void)
+{
+    // Initialization
+    //--------------------------------------------------------------------------------------
+    const int screenWidth = 800;
+    const int screenHeight = 450;
+
+    InitWindow(screenWidth, screenHeight, "raylib example.");
+
+ 
+    SetTargetFPS(60);               // Set our game to run at 60 frames-per-second
+    //--------------------------------------------------------------------------------------
+
+    // Main game loop
+    while (!WindowShouldClose())    // Detect window close button or ESC key
+    {
+        // Update
+        //----------------------------------------------------------------------------------
+        
+        //----------------------------------------------------------------------------------
+        // Draw
+        //----------------------------------------------------------------------------------
+        BeginDrawing();
+
+            ClearBackground(RAYWHITE);
+                
+            // Here we use the function that is outside our main function.    
+            drawmessage(100,100);
+            
+
+        EndDrawing();
+        //----------------------------------------------------------------------------------
+    }
+
+    // De-Initialization
+    //--------------------------------------------------------------------------------------
+    CloseWindow();        // Close window and OpenGL context
+    //--------------------------------------------------------------------------------------
+
+    return 0;
+
+
+}
+
+// This is our function
+// It is outside the main function.
+// void means it returns nothing.
+void drawmessage(int x,int y){
+    DrawText("Hello World.",x,y,20,BLACK);
+}