The Daily Click ::. Forums ::. Klik Coding Help ::. perfectly smooth scrolling (MMF2)
 

Post Reply  Post Oekaki 
 

Posted By Message

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
19th October, 2006 at 22:42:26 -

After messing around in MMF2 for a while i decided to open a game and try to make it run better.

I discovered that matching the frames per second to your refresh rate gets you almost perfect scrolling (although that isn't exactly a discovery is it?)

And adding vsync to that gets you perfectly smooth scrolling with no 'tearing' where part of the screen is not matched up when the screen has refreshed.

I thought 'brillant ive wanted this for ages!' however.

My pc's refresh rate is 85, and i had to change my games framerate to 85 to get that smoothness.
Now as you all may know, not everyone refresh rate is 85, So i looked in the current list ofd extensions for a way to force the refresh rate to match the game so everyone can enjoy pixel perfect scrolling. However there isn't one!

so if someone was thinking of making a video releate extension (and if it's possible) could you please consider making one. Thank you.

 
.

Peblo

Custom ratings must be 50 characters or less

Registered
  05/07/2002
Points
  185

Game of the Week WinnerVIP MemberI'm on a Boat360 OwnerAttention GetterThe Cake is a LieCardboard BoxHero of TimePS3 OwnerIt's-a me, Mario!
I'm a Storm TrooperSonic SpeedStrawberryI like Aliens!Wii OwnerMushroomGhostbuster!
19th October, 2006 at 23:37:00 -

Huh... I think there was an extension to get framerate in MMF1.5, dunno about MMF2.

 
"Isn't it always amazing how we characterize a person's intelligence by how closely their thinking matches ours?"
~Belgarath

Tiles

Possibly Insane

Registered
  06/12/2002
Points
  2339

GOTM 3TH PLACE WINNER - JANUARY 2010
20th October, 2006 at 03:16:20 -

I doubt that there will be such an extension. Because when somebody usess 75 Hz, and another player uses 100 Hz, the one with 100 Hz will have the game run 1/4 faster than the one with 75 Hz. Animation speed is connected to Mainloop. Make the Mainloop faster, and the game runs faster ...

 
Free graphics,Free Games
http://www.reinerstilesets.de

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
20th October, 2006 at 06:39:59 -

I can't say I remember any problems with scrolling...

 
n/a

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
20th October, 2006 at 19:51:59 -

@Balfazar, you can change the fps anyway, i want something to change the refresh rate.

@Tiles, The extension would change the refresh rate. It doesn't matter what refresh rate the person has, the game will change it on starup.

@Klikmaster, There is no problem. But perfect syncronization would make things look better.

 
.

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
21st October, 2006 at 09:38:04 -

I think you'd be better off with an extension that could say 'the screen is running at 75fps'.

You change MMF2's frame rate to that FPS so they match, and THEN you use a custom movement with decimal values.

You work out that if you designed the game in 50fps, and it now runs at 75fps, the 'step' in your movements must simply be adjusted. Perhaps the player normally moves 0.5px per event loop?

Let's try some maths (someone correct me if this is wrong, hopefully you can see what we're trying to do here):

50fps / 75fps = 0.666667
So this will be our adjusting ratio.

0.5px * 0.666667 = 0.333333px as our new step value.

Or simply put as an equation:

Step * Design Framerate / Actual Framerate = New Step

So now, instead of moving 0.5px per loop, he moves 0.333333px per loop. Effectively, he's moving in slow motion, but the display is refreshing faster, so they appear to be the same speed as before, just smoother.


EDIT: Yup, that works. Just made a little example (not uploaded yet) which keeps objects moving at the same speed no matter what the frame rate (they'll cross the screen in the same time at 30fps as at 80fps)

Image Edited by the Author.

 
191 / 9999 * 7 + 191 * 7

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
21st October, 2006 at 12:12:00 -

The problem with changing the framerate on MMF2 games at runtime, unless to adjest for performance, is the fact that unlike in 3D games, framerate speeds the game up. It increases the number of loops produced in 1 second, and this is easyly 'purged' if you play the game on a computer that doesn't play the game as smoothly. If this was all automaticly set to the monitor refresh rate, then someone with 60hertz will play the game 'slower' then someone with 85hertz.
The framerate will match and the game will play very smoothly, yes... that's all fine and well. The entire game will slow down too though.

 
http://www.facebook.com/truediamondgame

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
21st October, 2006 at 12:48:34 -

i just realised that 60fps runs as smooth as hell too. so maybe matching the framerate to the refresh rate isn't the solution.

maybe 50fps just isn't all that smooth.

so i think my problem is solved, thanks for the help anyway!

 
.

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
21st October, 2006 at 13:04:28 -

Isn't that solved by my post above?

Or am I just misreading yours? If so, I'm very sorry


If you simply divide the framerate you designed it in by the actual framerate, you get an adjusting ratio that you can multiply into any distance that you want your objects to move.

I ran a test, and it works surprisingly well. You get objects travelling the same distance-per-second no matter what framerate you go into.

The only real problem I found is when the machine can't handle the framerate you selected. The formula thinks you must be running at 100fps, for example, and adjusts accordingly by slowing all the movements down per frame. In fact, your machine can only push so high as 60, and the objects are crawling.

To solve that, you'd need to make your app monitor the framerate and make sure it was matching closely to the framerate selected. If not, it would reduce the rate.

Image Edited by the Author.

 
191 / 9999 * 7 + 191 * 7

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
21st October, 2006 at 17:21:00 -

i think you misread,
i didn't want to change the frames per second at all. I wanted an extension that changes the current computers refresh rate.

I thought that matching the fps to the refresh rate was the only way to get perfectly smooth scrolling.

I'm not sure why, but it seems to work with 60fps (my refresh rate is 85hz)

but really i wanted smoother scrolling,

sorry if i confused anyone.

 
.

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
22nd October, 2006 at 00:35:47 -

I don't know if one is available for MMF 1.5, but I think there is one available for MMF2. One I know of is "The Big Box" extension.

I don't know if it works yet, but I know that it has an option for refresh rate changing.

 
http://www.facebook.com/truediamondgame

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
22nd October, 2006 at 03:02:44 -

Yeh The Big Box can change the refresh rate, if you're still interested in doing it anyway

 
This is a signature. Have this one on me.

Clubsoft

Administrator
Weeeeeeee

Registered
  02/12/2001
Points
  254

Acoders MemberHas Donated, Thank You!May contain nutsVIP Member360 OwnerI'm an alien!Code Monkey
22nd October, 2006 at 06:32:03 -

I will just say you need to be careful when changing refresh rates, alot of TFTs for example wont go over 60hz in their native resolution, just a heads up.. and CRTs flicker horribly at 60hz

 
.: ImageApocalyptic Coders - www.acoders.com :.

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
28th October, 2006 at 14:11:07 -

well im quite happy without vsync anyway,

thanks for the help anyway,



did anyone try out the new zeb?
that uses 100 frames per second with vsync, and on my pc at least it's got the kind of smoothness im looking for.

but with my games maybe my events aren't efficient enough because it slows down far too much.

 
.

jpSoul



Registered
  25/10/2003
Points
  1714
31st October, 2006 at 12:14:22 -

hi
if you set the framerate of your screen to 60 and your game at 60 too the screen is perfectly smooth. 100 is too much ^^
if your game has dark coulours you can set the screen at 60fps it will not do a lot a flickering; but it's more obstructing if there is bright coulours...

i am the author of the big box, it can change the display frequency but if you use this function you MUST NOT use the display options in mmf ! (like "change resolution mode" ...) because they use the same display routine (gdi).

Image Edited by the Author.

 
n/a

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
11th November, 2006 at 20:59:05 -

i figure out how to get it working now

you need to have 60 fps (or 100 will work although as you say phanoo it's overkill)

then turn on vsync but turn off directx and vram and there you go!

 
.

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
12th November, 2006 at 06:26:49 -

Could you maybe upload the source so we can test it (and steal your code )

 
n/a

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
12th November, 2006 at 11:47:52 -

no.

just test it out yourselves

 
.
   

Post Reply



 



Advertisement

Worth A Click