It depends mainly on how Delta is calculated. The simplest way is to make Delta equal to how many milliseconds have passed with something like this
NewTime = Millisecs()
Delta = NewTime - OldTime
OldTime = NewTime Then you would multiply that by a factor which is determined by how much you want something to move each millisecond. For example, if you want the screen to scroll 100 pixels per second, that'll be 0.1 pixels per millisecond. Since you will be using fractional numbers, you must make sure your variables are declared as real with #,Float, or double.
ScrollX# :+ 0.1 * Delta If you don't decalre the variables as real, then most likely your objects won't be updated properly, if at all. Now there are a couple of disadvantages to this method, one being that when the internal clock rolls over, which happens when the computer hasn't been rebooted in several days, then you have to start dealing with negative Delta. Also, if some background task starts hogging the CPU, you will get sudden jerks in the animation. There are algorithms floating around that will take care of both problems, just do a search.
|