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
40 changes: 40 additions & 0 deletions public/usage-examples/input/mouse_movement-1-example-oop.cs
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
32 changes: 32 additions & 0 deletions public/usage-examples/input/mouse_movement-1-example-top-level.cs
Original file line number Diff line number Diff line change
@@ -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();
37 changes: 37 additions & 0 deletions public/usage-examples/input/mouse_movement-1-example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "splashkit.h"
#include <string>

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;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions public/usage-examples/input/mouse_movement-1-example.py
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions public/usage-examples/input/mouse_movement-1-example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tracking Mouse Movement in a Window