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
14 changes: 14 additions & 0 deletions public/usage-examples/CONTRIBUTING.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ To contribute a function usage example, you need to create the following files:
- **Code files** with the example code. This must be a complete code example, not just a snippet of code.
- ***Zip file*** (*only if your code requires resource files*) containing the "Resources" folder created with the `skm resources` command, with any resources needed for your example code to run. (More info about adding this at the end.)

## Quick checklist before you open a PR

- Files are placed in: `/public/usage-examples/<category folder>/`
- File naming follows: `<unique_global_name>-<number>-example.<ext>`
- Example: `key_down-1-example.cpp`
- Each example includes:
- `.txt` (title/description, and optional Resources link callout)
- `.cpp`
- `-oop.cs`
- `-top-level.cs`
- `.py`
- output file: `.png` (or `.gif` if interactive, or `.webm` if audio)
- If the example needs assets, include a `*-resources.zip` containing a `Resources/` folder (created using `skm resources`).

## File Location

Place the following files into the folder with the **unique global name** located in `/public/usage-examples/<category folder of the function>`:
Expand Down
15 changes: 15 additions & 0 deletions public/usage-examples/graphics/fill_circle-01-example-oop.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using SplashKitSDK;

public static class Program {
public static void Main() {
new Window("Drawing Example", 800, 600);
while (!SplashKit.QuitRequested()) {
SplashKit.ProcessEvents();
SplashKit.ClearScreen(Color.White);
SplashKit.FillCircle(Color.Blue, 400, 300, 50);
SplashKit.FillRectangle(Color.Red, 100, 100, 150, 80);
SplashKit.DrawLine(Color.Green, 50, 50, 750, 550);
SplashKit.RefreshScreen();
}
}
}
11 changes: 11 additions & 0 deletions public/usage-examples/graphics/fill_circle-01-example-top-level.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using SplashKitSDK;

new Window("Drawing Example", 800, 600);
while (!SplashKit.QuitRequested()) {
SplashKit.ProcessEvents();
SplashKit.ClearScreen(Color.White);
SplashKit.FillCircle(Color.Blue, 400, 300, 50);
SplashKit.FillRectangle(Color.Red, 100, 100, 150, 80);
SplashKit.DrawLine(Color.Green, 50, 50, 750, 550);
SplashKit.RefreshScreen();
}
14 changes: 14 additions & 0 deletions public/usage-examples/graphics/fill_circle-01-example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "splashkit.h"

int main() {
open_window("Drawing Example", 800, 600);
while (!quit_requested()) {
process_events();
clear_screen(COLOR_WHITE);
fill_circle(COLOR_BLUE, 400, 300, 50);
fill_rectangle(COLOR_RED, 100, 100, 150, 80);
draw_line(COLOR_GREEN, 50, 50, 750, 550);
refresh_screen();
}
return 0;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions public/usage-examples/graphics/fill_circle-01-example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from splashkit import *

open_window("Drawing Example", 800, 600)
while not quit_requested():
process_events()
clear_screen(color_white())
fill_circle(color_blue(), 400, 300, 50)
fill_rectangle(color_red(), 100, 100, 150, 80)
draw_line(color_green(), 50, 50, 750, 550)
refresh_screen()
1 change: 1 addition & 0 deletions public/usage-examples/graphics/fill_circle-01-example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Shows drawing basics in SplashKit: clear screen, fill_circle, fill_rectangle, draw_line; refresh each frame.
26 changes: 26 additions & 0 deletions public/usage-examples/input/key_down-01-example-oop.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using SplashKitSDK;

public static class Program
{
public static void Main()
{
new Window("Key Down Example", 800, 600);

while (!SplashKit.QuitRequested())
{
SplashKit.ProcessEvents();
SplashKit.ClearScreen(Color.White);

if (SplashKit.KeyDown(KeyCode.SpaceKey))
{
SplashKit.DrawText("Space key is pressed", Color.Black, 200, 300);
}
else
{
SplashKit.DrawText("Press the space key", Color.Black, 200, 300);
}

SplashKit.RefreshScreen();
}
}
}
20 changes: 20 additions & 0 deletions public/usage-examples/input/key_down-01-example-top-level.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using SplashKitSDK;

new Window("Key Down Example", 800, 600);

while (!SplashKit.QuitRequested())
{
SplashKit.ProcessEvents();
SplashKit.ClearScreen(Color.White);

if (SplashKit.KeyDown(KeyCode.SpaceKey))
{
SplashKit.DrawText("Space key is pressed", Color.Black, 200, 300);
}
else
{
SplashKit.DrawText("Press the space key", Color.Black, 200, 300);
}

SplashKit.RefreshScreen();
}
25 changes: 25 additions & 0 deletions public/usage-examples/input/key_down-01-example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "splashkit.h"

int main()
{
open_window("Key Down Example", 800, 600);

while (!quit_requested())
{
process_events();
clear_screen(COLOR_WHITE);

if (key_down(SPACE_KEY))
{
draw_text("Space key is pressed", COLOR_BLACK, 200, 300);
}
else
{
draw_text("Press the space key", COLOR_BLACK, 200, 300);
}

refresh_screen();
}

return 0;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions public/usage-examples/input/key_down-01-example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from splashkit import *

open_window("Key Down Example", 800, 600)

while not quit_requested():
process_events()
clear_screen(color_white())

if key_down(SPACE_KEY):
draw_text("Space key is pressed", color_black(), 200, 300)
else:
draw_text("Press the space key", color_black(), 200, 300)

refresh_screen()
2 changes: 2 additions & 0 deletions public/usage-examples/input/key_down-01-example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Demonstrates how to detect keyboard input using key_down() in SplashKit.
The example displays a message when the space key is pressed.
14 changes: 14 additions & 0 deletions public/usage-examples/input/mouse_x-01-example-oop.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using SplashKitSDK;

public static class Program {
public static void Main() {
new Window("Mouse Example", 800, 600);
while (!SplashKit.QuitRequested()) {
SplashKit.ProcessEvents();
SplashKit.ClearScreen(Color.White);
SplashKit.DrawText("Mouse X: " + SplashKit.MouseX().ToString(), Color.Black, 20, 20);
SplashKit.DrawText("Mouse Y: " + SplashKit.MouseY().ToString(), Color.Black, 20, 45);
SplashKit.RefreshScreen();
}
}
}
10 changes: 10 additions & 0 deletions public/usage-examples/input/mouse_x-01-example-top-level.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using SplashKitSDK;

new Window("Mouse Example", 800, 600);
while (!SplashKit.QuitRequested()) {
SplashKit.ProcessEvents();
SplashKit.ClearScreen(Color.White);
SplashKit.DrawText("Mouse X: " + SplashKit.MouseX().ToString(), Color.Black, 20, 20);
SplashKit.DrawText("Mouse Y: " + SplashKit.MouseY().ToString(), Color.Black, 20, 45);
SplashKit.RefreshScreen();
}
13 changes: 13 additions & 0 deletions public/usage-examples/input/mouse_x-01-example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "splashkit.h"

int main() {
open_window("Mouse Example", 800, 600);
while (!quit_requested()) {
process_events();
clear_screen(COLOR_WHITE);
draw_text("Mouse X: " + to_string(mouse_x()), COLOR_BLACK, 20, 20);
draw_text("Mouse Y: " + to_string(mouse_y()), COLOR_BLACK, 20, 45);
refresh_screen();
}
return 0;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/usage-examples/input/mouse_x-01-example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from splashkit import *

open_window("Mouse Example", 800, 600)
while not quit_requested():
process_events()
clear_screen(color_white())
draw_text("Mouse X: " + str(mouse_x()), color_black(), 20, 20)
draw_text("Mouse Y: " + str(mouse_y()), color_black(), 20, 45)
refresh_screen()
1 change: 1 addition & 0 deletions public/usage-examples/input/mouse_x-01-example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Displays current mouse position using mouse_x and mouse_y; updates every frame.
15 changes: 15 additions & 0 deletions public/usage-examples/sprites/create_sprite-01-example-oop.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using SplashKitSDK;

public static class Program {
public static void Main() {
new Window("Sprite Example", 800, 600);
Bitmap bmp = SplashKit.LoadBitmap("player", "images/player.png");
Sprite player = SplashKit.CreateSprite(bmp);
while (!SplashKit.QuitRequested()) {
SplashKit.ProcessEvents();
SplashKit.ClearScreen(Color.White);
SplashKit.DrawSprite(player);
SplashKit.RefreshScreen();
}
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using SplashKitSDK;

new Window("Sprite Example", 800, 600);
Bitmap bmp = SplashKit.LoadBitmap("player", "images/player.png");
Sprite player = SplashKit.CreateSprite(bmp);
while (!SplashKit.QuitRequested()) {
SplashKit.ProcessEvents();
SplashKit.ClearScreen(Color.White);
SplashKit.DrawSprite(player);
SplashKit.RefreshScreen();
}
14 changes: 14 additions & 0 deletions public/usage-examples/sprites/create_sprite-01-example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "splashkit.h"

int main() {
open_window("Sprite Example", 800, 600);
bitmap bmp = load_bitmap("player", "images/player.png");
sprite player = create_sprite(bmp);
while (!quit_requested()) {
process_events();
clear_screen(COLOR_WHITE);
draw_sprite(player);
refresh_screen();
}
return 0;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions public/usage-examples/sprites/create_sprite-01-example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from splashkit import *

open_window("Sprite Example", 800, 600)
bmp = load_bitmap("player", "images/player.png")
player = create_sprite(bmp)

while not quit_requested():
process_events()
clear_screen(color_white())
draw_sprite(player)
refresh_screen()
1 change: 1 addition & 0 deletions public/usage-examples/sprites/create_sprite-01-example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Loads a bitmap, creates a sprite, and draws it each frame. Requires Resources/images/player.png (see resources zip).