Howto-Make an advanced timer

You must understand the Game Editor concepts, before post here.

Howto-Make an advanced timer

Postby Hblade » Wed Jun 10, 2009 5:57 am

Advanced Timer
    Written by Hblade

Step 1
    Programming the timer
Open up Global code and put this code in it
Code: Select all
int framecount;
void Wait(int f)
{
    framecount = framecount + 1;
    if (framecount == f)
    {
        switch(temp)
        case 0:
        temp = 1;
        framecount = 0;
    }
}

Make a variable and call it temp, make it an actor variable

Step 2
    Using the timer
Open up the actor you wan't the timer to apply to, then click Draw Actor - Script editor, then put this code in
Code: Select all
Wait(189);
if (temp == 1)
{
enter your code
}

It wil wait for 189 frames then it will initiate the code
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Howto-Make an advanced timer

Postby Fuzzy » Wed Jun 10, 2009 6:27 am

Nicely done.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Re: Howto-Make an advanced timer

Postby skydereign » Wed Jun 10, 2009 6:40 am

Why not implement two actor variables, since you are already using one? That way any actor can call the function, and framecount won't get confused. Just switch framecount to an actor variable. It wouldn't hurt efficiency, as only actors with the function call would have a changing framecount.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Howto-Make an advanced timer

Postby Hblade » Fri Jun 12, 2009 6:41 am

Nice sky
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron