diff --git a/public/usage-examples/input/mouse_clicked-1-example-oop.cs b/public/usage-examples/input/mouse_clicked-1-example-oop.cs new file mode 100644 index 000000000..066f5a991 --- /dev/null +++ b/public/usage-examples/input/mouse_clicked-1-example-oop.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; +using SplashKitSDK; + +namespace MouseClickedExample +{ + public class Program + { + public static void Main() + { + SplashKit.OpenWindow("Click to Place Markers", 800, 600); + + List clicks = new(); + + while (!SplashKit.QuitRequested()) + { + SplashKit.ProcessEvents(); + + // Add a marker where the left mouse button was clicked + if (SplashKit.MouseClicked(MouseButton.LeftButton)) + { + clicks.Add(SplashKit.MousePosition()); + } + + SplashKit.ClearScreen(); + + foreach (Point2D pt in clicks) + { + SplashKit.FillCircle(Color.Red, pt.X, pt.Y, 8); + } + + SplashKit.RefreshScreen(60); + } + + SplashKit.CloseAllWindows(); + } + } +} \ No newline at end of file diff --git a/public/usage-examples/input/mouse_clicked-1-example-top-level.cs b/public/usage-examples/input/mouse_clicked-1-example-top-level.cs new file mode 100644 index 000000000..f08daa800 --- /dev/null +++ b/public/usage-examples/input/mouse_clicked-1-example-top-level.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using SplashKitSDK; +using static SplashKitSDK.SplashKit; + +OpenWindow("Click to Place Markers", 800, 600); + +List clicks = new(); + +while (!QuitRequested()) +{ + ProcessEvents(); + + // Add a marker where the left mouse button was clicked + if (MouseClicked(MouseButton.LeftButton)) + { + clicks.Add(MousePosition()); + } + + ClearScreen(ColorWhite()); + + foreach (Point2D pt in clicks) + { + FillCircle(ColorRed(), pt.X, pt.Y, 8); + } + + RefreshScreen(60); +} + +CloseAllWindows(); \ No newline at end of file diff --git a/public/usage-examples/input/mouse_clicked-1-example.cpp b/public/usage-examples/input/mouse_clicked-1-example.cpp new file mode 100644 index 000000000..a6d78f1aa --- /dev/null +++ b/public/usage-examples/input/mouse_clicked-1-example.cpp @@ -0,0 +1,32 @@ +#include "splashkit.h" +#include + +int main() +{ + open_window("Click to Place Markers", 800, 600); + + std::vector clicks; + + while (!quit_requested()) + { + process_events(); + + // Add a marker where the left mouse button was clicked + if (mouse_clicked(LEFT_BUTTON)) + { + clicks.push_back(mouse_position()); + } + + clear_screen(color_white()); + + for (const point_2d &pt : clicks) + { + fill_circle(COLOR_RED, pt.x, pt.y, 8); + } + + refresh_screen(60); + } + + close_all_windows(); + return 0; +} \ No newline at end of file diff --git a/public/usage-examples/input/mouse_clicked-1-example.png b/public/usage-examples/input/mouse_clicked-1-example.png new file mode 100644 index 000000000..c56ef1fa9 Binary files /dev/null and b/public/usage-examples/input/mouse_clicked-1-example.png differ diff --git a/public/usage-examples/input/mouse_clicked-1-example.py b/public/usage-examples/input/mouse_clicked-1-example.py new file mode 100644 index 000000000..ef448e1f2 --- /dev/null +++ b/public/usage-examples/input/mouse_clicked-1-example.py @@ -0,0 +1,21 @@ +from splashkit import * + +open_window("Click to Place Markers", 800, 600) + +clicks = [] + +while not quit_requested(): + process_events() + + # Add a marker where the left mouse button was clicked + if mouse_clicked(MouseButton.left_button): + clicks.append(mouse_position()) + + clear_screen(color_white()) + + for pt in clicks: + fill_circle(color_red(), pt.x, pt.y, 8) + + refresh_screen() + +close_all_windows() \ No newline at end of file diff --git a/public/usage-examples/input/mouse_clicked-1-example.txt b/public/usage-examples/input/mouse_clicked-1-example.txt new file mode 100644 index 000000000..c8da88383 --- /dev/null +++ b/public/usage-examples/input/mouse_clicked-1-example.txt @@ -0,0 +1,3 @@ +Click to Place Markers + +Left click anywhere in the window to place a red marker at the clicked position. \ No newline at end of file