Browse Source

Create Beginners_-_if_One_Line.c

Rudy Boudewijn van Etten 5 years ago
parent
commit
3b15c25fb1
1 changed files with 52 additions and 0 deletions
  1. 52 0
      Beginners_-_if_One_Line.c

+ 52 - 0
Beginners_-_if_One_Line.c

@@ -0,0 +1,52 @@
+
+#include "raylib.h"
+
+
+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);
+            
+            // This is one way to use the 'if' command. If there is only 1 line after the if 
+            // Notice that the else is on the next line. 
+            if(GetMouseX()<screenWidth/2)DrawText("Mouse on left side of screen.",0,0,20,GRAY);
+            else DrawText("Mouse on right side of screen.",0,0,20,GRAY);
+                
+            
+
+
+
+        EndDrawing();
+        //----------------------------------------------------------------------------------
+    }
+
+    // De-Initialization
+    //--------------------------------------------------------------------------------------
+    CloseWindow();        // Close window and OpenGL context
+    //--------------------------------------------------------------------------------------
+
+    return 0;
+
+
+}