What about a method that gives access to the Timer

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Adversus
Posts: 128
Joined: Sun Oct 05, 2008 10:58 pm
Contact:

What about a method that gives access to the Timer

Post by Adversus »

As it belongs to the device there's no easy way to do this.
LunarEffect
Posts: 4
Joined: Thu Feb 26, 2009 6:43 pm

Post by LunarEffect »

Its not that hard really?

ITimer *timer = device->getTimer();

and then all you have to do is...

timer->getTime();
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I guess you're saying this because you don't have access to the device where you need the timer... but then how would you propose another function would provide you with the timer if not via the device (its owner)?
Image Image Image
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

JP wrote:but then how would you propose another function would provide you with the timer if not via the device (its owner)?
Singletons n00b!!! :lol:
TheQuestion = 2B || !2B
Strong99
Admin
Posts: 687
Joined: Fri Mar 31, 2006 7:06 pm
Location: Netherlands
Contact:

Post by Strong99 »

maybe he means like videodriver is accesible in the gui env and the scenemanager?
LunarEffect
Posts: 4
Joined: Thu Feb 26, 2009 6:43 pm

Post by LunarEffect »

Theres always the possibilty to write your own timer, which works just as well...

time.h gives you the function clock() and the attribute CLOCKS_PER_SEC. Its quite easy to assemble it into a working timer =)
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

CuteAlien wrote an extension/patch for multiple timers, if that's what you need you can find it here
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Halifax wrote:
JP wrote:but then how would you propose another function would provide you with the timer if not via the device (its owner)?
Singletons n00b!!! :lol:
Aye but Irrlicht dun use dose newb :evil:

:lol:
Image Image Image
Adversus
Posts: 128
Joined: Sun Oct 05, 2008 10:58 pm
Contact:

Post by Adversus »

You don't have access to the device when you create an entity using a factory i.e. one loaded in from xml.

So therefore you can't simply pass in a reference.

Oh and for singletons. I try to avoid them as they're effectively global variables and can cause unforseen problems (i.e. using it for your SceneManager), but for this case that's not the reason. I would simply never have access to it to create it in the first place as I'm writing a CustomSceneNode in IrrEdit without IrrEdit's source code so all I can "see" is the SceneManager.

Oh and I have 7 years experience in C++ and two published games under my belt for Namco and EA Halifax. Just out of curiosity, what's your resume? :-)

btw - I got round the problem by using the same method in the example Animators by just doing:

Code: Select all

// first update?
if( firstUpdate )
{
	lastTime = timeMs;
	firstUpdate = false;
}
// find the delta time in seconds
f32 timeDelta = (f32) (timeMs - lastTime) / 1000.0f; 
However it just seemed a bit wasteful.
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

Adversus wrote:Oh and I have 7 years experience in C++ and two published games under my belt for Namco and EA Halifax. Just out of curiosity, what's your resume? :-)
My respone wasn't an attack...I was joking around with JP.
TheQuestion = 2B || !2B
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I has mor pohsts dan yew :twisted:

[/spam]
Image Image Image
hayate
Posts: 43
Joined: Mon Feb 16, 2009 9:38 pm
Location: Brescia, Italy

Post by hayate »

Adversus wrote:...
two published games under my belt for Namco and EA Halifax
...
I'm just curious: what's the name of these games? :shock:
Sorry for my awful english ^_^'
Image
Adversus
Posts: 128
Joined: Sun Oct 05, 2008 10:58 pm
Contact:

Post by Adversus »

I-Ninja and Catwoman (yea I know it was crap but we had around 8 months to do it and the design was poo). Ninja was a good little game though.

yea ok Halifax, reading it back I realise that now. I apologise. It's just that sometimes people are put off by others that know only a little more than they do and want to simply make themselves feel better. That and I was having one of those days ;-)
Post Reply