Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions public/usage-examples/input/mouse_clicked-1-example-oop.cs
Original file line number Diff line number Diff line change
@@ -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<Point2D> 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();
}
}
}
29 changes: 29 additions & 0 deletions public/usage-examples/input/mouse_clicked-1-example-top-level.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System.Collections.Generic;
using SplashKitSDK;
using static SplashKitSDK.SplashKit;

OpenWindow("Click to Place Markers", 800, 600);

List<Point2D> 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();
32 changes: 32 additions & 0 deletions public/usage-examples/input/mouse_clicked-1-example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "splashkit.h"
#include <vector>

int main()
{
open_window("Click to Place Markers", 800, 600);

std::vector<point_2d> 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;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions public/usage-examples/input/mouse_clicked-1-example.py
Original file line number Diff line number Diff line change
@@ -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()
3 changes: 3 additions & 0 deletions public/usage-examples/input/mouse_clicked-1-example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Click to Place Markers

Left click anywhere in the window to place a red marker at the clicked position.