Page 1 of 1

Posted: Thu Jan 09, 2003 10:11 pm
by BackupUser
Restored from previous forum. Originally posted by FlixFlax.

Hi
I'm writing a pacman-game (what else?), but how do I make
the movementspeed the same on a slower comp than my own ?
(so the game looks and "feels" the same)
I have read somewhere, that the x- and y increments must be
adjusted :

fx :
on my comp x_pacman = x_pacman+1.0
on another comp x_pacman = x_pacman+1.5

This is also related to the screen-update frequens, and my
question is how to compensate for this and the overall speed
of the comp ?

Hope you can help me with this.

Posted: Thu Jan 09, 2003 10:15 pm
by BackupUser
Restored from previous forum. Originally posted by PB.

> on my comp x_pacman = x_pacman+1.0
> on another comp x_pacman = x_pacman+1.5

Never use maths like that to fix the speed, because different CPUs
will still give too fast or too slow results. You normally have to
use delays based on the system clock, or vertical blanking of the
screen. I'm sure someone with more experience will answer this for
you very soon.

Posted: Thu Jan 09, 2003 10:39 pm
by BackupUser
Restored from previous forum. Originally posted by Kale.

or maybe use 'SetFrameRate(#)'

--Kale

Getting used to PureBasic and falling in Love! :)

Posted: Thu Jan 09, 2003 10:45 pm
by BackupUser
Restored from previous forum. Originally posted by FlixFlax.

Hi PB
Thanks for your quick reply.

But I didnt mean that the "1.5-increment" should be a fixed
value for all machines. It should be a different number on
the different comps. So you could compensate for the speed-
difference. Does that make any sense ?

Posted: Thu Jan 09, 2003 10:53 pm
by BackupUser
Restored from previous forum. Originally posted by PB.

> I didnt mean that the "1.5-increment" should be a fixed
> value for all machines. It should be a different number on
> the different comps.

But there's so many millions of different comps out there -- you can't
use a different number for each one. That's why I said you shouldn't
use maths to do it. I haven't coded any games, but SetFrameRate(),
as Kale said, would probably do it. If not, use the PC's clock to fix
the speed, as the clock isn't affected by the CPU of the PC.

Posted: Thu Jan 09, 2003 10:53 pm
by BackupUser
Restored from previous forum. Originally posted by FlixFlax.

Hi Kyle.

Hmmm... havent tried that fellow ! But what does it mean ? This is from the help-file :
Set the frame rate (in frames per second) for the current screen. This is especially useful for windowed screen mode.

I dont think that I simply can set the framerate as I wish. It must have something to do
with "computing-power" . Or ?....

Posted: Thu Jan 09, 2003 11:42 pm
by BackupUser
Restored from previous forum. Originally posted by dmoc.

distance moved = velocity x time

So if you measure the time between frames (or each loop of your game engine) and use velocities instead of absolute (or incremental) distances then game speed is constant and independent of the processor speed.

Edit: Just for completeness: distance = velocity x delta-time

Use a scheme like this (pseudo-code)...

t1=time()
do
dt = time-t1
t1 = time()

dx = vx * dt
x = x + dx

(rest of your code)
loop

Posted: Fri Jan 10, 2003 12:06 am
by BackupUser
Restored from previous forum. Originally posted by Franco.

Hey guy's we had this already:
viewtopic.php?t=3708

Sorry, but... why not search in the forum and then, if nothing is found, ask for it :)

I did -> Search: same speed game

I suppose you can do it too :)

Have a nice day...

Franco

Posted: Fri Jan 10, 2003 12:49 pm
by BackupUser
Restored from previous forum. Originally posted by Kale.

here is something i've used alot in DarkBasic to optimise and time things correctly, it should be pretty easy to convert the code mentioned using the above commands. It details a method called 'Forced Timing'.

http://www.garyw.uklinux.net/DB/optimisations.txt

pretty much the same as mentioned here:

viewtopic.php?t=3708

--Kale

Getting used to PureBasic and falling in Love! :)

Posted: Fri Jan 10, 2003 3:55 pm
by BackupUser
Restored from previous forum. Originally posted by fred.

In fullscreen mode the frame rate is always limited by the monitor refresh rate. You can use SetRefreshRate() to fix the refresh rate to 60hz for example and have your game running smoothly @ 60 fps. If this don't work (some card/monitor can reject it), OpenScreen will return 0 and then you can set the refresh rate to 0 and use SetFrameRate() to 60. SetFrameRate() always work and use an high precision timer.

Fred - AlphaSND

Posted: Sat Jan 11, 2003 12:50 am
by BackupUser
Restored from previous forum. Originally posted by FlixFlax.

Thanks to all of you for your help.

Please correct me if I'm wrong when I interpret your answers like this :

FIRST I must set the framerate to 60 Hz (low number, so all machines can cope with it)

AND THEN I can do the coding, that dmoc,Franco and Kale pointed at.

Franco, you are ofcause right, when you ask me to search the forum first. But on the other hand, after some time when the forum had grown very big, it would no longer be a forum, but a database, and the
"social aspect" would be gone. - very sad :)
- And I would not have learnt about the SetFrameRate()-thing.
(if I understand it right)

greetings

Posted: Sat Jan 11, 2003 1:37 am
by BackupUser
Restored from previous forum. Originally posted by Kale.
FIRST I must set the framerate to 60 Hz
This is incorrect, let me waffle on a bit :)

The frame rate is measured in frames per second, this is how many times the cpu/gpu sends an image to the monitor.

the refresh rate is how many times the monitor is updated from the graphic card (measured in Hz (changes/cycles per second)). Usually people only refer to the vertical refresh rate, the minimum monitors seem to display is 60. If you look at your monitor carefully the picture is made up of horizontal raster lines drawn from left to right then down, so if you have a resolution of 800x600 this draws 800 pixels across from pos 0,0 to 0,800 then moves to 1,0 and continues to draw each line. The value 60Hz means it draws the whole monitor image 60 times a second. Health and safety says (UK) that you shouldn't work with monitor screen with less than a 72Hz vertical refresh rate, because it can give you headaches because you can almost see the drawing operations and it kinda flickers.

You can set the framerate higher than the refreshrate as is done in most 3d games but if vertical sync is disabled you will see 'visual tearing' across the screen, this is because the screen is being updated faster than the monitor can display but its not that noticable. If vertical sync is enabled the framerate is syncronised to the refreshrate allowing a rock solid display with no tearing sacrificing a few frames per second. This is what fred was on about setting the framerate and refreshrate the same, i guess going for 60 is the lowest common denominator.

Maybe a routine could be written to detect supported refresh rates before the engine is initialised? ...just a thought.

well i'm a little drunk and ready for bed, i hope i made sense and explained it a little clearer to you about the differences of framerate and refreshrate :) ...infact i hope what i've said is true, he he...

night night...

--Kale

Getting used to PureBasic and falling in Love! :)

Posted: Sat Jan 11, 2003 10:00 am
by BackupUser
Restored from previous forum. Originally posted by FlixFlax.

Hi Kale

Hope your head is ok today :)

You are right. I mixed up the refreshrate and framerate in my last post. But if we substitute "framerate" with "refreshrate" is it then correct ?

//
FIRST I must set the refreshrate to 60 Hz (low number, so all machines can cope with it)

AND THEN I can do the coding, that dmoc,Franco and Kale pointed at.
//

Does the refreshrate>72Hz also count for games, or is it only textapps ? I mean, a TV is = 50Hz (in DK)

Posted: Sat Jan 11, 2003 5:59 pm
by BackupUser
Restored from previous forum. Originally posted by Kale.

72Hz only seems to be for VDU's (Video Display Units) in the workplace.

Oh and my heads fine, ta :)

--Kale

Getting used to PureBasic and falling in Love! :)