0

Hi there. I've been trying to wrap my head aound this seemingly simple problem. I am write a game and I need to show on the screen the number of seconds the game has been playing for. This is the best way I can come up with but it doesn't want to update with the new values.

        int sec = 0;
        int min = 0;
        timer_id gameTimer = create_timer(1000);
        if (timer_expired( gameTimer) )
        {   
            sec = sec + 1; 
            if (sec == 60)
            {
                sec = 0;
                min = min + 1;
            }
        }

        draw_int( screen_width()/2, screen_height()/2, sec);
        draw_int( screen_width()/2, screen_height()/2+2, min);

The last two lines don't mean anything, they are just there to check if it worked. Thank you

2
Contributors
1
Reply
22
Views
1 Year
Discussion Span
Last Post by rproffitt
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.