diff --git a/public/usage-examples/input/move_mouse_to_point-1-example-oop.cs b/public/usage-examples/input/move_mouse_to_point-1-example-oop.cs new file mode 100644 index 000000000..c10ba016c --- /dev/null +++ b/public/usage-examples/input/move_mouse_to_point-1-example-oop.cs @@ -0,0 +1,60 @@ +using SplashKitSDK; + +namespace MoveMouse +{ + public class Program + { + public static void Main() + { + SplashKit.OpenWindow("Move Mouse To Point", 800, 600); + + // Define five target points using PointAt to create Point2D values + // These represent the four corners and the center of the window + Point2D topLeft = SplashKit.PointAt(100, 100); + Point2D topRight = SplashKit.PointAt(700, 100); + Point2D bottomLeft = SplashKit.PointAt(100, 500); + Point2D bottomRight = SplashKit.PointAt(700, 500); + Point2D center = SplashKit.PointAt(400, 300); + + while (!SplashKit.QuitRequested()) + { + SplashKit.ProcessEvents(); + + // MoveMouse (C#'s equivalent of move_mouse_to_point) repositions the cursor to the given Point2D location + // Each key press snaps the mouse to the corresponding target point + if (SplashKit.KeyTyped(KeyCode.QKey)) + SplashKit.MoveMouse(topLeft); + if (SplashKit.KeyTyped(KeyCode.EKey)) + SplashKit.MoveMouse(topRight); + if (SplashKit.KeyTyped(KeyCode.AKey)) + SplashKit.MoveMouse(bottomLeft); + if (SplashKit.KeyTyped(KeyCode.DKey)) + SplashKit.MoveMouse(bottomRight); + if (SplashKit.KeyTyped(KeyCode.SpaceKey)) + SplashKit.MoveMouse(center); + + SplashKit.ClearScreen(Color.White); + + // Draw a coloured circle at each target point so the user can see where the mouse will snap + SplashKit.FillCircle(Color.Red, topLeft.X, topLeft.Y, 12); + SplashKit.FillCircle(Color.Blue, topRight.X, topRight.Y, 12); + SplashKit.FillCircle(Color.Green, bottomLeft.X, bottomLeft.Y, 12); + SplashKit.FillCircle(Color.Orange, bottomRight.X, bottomRight.Y, 12); + SplashKit.FillCircle(Color.Purple, center.X, center.Y, 12); + + // Label each target with its corresponding key + SplashKit.DrawText("[Q]", Color.Red, "Arial", 16, topLeft.X - 12, topLeft.Y + 18); + SplashKit.DrawText("[E]", Color.Blue, "Arial", 16, topRight.X - 12, topRight.Y + 18); + SplashKit.DrawText("[A]", Color.Green, "Arial", 16, bottomLeft.X - 12, bottomLeft.Y + 18); + SplashKit.DrawText("[D]", Color.Orange, "Arial", 16, bottomRight.X - 12, bottomRight.Y + 18); + SplashKit.DrawText("[SPACE]", Color.Purple, "Arial", 16, center.X - 28, center.Y + 18); + + SplashKit.DrawText("Press Q/E/A/D/SPACE to move the mouse to a target point", Color.Black, "Arial", 18, 145, 260); + + SplashKit.RefreshScreen(60); + } + + SplashKit.CloseAllWindows(); + } + } +} diff --git a/public/usage-examples/input/move_mouse_to_point-1-example-top-level.cs b/public/usage-examples/input/move_mouse_to_point-1-example-top-level.cs new file mode 100644 index 000000000..384803f07 --- /dev/null +++ b/public/usage-examples/input/move_mouse_to_point-1-example-top-level.cs @@ -0,0 +1,54 @@ +// using static allows calling SplashKit methods directly (e.g. MoveMouse, KeyTyped) +// using SplashKitSDK is required for Point2D and KeyCode types +using static SplashKitSDK.SplashKit; +using SplashKitSDK; + +// Define five target points using PointAt to create Point2D values +// These represent the four corners and the center of the window +Point2D topLeft = PointAt(100, 100); +Point2D topRight = PointAt(700, 100); +Point2D bottomLeft = PointAt(100, 500); +Point2D bottomRight = PointAt(700, 500); +Point2D center = PointAt(400, 300); + +OpenWindow("Move Mouse To Point", 800, 600); + +while (!QuitRequested()) +{ + ProcessEvents(); + + // MoveMouse (C#'s equivalent of move_mouse_to_point) repositions the cursor to the given Point2D location + // Each key press snaps the mouse to the corresponding target point + if (KeyTyped(KeyCode.QKey)) + MoveMouse(topLeft); + if (KeyTyped(KeyCode.EKey)) + MoveMouse(topRight); + if (KeyTyped(KeyCode.AKey)) + MoveMouse(bottomLeft); + if (KeyTyped(KeyCode.DKey)) + MoveMouse(bottomRight); + if (KeyTyped(KeyCode.SpaceKey)) + MoveMouse(center); + + ClearScreen(ColorWhite()); + + // Draw a coloured circle at each target point so the user can see where the mouse will snap + FillCircle(ColorRed(), topLeft.X, topLeft.Y, 12); + FillCircle(ColorBlue(), topRight.X, topRight.Y, 12); + FillCircle(ColorGreen(), bottomLeft.X, bottomLeft.Y, 12); + FillCircle(ColorOrange(), bottomRight.X, bottomRight.Y, 12); + FillCircle(ColorPurple(), center.X, center.Y, 12); + + // Label each target with its corresponding key + DrawText("[Q]", ColorRed(), "Arial", 16, topLeft.X - 12, topLeft.Y + 18); + DrawText("[E]", ColorBlue(), "Arial", 16, topRight.X - 12, topRight.Y + 18); + DrawText("[A]", ColorGreen(), "Arial", 16, bottomLeft.X - 12, bottomLeft.Y + 18); + DrawText("[D]", ColorOrange(), "Arial", 16, bottomRight.X - 12, bottomRight.Y + 18); + DrawText("[SPACE]", ColorPurple(), "Arial", 16, center.X - 28, center.Y + 18); + + DrawText("Press Q/E/A/D/SPACE to move the mouse to a target point", ColorBlack(), "Arial", 18, 145, 260); + + RefreshScreen(60); +} + +CloseAllWindows(); diff --git a/public/usage-examples/input/move_mouse_to_point-1-example.cpp b/public/usage-examples/input/move_mouse_to_point-1-example.cpp new file mode 100644 index 000000000..355cd2f96 --- /dev/null +++ b/public/usage-examples/input/move_mouse_to_point-1-example.cpp @@ -0,0 +1,55 @@ +#include "splashkit.h" + +int main() +{ + open_window("Move Mouse To Point", 800, 600); + + // Define five target points using point_at to create point_2d values + // These represent the four corners and the center of the window + point_2d top_left = point_at(100, 100); + point_2d top_right = point_at(700, 100); + point_2d bottom_left = point_at(100, 500); + point_2d bottom_right = point_at(700, 500); + point_2d center = point_at(400, 300); + + while (!quit_requested()) + { + process_events(); + + // move_mouse_to_point (called as move_mouse in C++) repositions the cursor to the given point_2d location + // Each key press snaps the mouse to the corresponding target point + if (key_typed(Q_KEY)) + move_mouse(top_left); + if (key_typed(E_KEY)) + move_mouse(top_right); + if (key_typed(A_KEY)) + move_mouse(bottom_left); + if (key_typed(D_KEY)) + move_mouse(bottom_right); + if (key_typed(SPACE_KEY)) + move_mouse(center); + + clear_screen(COLOR_WHITE); + + // Draw a coloured circle at each target point so the user can see where the mouse will snap + fill_circle(COLOR_RED, top_left.x, top_left.y, 12); + fill_circle(COLOR_BLUE, top_right.x, top_right.y, 12); + fill_circle(COLOR_GREEN, bottom_left.x, bottom_left.y, 12); + fill_circle(COLOR_ORANGE, bottom_right.x, bottom_right.y, 12); + fill_circle(COLOR_PURPLE, center.x, center.y, 12); + + // Label each target with its corresponding key + draw_text("[Q]", COLOR_RED, "Arial", 16, top_left.x - 12, top_left.y + 18); + draw_text("[E]", COLOR_BLUE, "Arial", 16, top_right.x - 12, top_right.y + 18); + draw_text("[A]", COLOR_GREEN, "Arial", 16, bottom_left.x - 12, bottom_left.y + 18); + draw_text("[D]", COLOR_ORANGE, "Arial", 16, bottom_right.x - 12, bottom_right.y + 18); + draw_text("[SPACE]", COLOR_PURPLE, "Arial", 16, center.x - 28, center.y + 18); + + draw_text("Press Q/E/A/D/SPACE to move the mouse to a target point", COLOR_BLACK, "Arial", 18, 145, 260); + + refresh_screen(60); + } + + close_all_windows(); + return 0; +} diff --git a/public/usage-examples/input/move_mouse_to_point-1-example.gif b/public/usage-examples/input/move_mouse_to_point-1-example.gif new file mode 100644 index 000000000..2a10bb906 Binary files /dev/null and b/public/usage-examples/input/move_mouse_to_point-1-example.gif differ diff --git a/public/usage-examples/input/move_mouse_to_point-1-example.py b/public/usage-examples/input/move_mouse_to_point-1-example.py new file mode 100644 index 000000000..86b546b50 --- /dev/null +++ b/public/usage-examples/input/move_mouse_to_point-1-example.py @@ -0,0 +1,49 @@ +from splashkit import * + +open_window("Move Mouse To Point", 800, 600) + +# Define five target points using point_at to create point_2d values +# These represent the four corners and the center of the window +top_left = point_at(100, 100) +top_right = point_at(700, 100) +bottom_left = point_at(100, 500) +bottom_right = point_at(700, 500) +center = point_at(400, 300) + +while not quit_requested(): + process_events() + + # move_mouse_to_point repositions the cursor to the given point_2d location + # Each key press snaps the mouse to the corresponding target point + if key_typed(KeyCode.q_key): + move_mouse_to_point(top_left) + if key_typed(KeyCode.e_key): + move_mouse_to_point(top_right) + if key_typed(KeyCode.a_key): + move_mouse_to_point(bottom_left) + if key_typed(KeyCode.d_key): + move_mouse_to_point(bottom_right) + if key_typed(KeyCode.space_key): + move_mouse_to_point(center) + + clear_screen(color_white()) + + # Draw a coloured circle at each target point so the user can see where the mouse will snap + fill_circle(color_red(), top_left.x, top_left.y, 12) + fill_circle(color_blue(), top_right.x, top_right.y, 12) + fill_circle(color_green(), bottom_left.x, bottom_left.y, 12) + fill_circle(color_orange(), bottom_right.x, bottom_right.y, 12) + fill_circle(color_purple(), center.x, center.y, 12) + + # Label each target with its corresponding key + draw_text_font_as_string("[Q]", color_red(), "Arial", 16, top_left.x - 12, top_left.y + 18) + draw_text_font_as_string("[E]", color_blue(), "Arial", 16, top_right.x - 12, top_right.y + 18) + draw_text_font_as_string("[A]", color_green(), "Arial", 16, bottom_left.x - 12, bottom_left.y + 18) + draw_text_font_as_string("[D]", color_orange(), "Arial", 16, bottom_right.x - 12, bottom_right.y + 18) + draw_text_font_as_string("[SPACE]", color_purple(), "Arial", 16, center.x - 28, center.y + 18) + + draw_text_font_as_string("Press Q/E/A/D/SPACE to move the mouse to a target point", color_black(), "Arial", 18, 145, 260) + + refresh_screen_with_target_fps(60) + +close_all_windows() diff --git a/public/usage-examples/input/move_mouse_to_point-1-example.txt b/public/usage-examples/input/move_mouse_to_point-1-example.txt new file mode 100644 index 000000000..5df3d9b16 --- /dev/null +++ b/public/usage-examples/input/move_mouse_to_point-1-example.txt @@ -0,0 +1 @@ +Mouse Teleporter