Thanks everyone for your replies.
CloseToPerfect your method is interesting and I hadn't thought of doing it like that. But hey what can I say, I'm greedy and I want *everything* to run super-smooth, not just a scrolling background but my sprites too.
Anyway in case anyone's interested...here is my earlier code re-written to use a high-resolution timer (QueryPerformanceCounter). The 2D animation is much smoother, and the paddle moves at the same speed on both of my PCs even though they have different CPUs, gfx cards and vertical refresh rates.
To run this code you'll first need to install the Matrix1Utility DLL which you can find here:
http://www.matrix1.demon.co.uk/DBPro/TPCDLLS-downloads.html
hide mouse
sync on
InitialiseKernel32DLL()
NewTime as dword
OldTime as dword
DeltaTime as dword
`Set up paddle
PaddleWidth = 60
PaddleHeight = 8
box 0, 0, PaddleHeight, PaddleWidth
get image 2, 0, 0, PaddleHeight, PaddleWidth
sprite 1, (screen width() / 2) + (PaddleWidth / 2), screen height() - PaddleHeight - 30, 2 :`Center paddle near the bottom of the screen
rotate sprite 1, 90
do
`Draw background
cls
`Calculate delta time
NewTime = HiTimer(1000)
DeltaTime = (NewTime - OldTime)
OldTime = NewTime
`Update paddle position
if leftkey() then move sprite 1, -.7 * DeltaTime
if rightkey() then move sprite 1, .7 * DeltaTime
`Keep the paddle on-screen
if (sprite x (1) - PaddleWidth) < 0 then sprite 1, PaddleWidth, sprite y (1), 2
if sprite x (1) > screen width() then sprite 1, screen width(), sprite y (1), 2
`Re-draw the screen
fastsync
loop
ShutdownKernel32DLL()
end
function GetPerfClockFreq()
r as double integer
a as dword
a=make memory(8)
call dll 203, "QueryPerformanceFrequency", a
r=peek qword(a)
delete memory a
endfunction r
function GetPerfClockTick()
r as double integer
a as dword
a=make memory(8)
call dll 203, "QueryPerformanceCounter", a
r=peek qword(a)
delete memory a
endfunction r
function InitialiseKernel32DLL()
load dll "kernel32.dll", 203
endfunction
function ShutdownKernel32DLL()
delete dll 203
endfunction