Utilizing "tpf" outside of simpleUpdate


I was wondering if there was a proper way to use “tpf” outside of simpleUpdate()? For testing purposes I’ve been transferring tpf to a global tpfTemp to use it in simpleInitApp(), but I have a feeling it’s inefficient and takes double the time to transfer so many values over and over. Isn’t there a way I could globally access it? Thank you :slight_smile:

UPDATE: On second thought since simpleInitApp() only runs once it’s useless to globally access tpf. I’d still be interested in how for future reference, though. Thanks!

Where exactly do you want to access it? Everything in the game loop has access to it as long as you pass it down the chain.

You basically never get this situation. If you want to split code (same stuff, other classes), you can use BaseAppState.

In the simpleInitApp()

I see. I’ve been reading up on App States and the creation of new ones. Thank you :slight_smile: I’m quite new to this.

You are aware that tpf is not constant correct. In fact for the first few frames it is often all over the place before settling down.

Of course, otherwise I wouldn’t be relying on it for my sine wave y values :slight_smile: thank you.

What would the “time since last frame” value be when there hasn’t been any frames yet and this isn’t a frame yet?

tpf makes absolutely no sense during simpleInitApp(). It’s like wondering what tpf is before you’ve even started your application.

It sounds like you are doing improper stuff in simpleInitApp().

1 Like

It was a silly moment I had. I was trying to utilize “tpf” to generate proper values so that I could scale my cube and simulate “pulsating”. I’ve figured it out now but I was just curious as to what the wave looked like, so I went back to my first program where I drew sin waves. I wanted to replace y with the sin of tpf but it was unnecessary :slight_smile: