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
16 changes: 16 additions & 0 deletions public/usage-examples/utilities/replace_all-1-example-oop.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using SplashKitSDK;

public class Program

Choose a reason for hiding this comment

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

Wrap this in a namespace per convention, e.g.:

namespace ReplaceAllExample
{
    public class Program
    {
        ...
    }
}

{
public static void Main()
{
// Store the sentence to update
string text = "foo is here, foo is there, foo is everywhere.";

// Replace every "foo" with "bar"
string result = SplashKit.ReplaceAll(text, "foo", "bar");

// Show the updated sentence
SplashKit.WriteLine(result);
}
}
10 changes: 10 additions & 0 deletions public/usage-examples/utilities/replace_all-1-example-top-level.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using SplashKitSDK;

Choose a reason for hiding this comment

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

For top-level C#, use using static SplashKitSDK.SplashKit; so you can call functions directly like ReplaceAll(...) and WriteLine(...) without the SplashKit. prefix. Right now this reads the same as the OOP version.


// Store the sentence to update
string text = "foo is here, foo is there, foo is everywhere.";

// Replace every "foo" with "bar"
string result = SplashKit.ReplaceAll(text, "foo", "bar");

// Show the updated sentence
SplashKit.WriteLine(result);
16 changes: 16 additions & 0 deletions public/usage-examples/utilities/replace_all-1-example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "splashkit.h"
using namespace std;

Choose a reason for hiding this comment

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

You don't need using namespace std; here — SplashKit handles string through #include "splashkit.h". Just remove this line.


int main()
{
// Store the sentence to update
string text = "foo is here, foo is there, foo is everywhere.";

// Replace every "foo" with "bar"
string result = replace_all(text, "foo", "bar");

// Show the updated sentence
write_line(result);

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/utilities/replace_all-1-example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from splashkit import *

# Store the sentence to update
text = "foo is here, foo is there, foo is everywhere."

# Replace every "foo" with "bar"
result = replace_all(text, "foo", "bar")

# Show the updated sentence
write_line(result)
1 change: 1 addition & 0 deletions public/usage-examples/utilities/replace_all-1-example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replace all occurrences of one word in a sentence
4 changes: 2 additions & 2 deletions scripts/json-files/guides-groups.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[
"Camera",

Choose a reason for hiding this comment

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

This capitalisation change (cameraCamera, graphicsGraphics) looks unrelated to the replace_all example. Could potentially break guide generation — best to revert this file and submit separately if needed.

"Graphics",
"animations",
"audio",
"beyond-splashkit",
"camera",
"color",
"graphics",
"input",
"interface",
"json",
Expand Down
141 changes: 141 additions & 0 deletions scripts/json-files/usage-example-references.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,31 @@
]
}
],
"color": [

Choose a reason for hiding this comment

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

This saturation_of entry isn't related to the replace_all example — should go in the PR that adds the saturation_of usage example instead. Same goes for the rectangle_around, bitmap_center, draw_circle, get_font_style, and close_window entries below. Keep this PR focused on just replace_all.

{
"funcKey": "saturation_of",
"title": "Draws a rectangle in a random colour. The colour's saturation value is displayed on screen",
"url": "/api/color/#saturation-of",
"functions": [
"open_window",
"random_rgb_color",
"round",
"rectangle_from",
"clear_screen",
"color_white",
"fill_rectangle_record",
"draw_text_no_font_no_size",
"color_black",
"red_of",
"green_of",
"blue_of",
"alpha_of",
"refresh_screen",
"delay",
"close_all_windows"
]
}
],
"geometry": [
{
"funcKey": "center_point",
Expand Down Expand Up @@ -524,6 +549,32 @@
"close_window"
]
},
{
"funcKey": "rectangle_around",
"title": "A perpetually moving circle which increases and decreases in size, surrounded by a rectangle shape",
"url": "/api/geometry/#rectangle-around",
"functions": [
"open_window",
"create_timer",
"start_timer",
"quit_requested",
"point_at",
"cosine",
"sine",
"circle_at",
"timer_ticks",
"reset_timer",
"process_events",
"clear_screen_to_white",
"draw_rectangle_record",
"color_black",
"rectangle_around_circle",
"fill_circle_record",
"color_red",
"refresh_screen",
"close_all_windows"
]
},
{
"funcKey": "same_point",
"title": "Point 2D Guessing Game",
Expand Down Expand Up @@ -561,6 +612,24 @@
"close_all_windows"
]
},
{
"funcKey": "bitmap_center",
"title": "Draw a bitmap with a red dot at its center\r",
"url": "/api/graphics/#bitmap-center",
"functions": [
"open_window",
"load_bitmap",
"clear_screen",
"color_white",
"draw_bitmap",
"fill_circle_record",
"color_red",
"circle_at",
"refresh_screen",
"delay",
"close_all_windows"
]
},
{
"funcKey": "clear_screen",
"title": "Background Color",
Expand Down Expand Up @@ -597,6 +666,26 @@
"SplashKit"
]
},
{
"funcKey": "draw_circle",
"title": "Circle Showcase",
"url": "/api/graphics/#draw-circle",
"functions": [
"open_window",
"clear_screen",
"color_white",
"fill_circle",
"color_red",
"color_blue",
"color_green",
"color_orange",
"color_purple",
"random_rgb_color",
"refresh_screen",
"delay",
"close_all_windows"
]
},
{
"funcKey": "draw_circle_on_bitmap",
"title": "Creating a Red Planet",
Expand Down Expand Up @@ -1189,6 +1278,25 @@
"close_all_windows"
]
},
{
"funcKey": "get_font_style",
"title": "The program automatically cycles through font styles for a given font (also displaying example text), with the numerical value of each style being shown on screen\r",
"url": "/api/graphics/#get-font-style",
"functions": [
"open_window",
"font_named",
"quit_requested",
"process_events",
"set_font_style",
"clear_screen_to_white",
"draw_text_no_font_no_size",
"color_black",
"draw_text",
"refresh_screen",
"delay",
"close_all_windows"
]
},
{
"funcKey": "has_font",
"title": "Checking for Font using Variable",
Expand Down Expand Up @@ -1730,6 +1838,14 @@
"write_line"
]
},
{
"funcKey": "replace_all",
"title": "Replacing all occurrences of a word in a sentence",

Choose a reason for hiding this comment

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

The functions list here just has "print" — should be "replace_all" and "write_line" (the actual SplashKit functions used in the example).

"url": "/api/utilities/#replace-all",
"functions": [
"print"
]
},
{
"funcKey": "rnd",
"title": "Coin Flip",
Expand Down Expand Up @@ -1790,5 +1906,30 @@
"write_line"
]
}
],
"windows": [
{
"funcKey": "close_window",
"title": "Starts a countdown to close the window at the push of a button.",
"url": "/api/windows/#close-window",
"functions": [
"open_window",
"create_timer",
"quit_requested",
"process_events",
"clear_window",
"color_white",
"button_at_position",
"rectangle_from",
"start_timer",
"draw_text_font_as_string",
"color_black",
"timer_ticks",
"reset_timer",
"draw_interface",
"refresh_window",
"close_all_windows"
]
}
]
}