|
Post by kennn on Dec 7, 2019 7:59:10 GMT -6
In AllegroBASIC, setfps(number of frame per second) is the command. This type of command can help many users. Will there be such command in RCBasic in the future?
|
|
|
Post by n00b on Dec 7, 2019 23:23:59 GMT -6
A SetFPS function does not accomplish what you think it does. RCBasic sets the Vertical Sync flag with a window when it opens. On most displays this will be 60 FPS by default. However it could be slower or faster depending. The issue with having SetFPS is that even if you slow the rendering speed you are not slowing the rest of the program to compensate. So if you have an x-position that increases by 1 every frame. If the program is processing the new x-position every time a draw call is made but only displaying the results when ever it reaches a certain number of milliseconds you would have a character that would seem like its teleporting across the screen. tbird explained how to resolve this issue in a post a while back: Hey Johnno, I got a chance to run that code and it did not work that well so I made some changes. Try this. Dim sync_rate Dim last_sync Dim sync_delta
sync_delta = 0
Sub Set_SyncRate(r) sync_rate = r sync_delta = 1000 / r End Sub
Sub Sync_Update() Update Wait(sync_delta) End Sub
Set_SyncRate(10) He said he was getting around that 60 FPS, so I doubt it is an issue. Although implementing it isn't a bad idea anyways. I would like to point out that the way you are doing it, which is perfect for this type of game, slows down everything. Which as I said is perfect for this type of game, but for future reference to anyone reading, if you are making a complex game, you never want to use the 'wait' command. Instead I suggest using delta like so:
'Update the Delta Time
Function UpdateDelta()
DeltaTime = (Timer - TimeDelay) * 0.001
TimeDelay = Timer
End Function Then you simply call UpdateDelta() in your main loop, and for all your movement or rotation or anything that has to be 'visually' the same you: mySpeedX = 40 * DeltaTime. This way the rest of the game, AI, collision checks...etc. all run as fast as possible, only what's displayed gets slowed down.
On a side note if your doing things with forces or light physics then it's another ball park again. You get into interpolation and time stepping, much more complicated.
|
|
|
Post by kennn on Dec 8, 2019 1:01:59 GMT -6
Thanks for the detailed explanation!! The steps look complex. I really need to look into them carefully.
|
|
|
Post by rosy on Apr 25, 2021 11:54:44 GMT -6
I do not understand what's going on...
There is a rate(FPS) function in VPython which probably does what this Sync_Update() does
|
|
|
Post by aurel on Apr 25, 2021 12:26:13 GMT -6
..as nOOb explain setFPS is not universal function it is little bit easier to make it with winApi functions but with SDL i am not sure
|
|
|
Post by rosy on Apr 25, 2021 12:32:41 GMT -6
Maybe he explained, but incomprehensible to me ...
|
|