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.

DarkBASIC Professional Discussion / Animations play at different rates per computer processor?

Author
Message
Soyuz
23
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 15th Apr 2003 03:09
I just ran a few tests for this...

It seems that by setting an object animation speed using "set object speed", the speed at which the object animates is related to the speed of the computer processor rather than tying in with the sync rate, or anything else for that matter.

This is not desirable as I want an object to complete an animation at the same point in time whether people are running a 700mhz or 2Ghz computer.

The only immediate solution I can see is for my program to run a test on a computer when the programme initiates to attempt to figure out how to adjust the "set object speed" value accordingly for that particular machine, but there must be a more logical method.

Seems odd there isn't a "set object FPS speed" instead of "set object speed". This seems a bad oversight, so I'm hoping I'm wrong.
iac249
23
Years of Service
User Offline
Joined: 26th Mar 2003
Location: USA
Posted: 15th Apr 2003 07:09 Edited at: 15th Apr 2003 07:25
You need to use the Timer() function for this.

The following code loop would process once every 20 milliseconds, regardless of cpu speed:

CloseToPerfect
23
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 15th Apr 2003 07:50 Edited at: 15th Apr 2003 07:55
well your snippet would start something every 20 millisec but that doesn't help him to regulate the speed at which a animation play out, you can interupt the object animation.
the only way I can think of doing a speed test would be playing the animation and timing it using 'object playing' to check when its done.
ass backwards way of doing it though.

CTP

iac249
23
Years of Service
User Offline
Joined: 26th Mar 2003
Location: USA
Posted: 15th Apr 2003 08:32 Edited at: 15th Apr 2003 08:33
You could use the timer() function to determine the play speed.



This is a rather rough example, but it shows the basic idea.
Danmatsuma
23
Years of Service
User Offline
Joined: 2nd Mar 2003
Location: Australia
Posted: 15th Apr 2003 08:51 Edited at: 15th Apr 2003 09:54
use set object frame instead of the loop and play commands, they're really only useful for non-crucial animations, you can make your own animation loop like:



this will keep things in time with the sync command
hope that helps

[edit]
Oh yeah, if you make the variables in that snippet floats, you can get finer control, and changing the amount you inc frame by will set your object animation speed.

you can use that code to make your own replacement functions for loop object and play object

ZX Spectrum 48k Issue 3, Radio shack Tape drive, Rank arena 12" T.V. set.
Ratty Rat
23
Years of Service
User Offline
Joined: 24th Sep 2002
Location:
Posted: 15th Apr 2003 14:19
1) Yes use Set object Frame ...
2) Remember its not just the CPU speed you have to worry about, even on the same machine the speed will vary depending on the work being done (like how much its having to display, anything else you have running, how much code is run between each sync)
3) I use a bit of code like that below on ALL animation/motion functions in my games as it creates a (pretty much) consistent speed:-



"Don`t try to engage my enthusiasm, I don`t have one"
fatbiffa
23
Years of Service
User Offline
Joined: 15th Jan 2003
Location:
Posted: 15th Apr 2003 15:41
top work fella - i realised i'd have to sync all my cycles, anims, etc
a while a go and didn't dare start tinkering without a plan...

now i got one @;0)

Soyuz
23
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 15th Apr 2003 23:26
Good stuff hombres! I had presumed using set object frame would create jerky animations but I guess since the screen will not update faster than the code can do a loop this will never be an issue.

Many thanks.
iac249
23
Years of Service
User Offline
Joined: 26th Mar 2003
Location: USA
Posted: 16th Apr 2003 03:30
The problem reminds me of when I saw someone running some ancient DOS games on one of the more recent PC's. They must have never considered "timing" issues on the CPU, because the games played so fast!
The Wendigo
23
Years of Service
User Offline
Joined: 13th Sep 2002
Location: A hole near the base of a tree in the US
Posted: 16th Apr 2003 10:07
No! Don't use Set Object Frame. I've already been down that road and the only way to get it to look nice is with object interpolation. Problem: on low end computers this works just fine, but if you are running a really fast computer, the interpolation doesn't catch fast enough or something, but basically, the animations loop between 2 key frames or so and never get to where you want. My idea, I haven't tried this yet, but try grabbing the time and setting the animation speed to what you want times the frame time.

1.00 GHZ processor, 256 MB RAM, GeForce 3 64MB, SB Live!, 8 cans of soda per day

Login to post a reply

Server time is: 2026-07-11 12:01:50
Your offset time is: 2026-07-11 12:01:50