Page 1 of 1

Slow down scrolling

Posted: Fri Feb 22, 2008 6:00 pm
by Brujah
The tiltlescreen of my game is scrolling way too fast on my new computer. On my old one it was exactely right. Same for the actual scrolling in the game.
How can I slow this down that its still scrolling fast enough on older machines but scrolls slower on faster machines?

I display it like this:

ClipSprite(#SPRITE_TILESET_SPLASH1, xxx, 0, 640, 480)
DisplaySprite(#SPRITE_TILESET_SPLASH1, 0, 0)

And I increase/decrease xxx everytime.

Posted: Fri Feb 22, 2008 6:12 pm
by Fluid Byte
Well, you need to built in same sort of frame limiting technique. For windowed mode you can use the native PB command SetFramerate() and for fullscreen games SetRefreshrate(). Be sure to check out the the remarks for each command.

Other than these two there are quite a lot of different techniques to limit the FPS to a certain rate. You may try a forum search, there should be some useful posts.

Posted: Fri Feb 22, 2008 7:16 pm
by Kaeru Gaman
you can also join the German forums, perhaps it's easier for you there... ;)

http://www.purebasic.fr/german/

Posted: Fri Feb 22, 2008 9:15 pm
by hellhound66
Removed.

Posted: Sat Mar 01, 2008 8:52 am
by lethalpolux
or the simple way, you apply a timer/flag.

global timeb.l,slow.l

slow=4

ClipSprite(#SPRITE_TILESET_SPLASH1, xxx, 0, 640, 480)
DisplaySprite(#SPRITE_TILESET_SPLASH1, 0, 0)

timeb+1
if timeb=slow
xxx+1
timeb=0
endif

with this you don't need to limit the fps and can adjust the speed for every scrolls/anims on your game.

Posted: Sat Mar 01, 2008 10:29 am
by Derek
But wouldn't this rely on the speed of the computer as it is simply a counter system, not tied into any frame refresh etc.

Posted: Sat Mar 01, 2008 12:07 pm
by Kaeru Gaman
the most simple version of a timer:

Code: Select all

#FrameDuration = 40   ; do it with 25 FPS

FrameTimer.l = ElapsedMilliseconds() + #FrameDuration

Repeat    ; permanent loop of indefinite frequency

; *****************
; setting a flag when time is over
  Action = 0
  If ElapsedMilliseconds() > FrameTimer
    FrameTimer + #FrameDuration
    Action = 1
  EndIf
; *****************

  If Action

    ; everything you want to do

  EndIf

Until EXIT
this could be added to your existing code.
just put everything from your old mainloop into the If Action condition.