al_create_timer(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– al_create_timer πŸ’–

okay bestie so this is a page from the Allegro 5 API β€” yes, that Allegro, the one your gamedev mutuals won't shut up about πŸŽ€ β€” and it's all about making a timer. no cap.


✨ NAME ✨

al_create_timer β€” Allegro 5 API. it literally does what it says on the tin, she makes timers πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro5/allegro.h>

ALLEGRO_TIMER *al_create_timer(double speed_secs)

like, that's the whole vibe. one include, one function, one double. iconic.


🌸 DESCRIPTION 🌸

so what this does is it allocates and initializes a timer. that's it, that's the job 🫢

if it goes well? you get back a pointer to a brand-new timer object, main character energy, freshly spawned. if it does not go well? you get NULL back. no timer, no party, we're sobbing 😭

now, speed_secs β€” and this is the part people get wrong β€” is in seconds per "tick". so it's not "how many ticks per second", it's "how long one tick takes". and it must be positive. zero? negative? not it. the function said no 🚫

⚠️ also, and this is important bestie: the new timer is initially stopped. it is not running. it is sitting there, pretty, asleep, doing absolutely nothing. you have to wake it up with al_start_timer(3alleg5) before any ALLEGRO_EVENT_TIMER(3alleg5) events start getting sent. so if you're sitting there like "why is my timer not timing" β€” that's why. you didn't start her. periodt.

usage note: typical granularity is on the order of microseconds β€” cute, right? β€” but with some drivers it might only be milliseconds. so like, don't be shocked if your precision is giving "close enough" on certain setups. it's not you, it's the driver πŸ’€


🌈 SEE ALSO 🌈


and that's the whole page, bestie!! πŸ’œ this lil writeup came to you straight from the Allegro reference manual, and yes, the page itself is al_create_timer(3alleg5) β€” same name top and bottom, she's consistent like that πŸ‘‘ now go start that timer, fr fr πŸŽ€βœ¨

πŸ“¦ where this page comes from