Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] Timer Based Inc/Dec

Author
Message
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 19th Nov 2008 22:04 Edited at: 20th Nov 2008 01:51
Hi guy's, I made a function that handles increasing and decreasing of values via timers. So say I wanted to move and object from point 'A' to point 'B', I could setup a timer and set how long it would take in seconds, when I want to start it I just return the timer to the object position, easy.

So the code and demo:


I also put together a little sprite demo to test how efficient this is and the results are amazing.



Here's the Cool Demo: Edit cMYSPRITE_COUNT to increase/decrease the amount of sprites.


Now I set cMYSPRITE_COUNT to 512 for a real test and got round: 164 fps

That's 512 sprites each with 3 timers (1536 timers) that all randomally changing and are being tracked, I'd have to say that pretty damn good.

Enjoy

Note: if any of the code seems oddly indented, it's the forums fault.

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Anonymous User
16
Years of Service
User Offline
Joined: 21st Feb 2008
Location:
Posted: 22nd Nov 2008 09:46
Thanks for this, you saved me from coding the same thing for my fade in - fade out grayscale shader

???
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 24th Nov 2008 01:56 Edited at: 24th Nov 2008 01:56
No prob Anonymous, still need to add a ton of stuff though, like Reverse, Pause, Delay, Stop, Restart, Curve, I wonder what else?

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 18th Dec 2008 17:35
You'd think more people would need something like this, I guess not

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 19th Dec 2008 04:55
Quote: "You'd think more people would need something like this, I guess not "


Ehh, don't feel bad. Code Snippets gets VERY little views and replies. This looks pretty useful.

wildbill
18
Years of Service
User Offline
Joined: 14th Apr 2006
Location:
Posted: 19th Dec 2008 18:34
Just tried the demo and changed the sprite cap to 500. Still had over 100 fps. Very useful, thanks.
Sasuke
18
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 22nd Dec 2008 16:13
Quote: "Code Snippets gets VERY little views and replies"

Are well....

Anyway, thanks guy's, will update this soon to add more functionality, so you can do more object timer movement stuff

A dream is a fantasy, if you achieve that fantasy it was never a dream to begin with.

Login to post a reply

Server time is: 2024-11-22 07:59:59
Your offset time is: 2024-11-22 07:59:59