aboutsummaryrefslogtreecommitdiff
path: root/examples/core_input_mouse.c
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2014-09-21 14:07:20 +0200
committerRay <raysan5@gmail.com>2014-09-21 14:07:20 +0200
commit42b1cb1aaa9f673b97b12a7209fe3518d166ec34 (patch)
tree1cc6063e4fa8d95d7865cadec1f35bc7a3e80d9a /examples/core_input_mouse.c
parent1989b9fcd994bcdfb3ade460d6f3804de8734db0 (diff)
downloadraylib-42b1cb1aaa9f673b97b12a7209fe3518d166ec34.tar.gz
raylib-42b1cb1aaa9f673b97b12a7209fe3518d166ec34.zip
Rename ex03b_input_mouse.c to core_input_mouse.c
Diffstat (limited to 'examples/core_input_mouse.c')
-rw-r--r--examples/core_input_mouse.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/examples/core_input_mouse.c b/examples/core_input_mouse.c
new file mode 100644
index 00000000..71aba744
--- /dev/null
+++ b/examples/core_input_mouse.c
@@ -0,0 +1,62 @@
+/*******************************************************************************************
+*
+* 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)
+*
+* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+int main()
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ int screenWidth = 800;
+ int screenHeight = 450;
+
+ Vector2 ballPosition = { -100.0, -100.0 };
+ int mouseX, mouseY;
+
+ InitWindow(screenWidth, screenHeight, "raylib example 06 - mouse input");
+ //---------------------------------------------------------------------------------------
+
+ // Main game loop
+ 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, DARKGRAY);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+}