Hi everyone!
My first post here even though Ive been reading for a while.
During the pandemic I started to get into programming after like 25 years. Like many of us I first got in touch with QBasic back at school and I decided to try to get into it a bit more when I had the time.
Anyway, I have started to make a few games, or experimenting around a bit. I started on Windows 7 and it worked pretty good.
I used _LIMIT 60 to limit the frame rate and cycles/game loop to 60fps since what I want is to make games similar to the older ones, Nintendo NES-games to be specific, since I love the style.
When moving sprites i use the method of moving its position once each loop, so 60 times a second. Just doing it very simple like ball.x = (ball.x + 1) or whatever speed the ball has.
In Windows 7 it looked good, smooth movement and I did not really notice anything special.
Then, I had to change to Windows 10 for job related reasons and then I suddenly noticed that the sprites was moving jerkily.. like they moved normal speed, slowed down, normal, slowed down in some "wavy pattern" yet a bit irregular. Its hard to describe.
The project was the same so no change in my source code.
I also use _DISPLAY after the _PUTIMAGE commands, at the end of the game loop where there is a section where everything gets drawn to screen.
I tried to google the issue and found out about the windows timer resolution. I downloaded a program called "TimerToolV3" and when I set the timer to 0.5 ms the sprites move a lot better but still not perfect.
I even tried using delta time by setting a start value at the top of the game loop and one at the end and if the time was less than 1/60 it measured the time again in a small loop and exited if time was 1/60 or more. Still no luck.
So, the problem I have is that it feels like the time that I get from Windows is not consistent. It "says" to QB64 that 1 unit of time has passed but the actual time that unit was, like in real life time, varies.
This is super annoying and it makes me question my coding. I am a noob sure but limit should be consistent shouldnt it?
I also downloaded some other games that people have made in QB64 using _LIMIT and I get the same result, wavy movement.
Could it have something to do with my screen? It has 60Hz as fastest update frequency and maybe the drivers for the screen was messed up/not installed correctly again after I changed to Windows 10? Ive got the latest NVIDIA drivers.
(other real games and game emulators work good with very smooth movement though).
Im lost and need some advice here... It must be possible to get a proper timing... its also just 60fps.. Feels like I am missing something fundamental.
/ Andrew