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
60 changes: 60 additions & 0 deletions public/usage-examples/input/move_mouse_to_point-1-example-oop.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
@@ -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();
55 changes: 55 additions & 0 deletions public/usage-examples/input/move_mouse_to_point-1-example.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions public/usage-examples/input/move_mouse_to_point-1-example.py
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Mouse Teleporter