Skip to content

Add mouse_movement usage example#761

Open
ZGT23 wants to merge 2 commits into
thoth-tech:mainfrom
ZGT23:feature/mouse-movement-usage-example
Open

Add mouse_movement usage example#761
ZGT23 wants to merge 2 commits into
thoth-tech:mainfrom
ZGT23:feature/mouse-movement-usage-example

Conversation

@ZGT23
Copy link
Copy Markdown

@ZGT23 ZGT23 commented May 8, 2026

Description

Splashkit Function: mouse_movement

Overview of example functionality:
This pull request adds a beginner-friendly usage example for the mouse_movement function in the Input category.

The example opens a graphical window and displays the current mouse movement values in real time. It demonstrates how mouse_movement() returns the amount of mouse movement since the last process_events() call.

The program uses the movement vector to move a blue circle around the window. It also displays the X and Y movement values on screen and draws a red line to show the latest movement direction. This helps beginners understand the difference between mouse position and mouse movement.

Files Included

  • C++ code
  • C# code (Top-Level statements)
  • C# code (Object-Oriented Programming)
  • Python code
  • Relevant title for the example (.txt)
  • Screenshot

Usage Example Checks

  • Code uses the SplashKit function above
  • Code does not use non-SplashKit functions
  • Code does not use extra function declarations or extra classes
  • Simple, clear demonstration of the function
  • Tested C++ version locally in MSYS2
  • Tested Python version locally in MSYS2

How Has This Been Tested?

The example was tested locally to confirm that:

  • The window opens correctly
  • mouse_movement() values update when the mouse moves
  • The blue circle reacts to the mouse movement vector
  • The red line shows the latest movement direction
  • C++ version runs correctly in MSYS2
  • Python version runs correctly in MSYS2

I also checked existing pull requests and repository files before starting this task. I did not find an existing standard mouse_movement-1-example file set under public/usage-examples/input/. Although mouse movement is mentioned in older mouse input tutorial material, this PR adds a dedicated standard usage example for the mouse_movement function.

Testing Checklist

  • C++ example tested locally
  • Python example tested locally
  • Tested in latest Chrome
  • Tested in latest Firefox
  • npm run preview

Folders and Files Added/Modified

  • Added:

    • public/usage-examples/input/mouse_movement-1-example.cpp
    • public/usage-examples/input/mouse_movement-1-example-top-level.cs
    • public/usage-examples/input/mouse_movement-1-example-oop.cs
    • public/usage-examples/input/mouse_movement-1-example.py
    • public/usage-examples/input/mouse_movement-1-example.txt
    • public/usage-examples/input/mouse_movement-1-example.png
  • Modified:

    • scripts/json-files/usage-example-references.json

Additional Notes

This example is designed to be simple and beginner-friendly. It focuses on demonstrating how mouse_movement() works after process_events() without adding unnecessary complexity.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 8, 2026

Deploy Preview for splashkit failed.

Name Link
🔨 Latest commit 311d708
🔍 Latest deploy log https://app.netlify.com/projects/splashkit/deploys/69fda642d05b8d0008864265

Copy link
Copy Markdown

@RUNQILIU-123 RUNQILIU-123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

I reviewed the added mouse_movement usage example files across C++, C# top-level, C# OOP, and Python. The examples are clear, beginner-friendly, and demonstrate the target SplashKit function well by showing how mouse movement values update after process_events() and how those values can be used to move an object on screen.

The file naming and structure are consistent with the existing usage example format, and the example focuses on the required function without adding unnecessary complexity. Overall, this is a suitable usage example for the Input category.

Good work.

Copy link
Copy Markdown

@himanshigaba22 himanshigaba22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice example - it’s clear, simple, and easy to follow. It demonstrates mouse_movement() really well.

Just one small thing - in the Python version, draw_text_no_font_no_size() is used instead of draw_text(). Just wanted to check if that was intentional, since most examples use draw_text().

Otherwise, everything looks good 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants