December 09, 2019, 10:18:17 PM

Author Topic: Game is way too fast!!!!  (Read 979 times)

Offline sphinx

  • Full Member
  • ***
  • Posts: 207
    • Ancientsoft
Game is way too fast!!!!
« on: July 05, 2019, 12:45:34 AM »
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

Offline Yellownakji

  • Full Member
  • ***
  • Posts: 247
  • No.
Re: Game is way too fast!!!!
« Reply #1 on: July 05, 2019, 01:11:28 AM »
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.

Offline Hezkore

  • Jr. Member
  • **
  • Posts: 86
  • 🍑 Juicy
Re: Game is way too fast!!!!
« Reply #2 on: July 05, 2019, 01:38:31 AM »
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.
Keep it simple.

Offline sphinx

  • Full Member
  • ***
  • Posts: 207
    • Ancientsoft
Re: Game is way too fast!!!!
« Reply #3 on: July 05, 2019, 04:25:22 AM »
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

Offline Hezkore

  • Jr. Member
  • **
  • Posts: 86
  • 🍑 Juicy
Re: Game is way too fast!!!!
« Reply #4 on: July 05, 2019, 09:29:38 AM »
You should maybe isolate the issue in a separate example and post it as an issue on the NG GitHub.
Keep it simple.

Offline Derron

  • Hero Member
  • *****
  • Posts: 2609
Re: Game is way too fast!!!!
« Reply #5 on: July 05, 2019, 09:43:59 AM »
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

Offline sphinx

  • Full Member
  • ***
  • Posts: 207
    • Ancientsoft
Re: Game is way too fast!!!!
« Reply #6 on: July 05, 2019, 01:20:09 PM »
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

Offline sphinx

  • Full Member
  • ***
  • Posts: 207
    • Ancientsoft
Re: Game is way too fast!!!!
« Reply #7 on: July 05, 2019, 01:23:39 PM »
I did a delta time on my own and it works great now on OSX Windowed and Full screen:

Code: [Select]
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

Offline Derron

  • Hero Member
  • *****
  • Posts: 2609
Re: Game is way too fast!!!!
« Reply #8 on: July 05, 2019, 03:49:14 PM »
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

Offline Hezkore

  • Jr. Member
  • **
  • Posts: 86
  • 🍑 Juicy
Re: Game is way too fast!!!!
« Reply #9 on: July 05, 2019, 04:36:27 PM »
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.
Keep it simple.

Online Steve Elliott

  • Hero Member
  • *****
  • Posts: 2117
  • elgol developer
Re: Game is way too fast!!!!
« Reply #10 on: July 05, 2019, 05:42:58 PM »
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.
Windows 10, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
MacOS Mojave, 64-bit, 8Gb RAM, CPU Intel i5, 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB.
Linux Mint 19.2, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
Raspberry pi4 4Gb RAM

Offline sphinx

  • Full Member
  • ***
  • Posts: 207
    • Ancientsoft
Re: Game is way too fast!!!!
« Reply #11 on: July 05, 2019, 05:57:08 PM »
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

Offline sphinx

  • Full Member
  • ***
  • Posts: 207
    • Ancientsoft
Re: Game is way too fast!!!!
« Reply #12 on: July 05, 2019, 06:01:37 PM »
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 :
Code: [Select]
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

Offline Yellownakji

  • Full Member
  • ***
  • Posts: 247
  • No.
Re: Game is way too fast!!!!
« Reply #13 on: July 05, 2019, 06:02:53 PM »
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.

Offline sphinx

  • Full Member
  • ***
  • Posts: 207
    • Ancientsoft
Re: Game is way too fast!!!!
« Reply #14 on: July 05, 2019, 06:08:14 PM »
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