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

namespace StopTimerExample
{
public class Program
{
public static void Main()
{
SplashKit.OpenWindow("Press S to Stop Timer", 700, 220);

SplashKit.CreateTimer("demo");
SplashKit.StartTimer("demo");

while (!SplashKit.QuitRequested())
{
SplashKit.ProcessEvents();

if (SplashKit.KeyTyped(KeyCode.SKey) && SplashKit.TimerStarted("demo"))
{
SplashKit.StopTimer("demo");
}

string status = SplashKit.TimerStarted("demo") ? "Running" : "Stopped";
uint ticks = SplashKit.TimerTicks("demo");

SplashKit.ClearScreen(Color.White);

SplashKit.DrawText("Press S to stop the timer", Color.Black, 20, 20);
SplashKit.DrawText("Status: " + status, Color.Blue, 20, 70);
SplashKit.DrawText("Ticks: " + ticks, Color.Red, 20, 110);

SplashKit.RefreshScreen(60);
}

SplashKit.CloseAllWindows();
}
}
}
30 changes: 30 additions & 0 deletions public/usage-examples/timers/stop_timer-1-example-top-level.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using SplashKitSDK;
using static SplashKitSDK.SplashKit;

OpenWindow("Press S to Stop Timer", 700, 220);

CreateTimer("demo");
StartTimer("demo");

while (!QuitRequested())
{
ProcessEvents();

if (KeyTyped(KeyCode.SKey) && TimerStarted("demo"))
{
StopTimer("demo");
}

string status = TimerStarted("demo") ? "Running" : "Stopped";
uint ticks = TimerTicks("demo");

ClearScreen(ColorWhite());

DrawText("Press S to stop the timer", ColorBlack(), 20, 20);
DrawText($"Status: {status}", ColorBlue(), 20, 70);
DrawText($"Ticks: {ticks}", ColorRed(), 20, 110);

RefreshScreen(60);
}

CloseAllWindows();
36 changes: 36 additions & 0 deletions public/usage-examples/timers/stop_timer-1-example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "splashkit.h"
#include <string>

using namespace std;

int main()
{
open_window("Press S to Stop Timer", 700, 220);

create_timer("demo");
start_timer("demo");

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

if (key_typed(S_KEY) && timer_started("demo"))
{
stop_timer("demo");
}

string status = timer_started("demo") ? "Running" : "Stopped";
unsigned int ticks = timer_ticks("demo");

clear_screen(COLOR_WHITE);

draw_text("Press S to stop the timer", COLOR_BLACK, 20, 20);
draw_text("Status: " + status, COLOR_BLUE, 20, 70);
draw_text("Ticks: " + to_string((int)ticks), COLOR_RED, 20, 110);

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.
25 changes: 25 additions & 0 deletions public/usage-examples/timers/stop_timer-1-example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from splashkit import *

open_window("Press S to Stop Timer", 700, 220)

create_timer("demo")
start_timer_named("demo")

while not quit_requested():
process_events()

if key_typed(KeyCode.s_key) and timer_started_named("demo"):
stop_timer_named("demo")

status = "Running" if timer_started_named("demo") else "Stopped"
ticks = timer_ticks_named("demo")

clear_screen(color_white())

draw_text_no_font_no_size("Press S to stop the timer", color_black(), 20, 20)
draw_text_no_font_no_size(f"Status: {status}", color_blue(), 20, 70)
draw_text_no_font_no_size(f"Ticks: {ticks}", color_red(), 20, 110)

refresh_screen()

close_all_windows()
3 changes: 3 additions & 0 deletions public/usage-examples/timers/stop_timer-1-example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Press S to Stop Timer

Press S to stop the timer and reset its ticks to 0.