Ooops
January 26, 2021, 12:30:59 PM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Algorithms
»
[bb] Timescale by Streaksy [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] Timescale by Streaksy [ 1+ years ago ] (Read 458 times)
BlitzBot
Jr. Member
Posts: 1
[bb] Timescale by Streaksy [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:38 AM »
Title :
Timescale
Author :
Streaksy
Posted :
1+ years ago
Description :
Put SyncLagScale in your main loop, and multiply every movement by Timescale#, and it'll move fluidly. I've found this extremely useful. It's an alternative to using frame-limitting timers.
You can even use SetTimeScale(s#) to control the speed of time.
Enjoy >D
(Code archive contribution #4)
Code :
Code: BlitzBasic
Global
TimeScale#,LagScale#,TimeScaleMul#=
1
,TimeScaleLastTime
;TIMESCALING
Global
TimeScaleLibPresent=
1
Function
SyncLagScale
(
)
tim=
MilliSecs
(
)
timepassed#=tim-TimeScaleLastTime
If
TimeScaleLastTime=
0
Then
lagscale=
1
Else
lagscale=
(
timepassed/
1000
)
*
50
TimeScaleLastTime=tim
timescale=lagscale*timescalemul:
If
timescale>
6
Then
timescale=
6
If
timescale>
20
Then
timescale=
1
;okay thats alot... lets treat it like a delay rather than an example of framerate
End Function
Function
SetTimeScale
(
s#
)
timescalemul=s
End Function
Comments :
Serpent(Posted 1+ years ago)
I've been thinking for a while about doing something like this in a game - any frame rate would be supported and lag would be accounted for, which would be very useful in multiplayer games in that computers stay in sync despite one computer lagging more than the other.I was going to comment on how you should limit the scaling, but I see that you've already accounted to this. Nicely done and useful. Thanks for posting.
Streaksy(Posted 1+ years ago)
Thanks again serpent =D
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Algorithms
»
[bb] Timescale by Streaksy [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal