diff options
| author | raysan5 <raysan5@gmail.com> | 2013-11-23 13:30:54 +0100 |
|---|---|---|
| committer | raysan5 <raysan5@gmail.com> | 2013-11-23 13:30:54 +0100 |
| commit | ccf26080915d5487dfb2e5fdb79c2bc2893b7454 (patch) | |
| tree | e7a4856dbea9eac3d356533260b37ce812d5f6e1 /examples | |
| parent | 7635e9c79ff2ed581942b61ca6cebac73712ecca (diff) | |
| download | raylib-ccf26080915d5487dfb2e5fdb79c2bc2893b7454.tar.gz raylib-ccf26080915d5487dfb2e5fdb79c2bc2893b7454.zip | |
Replaced tab by 4 spaces and adjust text
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/ex01_basic_window.c | 64 | ||||
| -rw-r--r-- | examples/ex02b_shapes.c | 110 | ||||
| -rw-r--r-- | examples/ex02c_color_palette.c | 152 | ||||
| -rw-r--r-- | examples/ex03a_input_keys.c | 78 | ||||
| -rw-r--r-- | examples/ex03b_input_mouse.c | 90 | ||||
| -rw-r--r-- | examples/ex03c_input_gamepad.c | 98 | ||||
| -rw-r--r-- | examples/ex04a_textures.c | 78 |
7 files changed, 335 insertions, 335 deletions
diff --git a/examples/ex01_basic_window.c b/examples/ex01_basic_window.c index 7b40bbd0..9189b296 100644 --- a/examples/ex01_basic_window.c +++ b/examples/ex01_basic_window.c @@ -1,11 +1,11 @@ /******************************************************************************************* * -* raylib example 01 - Basic Window +* raylib example 01 - Basic Window * -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* This example has been created using raylib 1.0 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * ********************************************************************************************/ @@ -13,38 +13,38 @@ int main() { - int screenWidth = 800; - int screenHeight = 450; - - // Initialization - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "raylib example 01a - basic window"); // Window and context initialization - //---------------------------------------------------------- - + int screenWidth = 800; + int screenHeight = 450; + + // Initialization + //--------------------------------------------------------- + InitWindow(screenWidth, screenHeight, "raylib example 01a - basic window"); + //---------------------------------------------------------- + // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { - // Update - //----------------------------------------------------- - // TODO: Update your variables here - //----------------------------------------------------- - - // Draw - //----------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("Congrats! You created your first window!", 190, 200, 20, 1, LIGHTGRAY); - + // Update + //----------------------------------------------------- + // TODO: Update your variables here + //----------------------------------------------------- + + // Draw + //----------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawText("Congrats! You created your first window!", 190, 200, 20, 1, LIGHTGRAY); + EndDrawing(); - //----------------------------------------------------- + //----------------------------------------------------- } - // De-Initialization - //--------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //---------------------------------------------------------- - + // De-Initialization + //--------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //---------------------------------------------------------- + return 0; }
\ No newline at end of file diff --git a/examples/ex02b_shapes.c b/examples/ex02b_shapes.c index 93a0bccd..5b9ad560 100644 --- a/examples/ex02b_shapes.c +++ b/examples/ex02b_shapes.c @@ -1,11 +1,11 @@ /******************************************************************************************* * -* raylib example 02b - Draw basic shapes 2d (rectangle, circle, line...) +* raylib example 02b - Draw basic shapes 2d (rectangle, circle, line...) * -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* This example has been created using raylib 1.0 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * ********************************************************************************************/ @@ -13,61 +13,61 @@ int main() { - int screenWidth = 800; - int screenHeight = 450; - - // Initialization - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "raylib example 02b - basic shapes drawing"); // Window and context initialization - //---------------------------------------------------------- - + int screenWidth = 800; + int screenHeight = 450; + + // Initialization + //--------------------------------------------------------- + InitWindow(screenWidth, screenHeight, "raylib example 02b - basic shapes drawing"); + //---------------------------------------------------------- + // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { - // Update - //----------------------------------------------------- - // TODO: Update your variables here - //----------------------------------------------------- - - // Draw - //----------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - // TODO: draw some shapes... with names... :P -/* - void DrawPixel(int posX, int posY, Color color); // Draw a pixel - void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version) - void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line - void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (Vector version) - void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle - void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); // Draw a gradient-filled circle - void DrawCircleV(Vector2 center, float radius, Color color); // Draw a color-filled circle (Vector version) - void DrawCircleLines(int centerX, int centerY, float radius, Color color); // Draw circle outline - void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle - void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle - void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2); // Draw a gradient-filled rectangle - void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version) - void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline - void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle - void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline - void DrawPoly(Vector2 *points, int numPoints, Color color); // Draw a closed polygon defined by points - void DrawPolyLine(Vector2 *points, int numPoints, Color color); // Draw polygon lines -*/ - DrawRectangle(screenWidth/4 - 50, screenHeight/2 - 100, 100, 100, GOLD); - DrawCircle(3*screenWidth/4, screenHeight/2 - 50, 50, MAROON); - - DrawText("_____", 320, 280, 50, 1, BLACK); - + // Update + //----------------------------------------------------- + // TODO: Update your variables here + //----------------------------------------------------- + + // Draw + //----------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + // TODO: draw some shapes... with names... :P +/* + void DrawPixel(int posX, int posY, Color color); // Draw a pixel + void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version) + void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line + void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (Vector version) + void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle + void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); // Draw a gradient-filled circle + void DrawCircleV(Vector2 center, float radius, Color color); // Draw a color-filled circle (Vector version) + void DrawCircleLines(int centerX, int centerY, float radius, Color color); // Draw circle outline + void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle + void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle + void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2); // Draw a gradient-filled rectangle + void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version) + void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline + void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle + void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline + void DrawPoly(Vector2 *points, int numPoints, Color color); // Draw a closed polygon defined by points + void DrawPolyLine(Vector2 *points, int numPoints, Color color); // Draw polygon lines +*/ + DrawRectangle(screenWidth/4 - 50, screenHeight/2 - 100, 100, 100, GOLD); + DrawCircle(3*screenWidth/4, screenHeight/2 - 50, 50, MAROON); + + DrawText("_____", 320, 280, 50, 1, BLACK); + EndDrawing(); - //----------------------------------------------------- + //----------------------------------------------------- } - // De-Initialization - //--------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //---------------------------------------------------------- - + // De-Initialization + //--------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //---------------------------------------------------------- + return 0; }
\ No newline at end of file diff --git a/examples/ex02c_color_palette.c b/examples/ex02c_color_palette.c index 3a735295..3e69abe3 100644 --- a/examples/ex02c_color_palette.c +++ b/examples/ex02c_color_palette.c @@ -1,11 +1,11 @@ /******************************************************************************************* * -* raylib example 02c - Draw raylib custom color palette +* raylib example 02c - Draw raylib custom color palette * -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* This example has been created using raylib 1.0 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * ********************************************************************************************/ @@ -13,83 +13,83 @@ int main() { - int screenWidth = 800; - int screenHeight = 450; - - // Initialization - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "raylib example 02c - raylib color palette"); // Window and context initialization - //---------------------------------------------------------- - + int screenWidth = 800; + int screenHeight = 450; + + // Initialization + //--------------------------------------------------------- + InitWindow(screenWidth, screenHeight, "raylib example 02c - raylib color palette"); + //---------------------------------------------------------- + // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { - // Update - //----------------------------------------------------- - // TODO: Update your variables here - //----------------------------------------------------- - - // Draw - //----------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("raylib color palette", 28, 42, 20, 2, BLACK); - - DrawRectangle(26, 80, 100, 100, DARKGRAY); - DrawRectangle(26, 188, 100, 100, GRAY); - DrawRectangle(26, 296, 100, 100, LIGHTGRAY); - DrawRectangle(134, 80, 100, 100, MAROON); - DrawRectangle(134, 188, 100, 100, RED); - DrawRectangle(134, 296, 100, 100, PINK); - DrawRectangle(242, 80, 100, 100, ORANGE); - DrawRectangle(242, 188, 100, 100, GOLD); - DrawRectangle(242, 296, 100, 100, YELLOW); - DrawRectangle(350, 80, 100, 100, DARKGREEN); - DrawRectangle(350, 188, 100, 100, LIME); - DrawRectangle(350, 296, 100, 100, GREEN); - DrawRectangle(458, 80, 100, 100, DARKBLUE); - DrawRectangle(458, 188, 100, 100, BLUE); - DrawRectangle(458, 296, 100, 100, SKYBLUE); - DrawRectangle(566, 80, 100, 100, DARKPURPLE); - DrawRectangle(566, 188, 100, 100, VIOLET); - DrawRectangle(566, 296, 100, 100, PURPLE); - DrawRectangle(674, 80, 100, 100, DARKBROWN); - DrawRectangle(674, 188, 100, 100, BROWN); - DrawRectangle(674, 296, 100, 100, BEIGE); + // Update + //----------------------------------------------------- + // TODO: Update your variables here + //----------------------------------------------------- + + // Draw + //----------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawText("raylib color palette", 28, 42, 20, 2, BLACK); + + DrawRectangle(26, 80, 100, 100, DARKGRAY); + DrawRectangle(26, 188, 100, 100, GRAY); + DrawRectangle(26, 296, 100, 100, LIGHTGRAY); + DrawRectangle(134, 80, 100, 100, MAROON); + DrawRectangle(134, 188, 100, 100, RED); + DrawRectangle(134, 296, 100, 100, PINK); + DrawRectangle(242, 80, 100, 100, ORANGE); + DrawRectangle(242, 188, 100, 100, GOLD); + DrawRectangle(242, 296, 100, 100, YELLOW); + DrawRectangle(350, 80, 100, 100, DARKGREEN); + DrawRectangle(350, 188, 100, 100, LIME); + DrawRectangle(350, 296, 100, 100, GREEN); + DrawRectangle(458, 80, 100, 100, DARKBLUE); + DrawRectangle(458, 188, 100, 100, BLUE); + DrawRectangle(458, 296, 100, 100, SKYBLUE); + DrawRectangle(566, 80, 100, 100, DARKPURPLE); + DrawRectangle(566, 188, 100, 100, VIOLET); + DrawRectangle(566, 296, 100, 100, PURPLE); + DrawRectangle(674, 80, 100, 100, DARKBROWN); + DrawRectangle(674, 188, 100, 100, BROWN); + DrawRectangle(674, 296, 100, 100, BEIGE); - - DrawText("DARKGRAY", 57, 166, 10, 2, BLACK); - DrawText("GRAY", 89, 274, 10, 2, BLACK); - DrawText("LIGHTGRAY", 51, 382, 10, 2, BLACK); - DrawText("MAROON", 180, 166, 10, 2, BLACK); - DrawText("RED", 207, 274, 10, 2, BLACK); - DrawText("PINK", 200, 382, 10, 2, BLACK); - DrawText("ORANGE", 290, 166, 10, 2, BLACK); - DrawText("GOLD", 306, 274, 10, 2, BLACK); - DrawText("YELLOW", 290, 382, 10, 2, BLACK); - DrawText("DARKGREEN", 374, 166, 10, 2, BLACK); - DrawText("LIME", 417, 274, 10, 2, BLACK); - DrawText("GREEN", 407, 382, 10, 2, BLACK); - DrawText("DARKBLUE", 491, 166, 10, 2, BLACK); - DrawText("BLUE", 523, 274, 10, 2, BLACK); - DrawText("SKYBLUE", 499, 382, 10, 2, BLACK); - DrawText("DARKPURPLE", 582, 166, 10, 2, BLACK); - DrawText("VIOLET", 617, 274, 10, 2, BLACK); - DrawText("PURPLE", 615, 382, 10, 2, BLACK); - DrawText("DARKBROWN", 695, 166, 10, 2, BLACK); - DrawText("BROWN", 728, 274, 10, 2, BLACK); - DrawText("BEIGE", 733, 382, 10, 2, BLACK); - + + DrawText("DARKGRAY", 57, 166, 10, 2, BLACK); + DrawText("GRAY", 89, 274, 10, 2, BLACK); + DrawText("LIGHTGRAY", 51, 382, 10, 2, BLACK); + DrawText("MAROON", 180, 166, 10, 2, BLACK); + DrawText("RED", 207, 274, 10, 2, BLACK); + DrawText("PINK", 200, 382, 10, 2, BLACK); + DrawText("ORANGE", 290, 166, 10, 2, BLACK); + DrawText("GOLD", 306, 274, 10, 2, BLACK); + DrawText("YELLOW", 290, 382, 10, 2, BLACK); + DrawText("DARKGREEN", 374, 166, 10, 2, BLACK); + DrawText("LIME", 417, 274, 10, 2, BLACK); + DrawText("GREEN", 407, 382, 10, 2, BLACK); + DrawText("DARKBLUE", 491, 166, 10, 2, BLACK); + DrawText("BLUE", 523, 274, 10, 2, BLACK); + DrawText("SKYBLUE", 499, 382, 10, 2, BLACK); + DrawText("DARKPURPLE", 582, 166, 10, 2, BLACK); + DrawText("VIOLET", 617, 274, 10, 2, BLACK); + DrawText("PURPLE", 615, 382, 10, 2, BLACK); + DrawText("DARKBROWN", 695, 166, 10, 2, BLACK); + DrawText("BROWN", 728, 274, 10, 2, BLACK); + DrawText("BEIGE", 733, 382, 10, 2, BLACK); + EndDrawing(); - //----------------------------------------------------- + //----------------------------------------------------- } - // De-Initialization - //--------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //---------------------------------------------------------- - + // De-Initialization + //--------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //---------------------------------------------------------- + return 0; }
\ No newline at end of file diff --git a/examples/ex03a_input_keys.c b/examples/ex03a_input_keys.c index 85deb2b4..da7d2123 100644 --- a/examples/ex03a_input_keys.c +++ b/examples/ex03a_input_keys.c @@ -1,11 +1,11 @@ /******************************************************************************************* * -* raylib example 03a - Keyboard input +* raylib example 03a - Keyboard input * -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* This example has been created using raylib 1.0 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * ********************************************************************************************/ @@ -13,45 +13,45 @@ int main() { - int screenWidth = 800; - int screenHeight = 450; - - Vector2 ballPosition = { screenWidth/2, screenHeight/2 }; - - // Initialization - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "raylib example 05 - keyboard input"); // Window and context initialization - //---------------------------------------------------------- - + int screenWidth = 800; + int screenHeight = 450; + + Vector2 ballPosition = { screenWidth/2, screenHeight/2 }; + + // Initialization + //--------------------------------------------------------- + InitWindow(screenWidth, screenHeight, "raylib example 05 - keyboard input"); + //---------------------------------------------------------- + // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { - // Update - //----------------------------------------------------- - if (IsKeyPressed(KEY_RIGHT)) ballPosition.x += 0.8; - if (IsKeyPressed(KEY_LEFT)) ballPosition.x -= 0.8; - if (IsKeyPressed(KEY_UP)) ballPosition.y -= 0.8; - if (IsKeyPressed(KEY_DOWN)) ballPosition.y += 0.8; - //----------------------------------------------------- - - // Draw - //----------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("move the ball with arrow keys", 10, 10, 20, 1, DARKGRAY); - - DrawCircleV(ballPosition, 50, MAROON); - + // Update + //----------------------------------------------------- + if (IsKeyPressed(KEY_RIGHT)) ballPosition.x += 0.8; + if (IsKeyPressed(KEY_LEFT)) ballPosition.x -= 0.8; + if (IsKeyPressed(KEY_UP)) ballPosition.y -= 0.8; + if (IsKeyPressed(KEY_DOWN)) ballPosition.y += 0.8; + //----------------------------------------------------- + + // Draw + //----------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawText("move the ball with arrow keys", 10, 10, 20, 1, DARKGRAY); + + DrawCircleV(ballPosition, 50, MAROON); + EndDrawing(); - //----------------------------------------------------- + //----------------------------------------------------- } - // De-Initialization - //--------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //---------------------------------------------------------- - + // De-Initialization + //--------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //---------------------------------------------------------- + return 0; }
\ No newline at end of file diff --git a/examples/ex03b_input_mouse.c b/examples/ex03b_input_mouse.c index 996cd73e..db713fac 100644 --- a/examples/ex03b_input_mouse.c +++ b/examples/ex03b_input_mouse.c @@ -1,11 +1,11 @@ /******************************************************************************************* * -* raylib example 03b - Mouse input +* raylib example 03b - Mouse input * -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* This example has been created using raylib 1.0 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * ********************************************************************************************/ @@ -13,51 +13,51 @@ int main() { - int screenWidth = 800; - int screenHeight = 450; - - Vector2 ballPosition = { -100.0, -100.0 }; - int counter = 0; - int mouseX, mouseY; - - // Initialization - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "raylib example 06 - mouse input"); // Window and context initialization - //---------------------------------------------------------- - + int screenWidth = 800; + int screenHeight = 450; + + Vector2 ballPosition = { -100.0, -100.0 }; + int counter = 0; + int mouseX, mouseY; + + // Initialization + //--------------------------------------------------------- + InitWindow(screenWidth, screenHeight, "raylib example 06 - mouse input"); + //---------------------------------------------------------- + // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { - // Update - //----------------------------------------------------- - if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) - { - mouseX = GetMouseX(); - mouseY = GetMouseY(); - - ballPosition.x = (float)mouseX; - ballPosition.y = (float)mouseY; - } - //----------------------------------------------------- - - // Draw - //----------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawCircleV(ballPosition, 40, GOLD); - - DrawText("mouse click to draw the ball", 10, 10, 20, 1, DARKGRAY); - + // Update + //----------------------------------------------------- + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) + { + mouseX = GetMouseX(); + mouseY = GetMouseY(); + + ballPosition.x = (float)mouseX; + ballPosition.y = (float)mouseY; + } + //----------------------------------------------------- + + // Draw + //----------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawCircleV(ballPosition, 40, GOLD); + + DrawText("mouse click to draw the ball", 10, 10, 20, 1, DARKGRAY); + EndDrawing(); - //----------------------------------------------------- + //----------------------------------------------------- } - // De-Initialization - //--------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //---------------------------------------------------------- - + // De-Initialization + //--------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //---------------------------------------------------------- + return 0; }
\ No newline at end of file diff --git a/examples/ex03c_input_gamepad.c b/examples/ex03c_input_gamepad.c index 377ac7f5..b770b0ca 100644 --- a/examples/ex03c_input_gamepad.c +++ b/examples/ex03c_input_gamepad.c @@ -1,11 +1,11 @@ /******************************************************************************************* * -* raylib example 03c - Gamepad input +* raylib example 03c - Gamepad input * -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* This example has been created using raylib 1.0 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * ********************************************************************************************/ @@ -13,55 +13,55 @@ int main() { - int screenWidth = 800; - int screenHeight = 450; - - Vector2 ballPosition = { screenWidth/2, screenHeight/2 }; - Vector2 gamepadMove = { 0, 0 }; - - // Initialization - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "raylib example 01 - gamepad input"); // Window and context initialization - //---------------------------------------------------------- - + int screenWidth = 800; + int screenHeight = 450; + + Vector2 ballPosition = { screenWidth/2, screenHeight/2 }; + Vector2 gamepadMove = { 0, 0 }; + + // Initialization + //--------------------------------------------------------- + InitWindow(screenWidth, screenHeight, "raylib example 01 - gamepad input"); + //---------------------------------------------------------- + // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { - // Update - //----------------------------------------------------- - if (IsGamepadAvailable(GAMEPAD_PLAYER1)) - { - gamepadMove = GetGamepadMovement(GAMEPAD_PLAYER1); - - ballPosition.x += gamepadMove.x; - ballPosition.y -= gamepadMove.y; - - if (IsGamepadButtonPressed(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_A)) - { - ballPosition.x = screenWidth/2; - ballPosition.y = screenHeight/2; - } - } - //----------------------------------------------------- - - // Draw - //----------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawText("move the ball with gamepad", 10, 10, 20, 1, DARKGRAY); - - DrawCircleV(ballPosition, 50, MAROON); - + // Update + //----------------------------------------------------- + if (IsGamepadAvailable(GAMEPAD_PLAYER1)) + { + gamepadMove = GetGamepadMovement(GAMEPAD_PLAYER1); + + ballPosition.x += gamepadMove.x; + ballPosition.y -= gamepadMove.y; + + if (IsGamepadButtonPressed(GAMEPAD_PLAYER1, GAMEPAD_BUTTON_A)) + { + ballPosition.x = screenWidth/2; + ballPosition.y = screenHeight/2; + } + } + //----------------------------------------------------- + + // Draw + //----------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawText("move the ball with gamepad", 10, 10, 20, 1, DARKGRAY); + + DrawCircleV(ballPosition, 50, MAROON); + EndDrawing(); - //----------------------------------------------------- + //----------------------------------------------------- } - // De-Initialization - //--------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context - //---------------------------------------------------------- - + // De-Initialization + //--------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //---------------------------------------------------------- + return 0; }
\ No newline at end of file diff --git a/examples/ex04a_textures.c b/examples/ex04a_textures.c index 5c2bf650..e0457c0a 100644 --- a/examples/ex04a_textures.c +++ b/examples/ex04a_textures.c @@ -1,11 +1,11 @@ /******************************************************************************************* * -* raylib example 04a - Texture loading and drawing +* raylib example 04a - Texture loading and drawing * -* This example has been created using raylib 1.0 (www.raylib.com) -* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) +* This example has been created using raylib 1.0 (www.raylib.com) +* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) * -* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) +* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com) * ********************************************************************************************/ @@ -13,45 +13,45 @@ int main() { - int screenWidth = 800; - int screenHeight = 450; - - // Initialization - //--------------------------------------------------------- - InitWindow(screenWidth, screenHeight, "raylib example 04a - texture loading and drawing"); // Window and context initialization - - // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading - //---------------------------------------------------------- - + int screenWidth = 800; + int screenHeight = 450; + + // Initialization + //--------------------------------------------------------- + InitWindow(screenWidth, screenHeight, "raylib example 04a - texture loading and drawing"); + + // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) + Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading + //---------------------------------------------------------- + // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { - // Update - //----------------------------------------------------- - // TODO: Update your variables here - //----------------------------------------------------- - - // Draw - //----------------------------------------------------- - BeginDrawing(); - - ClearBackground(RAYWHITE); - - DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE); - - DrawText("this IS a texture!", 360, 370, 10, 1, GRAY); - + // Update + //----------------------------------------------------- + // TODO: Update your variables here + //----------------------------------------------------- + + // Draw + //----------------------------------------------------- + BeginDrawing(); + + ClearBackground(RAYWHITE); + + DrawTexture(texture, screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2, WHITE); + + DrawText("this IS a texture!", 360, 370, 10, 1, GRAY); + EndDrawing(); - //----------------------------------------------------- + //----------------------------------------------------- } - // De-Initialization - //--------------------------------------------------------- - UnloadTexture(texture); // Texture unloading - - CloseWindow(); // Close window and OpenGL context - //---------------------------------------------------------- - + // De-Initialization + //--------------------------------------------------------- + UnloadTexture(texture); // Texture unloading + + CloseWindow(); // Close window and OpenGL context + //---------------------------------------------------------- + return 0; }
\ No newline at end of file |
