How do turn Itimer

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Willikus

How do turn Itimer

Post by Willikus »

So... I seek but I do not find an explanation simple...

ITimer the time functiun !

How make a clock (10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0!!!! Explosion for exemple)

In FPS, I try to use SetTime(x?) when I puch 'P', but when I puch 'P', my camera go in the place of x? seconde ago... (return towards the past)
How turn SetTime() ?
------------
timer->start();/stop();

What use this function...

The rest if is importante
__________________________
So, the context of my application :


I puch 'P',

If (Gv==0){
Gv =1

Gravity = -1
(Clock : 5,4,3,2,1,0!!!)
Gravity = 1

Gv=0
}


Help me, thx
killzone721
Posts: 19
Joined: Thu Feb 09, 2006 1:45 am

Post by killzone721 »

if i understand your question, then what you want is to start a timer...


well i have made class timer for myself to deal with timer... maybe this might hep

Code: Select all


class Timer
{
public:
	void declare()
	{
     irrTimer = mainmenu->getTimer();
	 irrTimer->getTime();
    }
	void set(int timeout)
	{
	 beginTime = irrTimer->getTime();
	 interval=0;
	 interval = timeout;
    }
	void start()
	{
     beginTime = irrTimer->getTime();
	 interval = 0;
    }
	bool alarm()
	{
	 int now = irrTimer->getTime();
     if((now - beginTime)>=interval)
     {
      return true;
     }
     else{return false;}
     return true;
    }
	int stop()
	{
	 int now = irrTimer->getTime();
	 interval = (now-beginTime);
	 return interval;
    }
	int check()
	{
	 int now = irrTimer->getTime();
	 interval = (now-beginTime);
	 return interval;
    }
	void reset()
    {
	 beginTime = 0;
	 interval = 0;
    }
private:
    int beginTime;
	int interval;
	ITimer* irrTimer;
};
to use this timer class make sure you call variable.declare(); first or the game will crash

HOPE THIS HELPS! :wink:
TO ALL THE AMATEURS OUT THERE LIKE ME......

AIM HIGH AND YOU MAKE SOMETHING PRETTY DECENT TO SHOW THE WORLD

CURRENTLY WORKING ON MY COMPANY WITH ME CREW MEMBERS. MY COMPANY IS CALLED
BIG DREAMS
AND WE ARE MAKE VERSION 0.1 FPS GAME
Willikus

Post by Willikus »

Thx for your answerd !

I go try your code (I must changed the HHD :? )

So... during the small time between the question and your answerd, I try other code but his stop all games during 2 seconde...

I don't tell my life and I go try... :arrow:
killzone721
Posts: 19
Joined: Thu Feb 09, 2006 1:45 am

Post by killzone721 »

i updated the class a bit

SO USE THIS ONE INSTED OF THE ONE ABOVE... THIS CLASS HAS THE AME CONCEPT THOUGH

Code: Select all

class Timer
{
public:
   void declare()
   {
     irrTimer = mainmenu->getTimer();
    irrTimer->getTime();
    }
   void set(int timeout)
   {
    beginTime = irrTimer->getTime();
    interval=0;
    interval = timeout;
    }
   void start()
   {
     beginTime = irrTimer->getTime();
    interval = 0;
    }
   bool alarm()
   {
    int now = irrTimer->getTime();
     if((now - beginTime)>=interval)
     {
      return true;
     }
     else{return false;}
    }
   int stop()
   {
    int now = irrTimer->getTime();
    interval = (now-beginTime);
    return interval;
    }
   int check()
   {
    int now = irrTimer->getTime();
    interval = (now-beginTime);
    return interval;
    }
   void reset()
    {
    beginTime = 0;
    interval = 0;
    }
private:
    int beginTime;
   int interval;
   ITimer* irrTimer;
}; 
TO ALL THE AMATEURS OUT THERE LIKE ME......

AIM HIGH AND YOU MAKE SOMETHING PRETTY DECENT TO SHOW THE WORLD

CURRENTLY WORKING ON MY COMPANY WITH ME CREW MEMBERS. MY COMPANY IS CALLED
BIG DREAMS
AND WE ARE MAKE VERSION 0.1 FPS GAME
Willikus

Post by Willikus »

Ok!

I'm french and I don't understand english very well (and the code). :oops:
So, You confirm my said:

->This code replace the ITimer (start(), stop(), ...) ?!
->This code add alarm() (and other but I don't know) ?!
->For regulate the Timer, I must modify 'interval' ???

And if you can confirm : if this functiun can use like this :
__________________________________________________
...Puch P...
if (alarm() == 0){
irrTimer->start();

Gravity = -1

if(alarm() == 1){ //<= It's possible ?
Gravity = 1
irrTimer->stop();
irrTimer->reset();
} else {
}
___________________________________________________

I'm sorry for ask question on C++

W
killzone721
Posts: 19
Joined: Thu Feb 09, 2006 1:45 am

Post by killzone721 »

Not exactly


Code: Select all


Timer timer                               //make a variable of the class timer

timer.declare();                         // you have to do this first or it will crash
timer.set(1000);               //you set the time 1000 = 1 sec ... it goes in 1000s
timer.stop();         // stop the timer because we have to do something before
Gravity = 1;            // START THE JUMP
timer.start();          //NOW START THE TIMER
if(timer.alarm()==true) // if timer done then
{
   gravity = -1;    //PUT GTRAVITY BACK ON
}

/////////////////////////DONE ///////////////////////////////////////

hop this helps and don't worry.. ask as many questions as you want
Last edited by killzone721 on Sun Mar 19, 2006 2:03 pm, edited 1 time in total.
TO ALL THE AMATEURS OUT THERE LIKE ME......

AIM HIGH AND YOU MAKE SOMETHING PRETTY DECENT TO SHOW THE WORLD

CURRENTLY WORKING ON MY COMPANY WITH ME CREW MEMBERS. MY COMPANY IS CALLED
BIG DREAMS
AND WE ARE MAKE VERSION 0.1 FPS GAME
killzone721
Posts: 19
Joined: Thu Feb 09, 2006 1:45 am

Post by killzone721 »

last post might be too UNCLEAR :D

here the code without documentation

Code: Select all


Timer timer 

timer.declare();
timer.set(1000);
timer.stop();  
Gravity = 1; 
timer.start();
if(timer.alarm()==true) 
{
   Gravity = -1;   
} 


HOPE THIS HELPS :wink: 
TO ALL THE AMATEURS OUT THERE LIKE ME......

AIM HIGH AND YOU MAKE SOMETHING PRETTY DECENT TO SHOW THE WORLD

CURRENTLY WORKING ON MY COMPANY WITH ME CREW MEMBERS. MY COMPANY IS CALLED
BIG DREAMS
AND WE ARE MAKE VERSION 0.1 FPS GAME
andrei25ni
Posts: 326
Joined: Wed Dec 14, 2005 10:08 pm

Post by andrei25ni »

killzone721, I have tryed your code, but I get this error :

295 MainMenu.cpp `timer' does not name a type
296 MainMenu.cpp `timer' undeclared (first use this function)

Do you know what I'm doing wrong ?
Post Reply