diff --git a/public/usage-examples/input/mouse_movement-1-example-oop.cs b/public/usage-examples/input/mouse_movement-1-example-oop.cs new file mode 100644 index 000000000..5ee4961c5 --- /dev/null +++ b/public/usage-examples/input/mouse_movement-1-example-oop.cs @@ -0,0 +1,40 @@ +using SplashKitSDK; + +namespace MouseMovementExample +{ + public static class Program + { + public static void Main() + { + SplashKit.OpenWindow("Mouse Movement Display", 800, 600); + + double circleX = 400; + double circleY = 300; + + while (!SplashKit.QuitRequested()) + { + SplashKit.ProcessEvents(); + + Vector2D movement = SplashKit.MouseMovement(); + + circleX += movement.X; + circleY += movement.Y; + + SplashKit.ClearScreen(Color.White); + + SplashKit.DrawText("Move the mouse to see mouse_movement() values.", Color.Black, 20, 20); + SplashKit.DrawText("Movement X: " + movement.X, Color.Black, 20, 60); + SplashKit.DrawText("Movement Y: " + movement.Y, Color.Black, 20, 100); + + SplashKit.FillCircle(Color.Blue, circleX, circleY, 15); + SplashKit.DrawCircle(Color.Black, circleX, circleY, 15); + + SplashKit.DrawLine(Color.Red, circleX, circleY, circleX + movement.X * 5, circleY + movement.Y * 5); + + SplashKit.RefreshScreen(60); + } + + SplashKit.CloseAllWindows(); + } + } +} \ No newline at end of file diff --git a/public/usage-examples/input/mouse_movement-1-example-top-level.cs b/public/usage-examples/input/mouse_movement-1-example-top-level.cs new file mode 100644 index 000000000..d43df14e6 --- /dev/null +++ b/public/usage-examples/input/mouse_movement-1-example-top-level.cs @@ -0,0 +1,32 @@ +using SplashKitSDK; +using static SplashKitSDK.SplashKit; + +OpenWindow("Mouse Movement Display", 800, 600); + +double circleX = 400; +double circleY = 300; + +while (!QuitRequested()) +{ + ProcessEvents(); + + Vector2D movement = MouseMovement(); + + circleX += movement.X; + circleY += movement.Y; + + ClearScreen(ColorWhite()); + + DrawText("Move the mouse to see mouse_movement() values.", ColorBlack(), 20, 20); + DrawText("Movement X: " + movement.X, ColorBlack(), 20, 60); + DrawText("Movement Y: " + movement.Y, ColorBlack(), 20, 100); + + FillCircle(ColorBlue(), circleX, circleY, 15); + DrawCircle(ColorBlack(), circleX, circleY, 15); + + DrawLine(ColorRed(), circleX, circleY, circleX + movement.X * 5, circleY + movement.Y * 5); + + RefreshScreen(60); +} + +CloseAllWindows(); \ No newline at end of file diff --git a/public/usage-examples/input/mouse_movement-1-example.cpp b/public/usage-examples/input/mouse_movement-1-example.cpp new file mode 100644 index 000000000..ad83a2d3b --- /dev/null +++ b/public/usage-examples/input/mouse_movement-1-example.cpp @@ -0,0 +1,37 @@ +#include "splashkit.h" +#include + +int main() +{ + open_window("Mouse Movement Display", 800, 600); + + double circle_x = 400; + double circle_y = 300; + + while (!quit_requested()) + { + process_events(); + + vector_2d movement = mouse_movement(); + + circle_x += movement.x; + circle_y += movement.y; + + clear_screen(COLOR_WHITE); + + draw_text("Move the mouse to see mouse_movement() values.", COLOR_BLACK, 20, 20); + draw_text(std::string("Movement X: ") + std::to_string(movement.x), COLOR_BLACK, 20, 60); + draw_text(std::string("Movement Y: ") + std::to_string(movement.y), COLOR_BLACK, 20, 100); + + fill_circle(COLOR_BLUE, circle_x, circle_y, 15); + draw_circle(COLOR_BLACK, circle_x, circle_y, 15); + + draw_line(COLOR_RED, circle_x, circle_y, circle_x + movement.x * 5, circle_y + movement.y * 5); + + refresh_screen(60); + } + + close_all_windows(); + + return 0; +} \ No newline at end of file diff --git a/public/usage-examples/input/mouse_movement-1-example.png b/public/usage-examples/input/mouse_movement-1-example.png new file mode 100644 index 000000000..019f41512 Binary files /dev/null and b/public/usage-examples/input/mouse_movement-1-example.png differ diff --git a/public/usage-examples/input/mouse_movement-1-example.py b/public/usage-examples/input/mouse_movement-1-example.py new file mode 100644 index 000000000..7bf667fff --- /dev/null +++ b/public/usage-examples/input/mouse_movement-1-example.py @@ -0,0 +1,29 @@ +from splashkit import * + +open_window("Mouse Movement Display", 800, 600) + +circle_x = 400 +circle_y = 300 + +while not quit_requested(): + process_events() + + movement = mouse_movement() + + circle_x += movement.x + circle_y += movement.y + + clear_screen(color_white()) + + draw_text_no_font_no_size("Move the mouse to see mouse_movement() values.", color_black(), 20, 20) + draw_text_no_font_no_size("Movement X: " + str(movement.x), color_black(), 20, 60) + draw_text_no_font_no_size("Movement Y: " + str(movement.y), color_black(), 20, 100) + + fill_circle(color_blue(), circle_x, circle_y, 15) + draw_circle(color_black(), circle_x, circle_y, 15) + + draw_line(color_red(), circle_x, circle_y, circle_x + movement.x * 5, circle_y + movement.y * 5) + + refresh_screen_with_target_fps(60) + +close_all_windows() \ No newline at end of file diff --git a/public/usage-examples/input/mouse_movement-1-example.txt b/public/usage-examples/input/mouse_movement-1-example.txt new file mode 100644 index 000000000..a40e100e6 --- /dev/null +++ b/public/usage-examples/input/mouse_movement-1-example.txt @@ -0,0 +1 @@ +Tracking Mouse Movement in a Window \ No newline at end of file