Qbasicnews.com

QBasic => QB Discussion & Programming Help => Topic started by: NovaProgramming on June 29, 2004, 02:17:40 PM



Title: In-game timer
Post by: NovaProgramming on June 29, 2004, 02:17:40 PM
I am in the process of re-doing my Qbasic RPG (Mokli: Quest for the Gems) and I was wondering if it were possible to make an in-game timer... you know, like they have on Final Fantasy or something, that tells you how long you've played?  I've messed around with the TIMER function, but haven't gotten it to work quite right...  Any help would be appreciated, thanks!


Title: In-game timer
Post by: Zack on June 29, 2004, 03:48:39 PM
Indeed, TIMER can be counter-intuitive. Here's a timer routine. It checks if a full second has past, and if so, updates the timer output.
Code:
t!=TIMER
DO
    IF TIMER - t! >= 1 THEN
        elapsed=elapsed + 1
        LOCATE 1,1: PRINT elapsed
        t!=TIMER
    END IF
LOOP

Of course, if the user is playing when the clock strikes midnight then the timer will be screwed up. But just trust that nobody is a nerd enough to be playing a game through midnight. :wink:


Title: In-game timer
Post by: NovaProgramming on June 29, 2004, 06:14:43 PM
yeah, especially if it's MY game  :D