Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / help with slow sprite "refresh rate" at 60 fps

Author
Message
noobnerd
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 23rd Dec 2010 14:24 Edited at: 23rd Dec 2010 14:25
hi although it is impossible to show in images, the base sprite here ( the big greyblue one) moves oddly, it refreshes itself like 4 times / second while everything else goes smoothly. i had the same problem when trying to make the asteroids move around at different speeds to simulate 3D in 2D, it seems weird that the big sprite should refresh slowly , when the game is running at 60 fps ? some help here please.
the refresh starts from the bottom of the sprite and moves upward, but i have been unable to catch that on a screenshot
Lucas Tiridath
AGK Developer
17
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 23rd Dec 2010 14:53
Can we see your code for this? Might help us find the prob. Nice graphics btw.
noobnerd
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 23rd Dec 2010 15:30 Edited at: 23rd Dec 2010 15:31
the game can be found here http://forum.thegamecreators.com/?m=forum_view&t=178440&b=5 the source is included, hope that sheds some light on it the code is abit messy, its my first game and i have only cleaned it once. the important ( i think ) parts of it are:



where sprite 300000 is the base, xd# is the x distance you have "moved" ( used to move everything else )
oh and the base sprite isnt finnished
BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 23rd Dec 2010 20:45 Edited at: 23rd Dec 2010 23:09
The desktop width() method seems to always work for me.
Actually I will try compiling your source code with my own set display mode command.

So, I compiled your code after downloading the txt.ttf font from your other post.

I do see what you are talking about, it is not a refresh problem.
What you are seeing is called video tearing.

Everything on the game screen is refreshing at the same rate, on my laptop it is 480fps.
My laptop screen refresh rate is 60fps, so the game refresh rate (frames per second) is out of sync with my laptop screen refresh, which causes the tearing that you are seeing.
Actually the asteroid backdrop also tears the same way, just less visible.

So if you will put this: set display mode desktop width(),desktop height(),32,1
at the top of your code, the tearing will go away.
The 1 at the end causes the game to VSYNC to the computer screens refresh rate.
Unfortunately, this will cause your game loops to run at the computers screen refresh rate, in my case 60fps.
In most cases 60 loops through your game code/per second is fast enough.
If you want more loops through your game code check out the decouple the display loop discussion if the DBPro forum, but it is a little more advanced technique, but not too bad.
http://forum.thegamecreators.com/?m=forum_view&t=175312&b=1

I think you will be fine just setting the VSync setting in the set display mode to 1 for now.

BTW, nice work on your game!
noobnerd
15
Years of Service
User Offline
Joined: 30th Nov 2010
Location:
Posted: 23rd Dec 2010 23:13
thanks ! Yea i know vsync, had it in older version, took it away because the set display mode command made the startup look odd , used the settings instead. Seems i will use vsync in the future too thanks for the help and the compliments

Login to post a reply

Server time is: 2026-07-21 20:35:31
Your offset time is: 2026-07-21 20:35:31