Delta time problem
BlitzMax Forums/BlitzMax Programming/Delta time problem
| ||
I have an image moving across the bottom of the screen. When I move press the left cursor the image moves at the correct speed. When I press the right cursor the image take a second longer to travel the width of the screen. Code Below: Image type variable: Field Speed#=640/4 Image type update method: If KeyDown(KEY_LEFT) X :- self.Speed*DeltaTime EndIf If KeyDown(KEY_RIGHT) X :+ self.Speed*DeltaTime EndIf In the main loop: DeltaTime = ( MilliSecs()- TimeDelay )*0.001 TimeDelay = MilliSecs() I don't know what is going on. Thanks in advance. Mark |
| ||
I don't know from just looking at that code. The only thing I would suggest, is to make sure that DeltaTime and the X variable are float values. |
| ||
That did it, I had the X variable as an Int. How embarrassing. |
| ||
it's a common mistake.. I'm sure everybody has done a few of those.. :p |
| ||
Yeah I keep making vars that should be floats and puzzling over why the result isn't as expected. |