Monday, January 15, 2007

Irritated like the tail of a horse

Maybe one day, I assume it will be in the far distance, I'll stop writing pieces of timing code because all my timing woes will be completed once and for all. Until that day:

class TimeEvent

{

    double waitTime;

    double timeCount;

    bool set = false;

 

    public TimeEvent(double waitTime)

    {

        this.waitTime = waitTime;

    }

 

    public double WaitTime

    {

        get

        {

            return waitTime;

        }

 

        set

        {

            waitTime = value;

        }

    }

 

    public void Set(double elapsedTime)

    {

        set = true;

        timeCount = 0;

    }

 

    public void Process(double elapsedTime)

    {

        if(set)

        {

            timeCount += elapsedTime;

 

            if(timeCount > waitTime)

            {

                set = false;

            }

        }

    }

 

    public bool CheckTimeUp()

    {

        return !set;

    }

}



Anyway I had a problem with performing actions in the game - you could do them two fast. You could open and shut the chest many many times, when you just wanted to open it. So in the mouse user interface I've a delay time event of 1ms, so there's 1ms wait before you perform another event. This works rather nicely.

...of course I should really be revising, but that suddenly make my game projects seem far far more enticing.

(Updated so less illogical!)
Post a Comment