Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
00a5cc3
Added usage example for Close Window Function
JulianBurton Aug 10, 2025
db40835
Add files via upload
CATHoDE33 Aug 23, 2025
7870dc1
Add files via upload
CATHoDE33 Sep 1, 2025
28696e0
changed files to match feedback given
JulianBurton Sep 1, 2025
470816e
Safe local fallback for Algolia env vars
ctrlvish Jul 26, 2025
65c0d36
Fix typo in script
ctrlvish Sep 10, 2025
5bad740
Revert "Safe local fallback for Algolia env vars"
ctrlvish Sep 10, 2025
36ad639
changes made
JulianBurton Sep 11, 2025
55fb8fd
Add files via upload
CATHoDE33 Sep 16, 2025
20077c9
adding game tutorial
ctrlvish Sep 19, 2025
1479153
Add files via upload
CATHoDE33 Sep 19, 2025
31a3a4d
updated tutorial to use imported and bigger font
ctrlvish Sep 21, 2025
2b1e417
Add files via upload
CATHoDE33 Sep 25, 2025
5cbd557
install fix (#37)
breezy-codes Oct 1, 2025
b1554a3
Update api.json
omckeon Nov 16, 2025
fdd6a69
Update api.json
omckeon Nov 29, 2025
46491f2
Update resume_music example to use new music paused/playing functions
omckeon Dec 4, 2025
da712a2
Add example for raspi_i2c_write_data function
omckeon Dec 4, 2025
7bb69af
Implementation to Reference Usage Examples (#408)
EthanRin Dec 4, 2025
5c26eba
Merge pull request #640 from CATHoDE33/rectangle_around
monicavtasmin Dec 6, 2025
aac8a7f
Merge pull request #573 from JulianBurton/CloseWindow
monicavtasmin Dec 6, 2025
df41a11
Merge pull request #585 from CATHoDE33/bitmap_center
monicavtasmin Dec 6, 2025
ec006f1
Merge pull request #631 from ctrlvish/apipagesbug
monicavtasmin Dec 6, 2025
038e3cd
Merge pull request #642 from ctrlvish/new-game-tutorial
monicavtasmin Dec 6, 2025
bd83478
Add has_timer usage examples in multiple languages
222448082Ashen Dec 21, 2025
f616144
Update usage example references and scraping logic
222448082Ashen Dec 21, 2025
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
59 changes: 58 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,62 @@
{
"files.associations": {
"*.mdx": "markdown"
}
},
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false
}
22 changes: 12 additions & 10 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import starlightDocSearch from '@astrojs/starlight-docsearch';
import remarkHeadingID from 'remark-heading-id';
import { loadEnv } from "vite";

const { DOCSEARCH_API_ID } = loadEnv(process.env.DOCSEARCH_API_ID, process.cwd(), "");
const { DOCSEARCH_API_SEARCH_KEY } = loadEnv(process.env.DOCSEARCH_API_SEARCH_KEY, process.cwd(), "");
const { DOCSEARCH_INDEX_NAME } = loadEnv(process.env.DOCSEARCH_INDEX_NAME, process.cwd(), "");
const env = loadEnv("", process.cwd(), "");
const DOCSEARCH_API_ID = env.DOCSEARCH_API_ID || process.env.DOCSEARCH_API_ID;
const DOCSEARCH_API_SEARCH_KEY = env.DOCSEARCH_API_SEARCH_KEY || process.env.DOCSEARCH_API_SEARCH_KEY;
const DOCSEARCH_INDEX_NAME = env.DOCSEARCH_INDEX_NAME || process.env.DOCSEARCH_INDEX_NAME;

if (!DOCSEARCH_API_ID || !DOCSEARCH_API_SEARCH_KEY || !DOCSEARCH_INDEX_NAME) {
console.error("Algolia DocSearch enviroment variables are invalid. Please check configuration!");
process.exit(1);
console.warn("Algolia DocSearch environment variables are not set. DocSearch will be disabled.");
}

// https://astro.build/config
Expand All @@ -36,11 +36,13 @@ export default defineConfig({
starlightLinksValidator({
errorOnRelativeLinks: true,
}),
starlightDocSearch({
appId: DOCSEARCH_API_ID,
apiKey: DOCSEARCH_API_SEARCH_KEY,
indexName: DOCSEARCH_INDEX_NAME,
}),
...(DOCSEARCH_API_ID && DOCSEARCH_API_SEARCH_KEY && DOCSEARCH_INDEX_NAME ? [
starlightDocSearch({
appId: DOCSEARCH_API_ID,
apiKey: DOCSEARCH_API_SEARCH_KEY,
indexName: DOCSEARCH_INDEX_NAME,
})
] : []),
],
expressiveCode: {
// theme: ["github-dark", "github-light"],
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"build": "npm run setup && astro build",
"preview": "astro preview",
"astro": "astro",
"setup": "node ./scripts/json-files-script.cjs && node ./scripts/api-pages-script.cjs",
"setup": "node ./scripts/json-files-script.cjs && node ./scripts/usage-example-scraping.cjs && node ./scripts/api-pages-script.cjs",
"generate-mdx": "node ./scripts/api-pages-script.cjs",
"generate-json": "node ./scripts/json-files-script.cjs",
"generate-json": "node ./scripts/json-files-script.cjs && node ./scripts/usage-example-scraping.cjs",
"check-links": "SET CHECK_LINKS=true && npm run build && SET CHECK_LINKS=false"
},
"dependencies": {
Expand Down
Binary file not shown.
11 changes: 4 additions & 7 deletions public/usage-examples/audio/resume_music-1-example-oop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public static void Main()
// Load music file and start playing
Music music = SplashKit.LoadMusic("Adventure", "time_for_adventure.mp3");
music.Play();
bool musicPlaying = true;

Window window = SplashKit.OpenWindow("Pause/Resume", 300, 200);

Expand All @@ -27,29 +26,27 @@ public static void Main()
if (SplashKit.KeyTyped(KeyCode.SpaceKey))
{
// Check if music is paused or not
if (musicPlaying)
if (SplashKit.MusicPlaying())
{
// Pause if playing
SplashKit.PauseMusic();
musicPlaying = false;
}
else
{
// Play if paused
SplashKit.ResumeMusic();
musicPlaying = true;
}
}

// Display text showing if music is playing or not
window.Clear(Color.White);
if (musicPlaying)
if (SplashKit.MusicPaused())
{
window.DrawText("Playing", Color.Black, 100, 100);
window.DrawText("Paused...", Color.Black, 100, 100);
}
else
{
window.DrawText("Paused...", Color.Black, 100, 100);
window.DrawText("Playing", Color.Black, 100, 100);
}
window.Refresh();
}
Expand Down
11 changes: 4 additions & 7 deletions public/usage-examples/audio/resume_music-1-example-top-level.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
// Load music file and start playing
Music music = LoadMusic("Adventure", "time_for_adventure.mp3");
PlayMusic(music);
bool musicPlaying = true;

Window window = OpenWindow("Pause/Resume", 300, 200);

Expand All @@ -22,29 +21,27 @@
if (KeyTyped(KeyCode.SpaceKey))
{
// Check if music is paused or not
if (musicPlaying)
if (MusicPlaying())
{
// Pause if playing
PauseMusic();
musicPlaying = false;
}
else
{
// Play if paused
ResumeMusic();
musicPlaying = true;
}
}

// Display text showing if music is playing or not
ClearWindow(window, ColorWhite());
if (musicPlaying)
if (MusicPaused())
{
DrawTextOnWindow(window, "Playing", ColorBlack(), 100, 100);
DrawTextOnWindow(window, "Paused...", ColorBlack(), 100, 100);
}
else
{
DrawTextOnWindow(window, "Paused...", ColorBlack(), 100, 100);
DrawTextOnWindow(window, "Playing", ColorBlack(), 100, 100);
}
RefreshWindow(window);
}
Expand Down
13 changes: 6 additions & 7 deletions public/usage-examples/audio/resume_music-1-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ int main()
// Load music file and start playing
music music = load_music("adventure", "time_for_adventure.mp3");
play_music(music);
bool music_playing = true;

window window = open_window("Pause/Resume", 300, 200);

Expand All @@ -23,34 +22,34 @@ int main()
if (key_typed(SPACE_KEY))
{
// Check if music is paused or not
if (music_playing)
if (music_playing())
{
// Pause if playing
pause_music();
music_playing = false;
}
else
{
// Play if paused
resume_music();
music_playing = true;
}
}

// Display text showing if music is playing or not
clear_window(window, COLOR_WHITE);
if (music_playing)
if (music_paused())
{
draw_text_on_window(window, "Playing", COLOR_BLACK, 100, 100);
draw_text_on_window(window, "Paused...", COLOR_BLACK, 100, 100);
}
else
{
draw_text_on_window(window, "Paused...", COLOR_BLACK, 100, 100);
draw_text_on_window(window, "Playing", COLOR_BLACK, 100, 100);
}
refresh_window(window);
}

// Cleanup
free_all_music();
close_all_windows();

return 0;
}
11 changes: 4 additions & 7 deletions public/usage-examples/audio/resume_music-1-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# Load music file and start playing
music = load_music("adventure", "time_for_adventure.mp3")
play_music(music)
music_playing = True

window = open_window("Pause/Resume", 300, 200)

Expand All @@ -17,21 +16,19 @@
# Check for pause/play request
if (key_typed(KeyCode.space_key)):
# Check if music is paused or not
if (music_playing):
if (music_playing()):
# Pause if playing
pause_music()
music_playing = False
else:
# Play if paused
resume_music()
music_playing = True

# Display text showing if music is playing or not
clear_window(window, color_white())
if (music_playing):
draw_text_on_window_no_font_no_size(window, "Playing", color_black(), 100, 100)
else:
if (music_paused()):
draw_text_on_window_no_font_no_size(window, "Paused...", color_black(), 100, 100)
else:
draw_text_on_window_no_font_no_size(window, "Playing", color_black(), 100, 100)
refresh_window(window)

# Cleanup
Expand Down
59 changes: 59 additions & 0 deletions public/usage-examples/geometry/rectangle_around-1-example-oop.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using SplashKitSDK;

namespace RectangleAroundExample
{
public class Program
{
public static void Main()
{
SplashKit.OpenWindow("Boring Screensaver", 800, 600);

Circle circle;
int circleSize = 30;
float rotationDegrees = 0;
Point2D circleCoordinates;
bool growing = true;
SplashKitSDK.Timer mainTimer = SplashKit.CreateTimer("mainTimer");
SplashKit.StartTimer(mainTimer);
SplashKitSDK.Timer reverseTimer = SplashKit.CreateTimer("reverseTimer");
SplashKit.StartTimer(reverseTimer);

while (!SplashKit.QuitRequested())
{
rotationDegrees += 0.005f;
circleCoordinates = SplashKit.PointAt(300 + 150 * SplashKit.Cosine(rotationDegrees), 300 + 150 * SplashKit.Sine(rotationDegrees));
circle = SplashKit.CircleAt(circleCoordinates, circleSize);

if (SplashKit.TimerTicks(mainTimer) >= 40 && growing == true)
{
circleSize += 1;
SplashKit.ResetTimer(mainTimer);
}
else if (SplashKit.TimerTicks(reverseTimer) >= 3000)
{
growing = false;
}

if (SplashKit.TimerTicks(mainTimer) >= 40 && growing == false)
{
circleSize -= 1;
SplashKit.ResetTimer(mainTimer);
}
else if (SplashKit.TimerTicks(reverseTimer) >= 6000)
{
growing = true;
SplashKit.ResetTimer(reverseTimer);
}

SplashKit.ProcessEvents();

SplashKit.ClearScreen(Color.White);
// A rectangle is drawn which encompasses the circle. It shares the same height, width and position
SplashKit.DrawRectangle(Color.Black, SplashKit.RectangleAround(circle));
SplashKit.FillCircle(Color.Red, circle);
SplashKit.RefreshScreen();
}
SplashKit.CloseAllWindows();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using SplashKitSDK;
using static SplashKitSDK.SplashKit;

OpenWindow("Boring Screensaver", 800, 600);

Circle circle;
int circleSize = 30;
float rotationDegrees = 0;
Point2D circleCoordinates;
bool growing = true;
// SplashKitSDK.Timer needed to distinguish from System.Threading.Timer ↓
SplashKitSDK.Timer mainTimer = CreateTimer("mainTimer");
StartTimer(mainTimer);
SplashKitSDK.Timer reverseTimer = CreateTimer("reverseTimer");
StartTimer(reverseTimer);

while (!QuitRequested())
{
rotationDegrees += 0.005f;
circleCoordinates = PointAt(300 + 150 * Cosine(rotationDegrees), 300 + 150 * Sine(rotationDegrees));
circle = CircleAt(circleCoordinates, circleSize);

if (TimerTicks(mainTimer) >= 40 && growing == true)
{
circleSize += 1;
ResetTimer(mainTimer);
}
else if (TimerTicks(reverseTimer) >= 3000)
{
growing = false;
}

if (TimerTicks(mainTimer) >= 40 && growing == false)
{
circleSize -= 1;
ResetTimer(mainTimer);
}
else if (TimerTicks(reverseTimer) >= 6000)
{
growing = true;
ResetTimer(reverseTimer);
}

ProcessEvents();

ClearScreen(ColorWhite());
// A rectangle is drawn which encompasses the circle. It shares the same height, width and position
DrawRectangle(ColorBlack(), RectangleAround(circle));
FillCircle(ColorRed(), circle);
RefreshScreen();
}
CloseAllWindows();
Loading