Game is way too fast!!!!

Started by sphinx, July 05, 2019, 00:45:34

Previous topic - Next topic

sphinx

I finished adapting my classic BlitzMax game to NG and it works great in Windows in both Windowed and Full screen modes and also in both architectures (x86 and x64).

In OSX it works good in Windowed mode but works way too fast in Full screen mode, it seems as (I may be mistaken) it skips a lot of frames so it performs like crazy!!

Anyone can help?!
Kind regards,
Maher F. Farag
www.ancientsoft.com
www.osakit.com

Yellownakji

Quote from: sphinx on July 05, 2019, 00:45:34
I finished adapting my classic BlitzMax game to NG and it works great in Windows in both Windowed and Full screen modes and also in both architectures (x86 and x64).

In OSX it works good in Windowed mode but works way too fast in Full screen mode, it seems as (I may be mistaken) it skips a lot of frames so it performs like crazy!!

Anyone can help?!


Are you using a deltatimer?  You need a way to have a capacity on your framerate...  Seems your frames are uncapped.

Hezkore

#2
You should never rely on frames anyways to regulate game speed.
For example!
If you're using VSync to limit your FPS; you'd maybe get 60 FPS on most monitors.
But I'd have 144 FPS with my monitor, which means the game would be over twice as fast for me.
There are also lots of ways to force VSync off anyways.
You'll want delta time things, or use a fixed update rate, and let the game render at any FPS.
Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

sphinx

Thanks for your replies.

I will check delta timer.

I have other problem with OSX!
Inside the game ONLY, the mouse is moving the opposite directions!!!!
Any clue?!
Kind regards,
Maher F. Farag
www.ancientsoft.com
www.osakit.com

Hezkore

You should maybe isolate the issue in a separate example and post it as an issue on the NG GitHub.
Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

Derron


sphinx

Quote from: Derron on July 05, 2019, 09:43:59
https://github.com/bmx-ng/brl.mod/issues/79

And this already links to:
https://www.syntaxbomb.com/index.php/topic,4951.msg21354.html#msg21354


Brucey suggested to move to SDL.mod on Mac (GL2SDL or GLSDLGraphics).


bye
Ron

I did confirm it on the link you posted above!
And Brucey kindly informed me to move to SDL mod.
Kind regards,
Maher F. Farag
www.ancientsoft.com
www.osakit.com

sphinx

I did a delta time on my own and it works great now on OSX Windowed and Full screen:

Graphics 800, 600, 32

' ################### DELTA TIME #############################
Global FPS:Int
Global DelayTime:Int

Local Counter:Int
Local mSec:Float
While FPS < 60 '25 is the minimum acceptable FPS for my game but upto 60 FPS is great
Cls
Counter = Counter + 1
If mSec < MilliSecs()
FPS = Counter
mSec = MilliSecs() + 1000
Counter = 0
End If
DrawText FPS, -100, -100 'for some reasons fake/unrealistic FPS is returned if Cls, DrawTex and Flip are missing!!!
Flip
Wend

'16.6 is 1000ms / 60 FPS
DebugLog FPS
If FPS > 60 Then 'No delay time is required if FPS is already lower than 60 frames per second
DelayTime = Int((16.6 - (1000 / FPS)))
End If
DebugLog "Delaytime: " + DelayTime
' ###########################################################


I only needed to call 'Delay DelayTime' just after Flip command of my Main Game Loop.

Well, it works great for me but I do appreciate if anyone give me his 2 cents!
Kind regards,
Maher F. Farag
www.ancientsoft.com
www.osakit.com

Derron

Just had a quick glance but...
Isn't your code crunching in 60 renders as fast as possible and then waiting the rest (delay...) until the second is gone?

This will lead to
stop...go go go...stop
effects.


Assume one plays with a 180hz screen refresh rate.
You render your 60 flips in 0.33 seconds.
Then you delay for 0.67 seconds to fill the second.

This means for 0.67 seconds the very same screen is displayed (no movement etc).

...



Deltatiming has to do with the movement of stuff.

X = X + speed * deltaTime

So if deltatime was a whole second (1.0) then the complete speed value would be added.
Means speed (or other values) are to define as "per second".

Deltatimes are the times of the update intervals.
Normally one would even have Tweening for render interpolation... Delta for the updates (so mostly constant) and tweening for renders (which can be varying when under heavy gpu load).
To keep it easy...just use deltatiming for now and have your loop

Repeat
UpdateWorld()
RenderWorld()
Until exitApp or AppTerminate()


Bye
Ron

Hezkore

I haven't looked at the code (annoying on mobile), but it doesn't have to work like that Derron. (maybe his code does though)
But if you keep a steady "delay" between updates; you will end up with a smooth update rate.
And then just keep rendering VSynced.
But of course, all methods has its up and downsides.
What I personally don't like about delta timing values like movements and such is that if the user has a very large "lag spike" the value will end up very large.
And then the object might jump so far that it goes across the entire screen, messing up some triggers or collision along the way.
You can work around that, of course, but I feel like it's a lot of work... compared to something like a locked update rate.
Simplicity is the ultimate sophistication. 🚀
GitHub
BlitzMax for VSCode
BlitzMax for Vim

Steve Elliott

#10
Quote
What I personally don't like about delta timing values like movements and such is that if the user has a very large "lag spike" the value will end up very large.

Dude, that's why you never allow large spikes!  You set a smallish maximum value of frame change and catch-up over several frames - not one.

And fixing a frame-rate doesn't work well (not smooth) with the multiple monitor refresh rates, like 60, 75, 144 and such.

Guys here have set a fixed 60fps update and it's not smooth on my 75hz monitor.  Delta time and it would be smooth.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

sphinx

Quote
Just had a quick glance but...
Isn't your code crunching in 60 renders as fast as possible and then waiting the rest (delay...) until the second is gone?

This will lead to
stop...go go go...stop
effects.

Assume one plays with a 180hz screen refresh rate.
You render your 60 flips in 0.33 seconds.
Then you delay for 0.67 seconds to fill the second.

This means for 0.67 seconds the very same screen is displayed (no movement etc).

...
You maybe right but that does not happen with my game on 4 different machines (varying specs)


Quote
Deltatiming has to do with the movement of stuff.

X = X + speed * deltaTime
Believe it or not but that's exactly what I am trying to avoid with my game!!
Far from the headache of reviewing and adding delta timing to all update methods of the game, it will ruin some of the game working!!
I do not know how to explain it but it doesn't worth it for me :(

Anyway, thanks for your reply. I do appreciate it.
Kind regards,
Maher F. Farag
www.ancientsoft.com
www.osakit.com

sphinx

Quote from: Derron on July 05, 2019, 09:43:59
https://github.com/bmx-ng/brl.mod/issues/79

And this already links to:
https://www.syntaxbomb.com/index.php/topic,4951.msg21354.html#msg21354


Brucey suggested to move to SDL.mod on Mac (GL2SDL or GLSDLGraphics).


bye
Ron

I did a work around for this :

Local YMouse:Int

While Not KeyHit(KEY_ESCAPE)

?MacOS
YMouse= ScreenHeight - MouseY()
?Not MacOS
YMouse = MouseY()
.
.
.
Wend
Kind regards,
Maher F. Farag
www.ancientsoft.com
www.osakit.com

Yellownakji

Quote from: Steve Elliott on July 05, 2019, 17:42:58
Quote
What I personally don't like about delta timing values like movements and such is that if the user has a very large "lag spike" the value will end up very large.

Dude, that's why you never allow large spikes!  You set a smallish maximum value of frame change and catch-up over several frames - not one.

And fixing a frame-rate doesn't work well (not smooth) with the multiple monitor refresh rates, like 60, 75, 144 and such.

Guys here have set a fixed 60fps update and it's not smooth on my 75hz monitor.  Delta time and it would be smooth.

Not to mention with a delta-timer, you can easily make your game "process" at normal speed even if the game trips up and runs under target framerate. (frameskip)   Deltatimers help keep everything in sync harmony.

In my deltatimer, i have variable game speed, so that i can have slow motion and speed up as well as Framerate monitoring.  My DT allows me to run at any designed FPS on any HZ monitor nicely.

Never program without a deltatimer.  Even in my software, i cap with a deltatimer.   All my software runs at 8fps unless it's a game.

Without a deltatimer, you're basically running as many loops as possible on your machine everytime.  Wasted resources.

sphinx

Quote from: Yellownakji on July 05, 2019, 18:02:53
Quote from: Steve Elliott on July 05, 2019, 17:42:58
Quote
What I personally don't like about delta timing values like movements and such is that if the user has a very large "lag spike" the value will end up very large.

Dude, that's why you never allow large spikes!  You set a smallish maximum value of frame change and catch-up over several frames - not one.

And fixing a frame-rate doesn't work well (not smooth) with the multiple monitor refresh rates, like 60, 75, 144 and such.

Guys here have set a fixed 60fps update and it's not smooth on my 75hz monitor.  Delta time and it would be smooth.

Not to mention with a delta-timer, you can easily make your game "process" at normal speed even if the game trips up and runs under target framerate. (frameskip)   Deltatimers help keep everything in sync harmony.

In my deltatimer, i have variable game speed, so that i can have slow motion and speed up as well as Framerate monitoring.  My DT allows me to run at any designed FPS on any HZ monitor nicely.

Never program without a deltatimer.  Even in my software, i cap with a deltatimer.   All my software runs at 8fps unless it's a game.

Without a deltatimer, you're basically running as many loops as possible on your machine everytime.  Wasted resources.

Indeed, having the option to make a slow motion or fast forward of your game is a cool feature.
Kind regards,
Maher F. Farag
www.ancientsoft.com
www.osakit.com