sample: custom timers/alarms the easy way

Topics on software tools like TileStudio, comments on documentation and tutorials (or the lack of) should go here.
Post Reply
User avatar
Posts: 125
Joined: Tue Feb 04, 2014 9:48 pm
Location: netherlands

sample: custom timers/alarms the easy way

Post by schepers_cp » Sat May 10, 2014 2:15 pm

hey all, to get people starting coding with timers and alarms here's a simple sampleon them.

Code: Select all

// i assume you use WaitVsync(1), so the fps is set to 60, so set the counter to 60
#define FPS_SEC 60
unsigned int counter_one_sec = FPS_SEC; //the actual counter variable

int main(){
	while(1) {
		WaitVsync(1); //needed for the counter to work properly
		if (counter_one_sec < 1) {
			//do the stuff you like every second

			//reset the value on the counter, it is advisable to keep it in here to re-run it every second
			//use this elsewhere in your code to actually create an alarm that goes off 1 second after the event happened
			counter_one_sec = FPS_SEC;
		//decrease the value by 1 if it's more than 0
		if (counter_one_sec > 0)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests