mirror of
https://github.com/Kapendev/parin.git
synced 2025-04-26 13:09:56 +03:00
26 lines
675 B
D
26 lines
675 B
D
/// This example shows how to use the timer structure of Parin.
|
|
|
|
import parin;
|
|
|
|
auto counter = 0;
|
|
auto timer = Timer(1, true);
|
|
|
|
void ready() {
|
|
lockResolution(320, 180);
|
|
// Start the timer when the game starts.
|
|
timer.start();
|
|
}
|
|
|
|
bool update(float dt) {
|
|
// The timer should be updated every frame, regardless of whether it is running.
|
|
timer.update(dt);
|
|
// Check if the timer has stopped and add 1 to the counter.
|
|
if (timer.hasStopped) counter += 1;
|
|
drawDebugText("Counter: {}".format(counter), Vec2(8));
|
|
drawDebugText("\nTimer: {}".format(timer.time), Vec2(8));
|
|
return false;
|
|
}
|
|
|
|
void finish() { }
|
|
|
|
mixin runGame!(ready, update, finish);
|