delorie.com/archives/browse.cgi | search |
From: | "DeHackEd" <Not DOT given AT out> |
References: | <6jmlve$6fp$1 AT news3 DOT isdnet DOT net> |
Subject: | Re: Need tips to code a FPS counter with Allegro |
Date: | Sun, 17 May 1998 16:32:15 -0400 |
Lines: | 39 |
Message-ID: | <O24pNLdg9GA.69@uppubnews03> |
Newsgroups: | comp.os.msdos.djgpp |
NNTP-Posting-Host: | d7-bn46-blvl-pda.attcanada.net [142.194.137.199] |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Take a look at the allegro demo game, or to be more specific... This code should be easy enough to figure out. Just be sure to lock. The first bit of code can go strait in and the second bit must be adjusted to your code. Whenever you want to display FPS itoa, sprintf, or textprintf it to the screen. volatile int fps_proc; volatile int fps; void fps_ticker() { fps = fps_proc; fps_proc = 0; // reset FPS so it doesn't keep getting bigger } END_OF_FUNCTION(fps_ticker) // in your main code: int game_process() { while (1) { if (do_game_data()) return 1; if (draw_a_frame()) return 0; fps_proc++; } return -1; } -- "DeHackEd" EMail address not given out due to low-life spammers.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |