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.

2D All the way! / Game running too fast?

Author
Message
Lampton Worm
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 21st Mar 2004 13:04
Hi,

When working in 3d I tried to use timer based movement, but for what I'm doing in 2d I'm not catering for machines that will run my game too slow. There will be a fixed system minimum, and since my game is 2d it will be quite low anyway... so, I'm more worried about the other end of the scale, i.e. the game will run like lighting on a computer faster than my own.

Does anyone else have this issue with their 2d games? Just wondering how you get round it? I could work out the time between loops and then delay the right amount each time, a sort of timer delay then I guess as the timer is the only standard measure across all hardware.

Obviously I'll know more when I sent a demo out and everyone yells "its too fast!" or "too slow!"

Cheers.
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 21st Mar 2004 14:12 Edited at: 21st Mar 2004 14:16
Put this at the beginning of your program...
Speed = 700
t = Timer() + Speed.....start with a high number so that the text prints.


You put this by your last sync..



Repeat

If t > timer()
print "Too fast!"
endif

until t<= timer()

t = Timer() + Speed

Then keep lowering the number until the text just about dissapears.
This will make your game the same speed on all machines. Then take the print statement out. I know it works because my old programs were written on a P800, and they are still the same speed on my P1800+.


Keep lowering the number

the_winch
22
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 21st Mar 2004 14:20 Edited at: 21st Mar 2004 14:25
You can either base movement on a timer() or fps. Either of them will work if a user has a massivly faster comp than you, thats the easy bit. The problem is with slow comps.
If you use a timer() then it might not be able to execute the code fast enough so the movement will be slower.
If you use fps then as the fps drops your sprites will be moving more and more pixels at at time and can look jerky and may even jump right over other sprites you are testing for collision with.
The best way is just to run it on the slowest comp you want it to run on and see if it works. Then just warn users that if they don't meet the spec they may have problems.

I guess fps based movement is best as your users with fast comps get the smoothest possible movement where using a timer you would be holding them back to the same speed as your users with the slowest comps.

You can even mix and match controling some parts with a timer and others with the fps.

This code moves the top sprite with a timer and the bottom one based on fps, changing the sync rate isn't completly accurite but gives an idea what would happen on different speed comps.

CloseToPerfect
22
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 21st Mar 2004 16:12
if it's a action type game I use timer based movement and let the game run as fast as posible. this seems to provide smoother scrolling effects then setting a sync rate of 30 or 60 or whatever. My 8-way overhead shoot, I had a test demo of it on here, runs very smooth on all systems, rather they are reporting 40 fps of 300 fps. If you have used timer based in 3d then it's not much different in 2d.

RGT may be gone but the best DBP forum is still alive and kicking, check it out.
http://www.dannywartnaby.co.uk/rgt/
Lampton Worm
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: United Kingdom
Posted: 22nd Mar 2004 11:39
Thanks all, some good tips there Pincho, I think I'll try that way and also set a minimum sys req. for now.

Cheers.
Matinuker
21
Years of Service
User Offline
Joined: 25th Mar 2004
Location:
Posted: 25th Mar 2004 13:38
Put sleep 1 in your main loop

Paf
Matinuker
21
Years of Service
User Offline
Joined: 25th Mar 2004
Location:
Posted: 25th Mar 2004 13:39
Hi can we just use this a programming chat line?

Paf

Login to post a reply

Server time is: 2025-06-30 06:47:59
Your offset time is: 2025-06-30 06:47:59