Stopinga countdown timer & getting that info

Game Editor comments and discussion.

Stopinga countdown timer & getting that info

Postby Antxion » Mon Mar 26, 2012 10:07 am

I'm trying to stop a countdown timer once my player hits a checkpoint and then get that time to use in a bonus screen

Here is the code I'm using for the timer. I can't figure out how to stop it.

Global Script
Code: Select all
int SecLeft = 30;
int VirtSec = 30;
int NumFrames = 0;


Timer - Create Actor - Script
Code: Select all
sprintf(text, "%i", VirtSec);


Timer - Draw Actor - Script
Code: Select all
if(NumFrames >= real_fps)
{
    if(SecLeft > 0)
    {
        SecLeft -= 1;
        if(VirtSec <= 0)
        {
            VirtSec = 59;
        }
        else
        {
            VirtSec -= 1;
        }
        sprintf(text, "%02d", VirtSec);
    }
    NumFrames = 0;
}
else
{
    NumFrames += 1;
}
"Only through fire is a strong sword forged."
May the force be with you.
User avatar
Antxion
 
Posts: 22
Joined: Sun Mar 25, 2012 1:04 am
Score: 0 Give a positive score

Re: Stopinga countdown timer & getting that info

Postby SuperSonic » Mon Mar 26, 2012 3:10 pm

Is that the code from my tutorial that you're using? ^^

Ok, here's what you have to do. In your global code, put this:
Code: Select all
int TimerOn = 1;

Then, on your collision event, put this:
Code: Select all
TimerOn = 0;

Finally, for your draw actor event, replace it with this:
Code: Select all
if(TimerOn)//Notice how I simply added an if statement to check whether or not the timer is on
{
    if(NumFrames >= real_fps)
    {
        if(SecLeft > 0)
        {
            SecLeft -= 1;
            if(VirtSec <= 0)
            {
                VirtSec = 59;
            }
            else
            {
                VirtSec -= 1;
            }
            sprintf(text, "%02d", VirtSec);
        }
        NumFrames = 0;
    }
    else
    {
        NumFrames += 1;
    }
}
Hope that helps :wink:
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Stopinga countdown timer & getting that info

Postby Antxion » Mon Mar 26, 2012 9:43 pm

+1
Yeah that was your code from your tutorial.
Thanks so much supersonic ,you really are super, thats really been bugging me.
"Only through fire is a strong sword forged."
May the force be with you.
User avatar
Antxion
 
Posts: 22
Joined: Sun Mar 25, 2012 1:04 am
Score: 0 Give a positive score

Re: Stopinga countdown timer & getting that info

Postby SuperSonic » Mon Mar 26, 2012 10:18 pm

Thanks for the point, and no problem. I'm glad I could help :wink:
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Stopinga countdown timer & getting that info

Postby Johnno » Tue Mar 27, 2012 2:15 am

oooh nice, I'm going to use that. Thanks SuperSonic
+1
Johnno
 
Posts: 23
Joined: Thu Mar 22, 2012 2:56 am
Score: 4 Give a positive score

Re: Stopinga countdown timer & getting that info

Postby SuperSonic » Tue Mar 27, 2012 2:48 am

Johnno wrote:oooh nice, I'm going to use that. Thanks SuperSonic
+1
Haha, no problem. And thank you for the point :P
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest