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 / How to make the game run at the same speed in every cpu?

Author
Message
3dZmaster
23
Years of Service
User Offline
Joined: 30th Jun 2003
Location: Finland
Posted: 16th Jul 2003 18:03
Ok, I saw this question been asked, but I can't find it anywhere now. Somebody answered "with timer function". Then he gave a website where this was explained. What was this website?
Current project: Dodge Viper Car Game (Not named yet) Other car models are going to be included soon
Philip
23
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 16th Jul 2003 18:43
I think the sync command may do a better job. I've read a few threads that suggest the timer function is not consistent between cpus

I'll leave the gurus on here to explain

Phil

What do you mean, bears aren't supposed to wear hats and a tie?
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 16th Jul 2003 18:53
You need a sync command plus a timer. IanM has a high precision timer on his web site.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins and other exciting things - oh my, yes!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Jul 2003 21:30
The TIMER() function is accurate - the problems are with the way people try to use it, and their assumptions about the way windows works.

But by all means use my high resolution timer - you can use it to get a 'tick' at any frequency you wish ... as long as the frequency is greater than 1Hz ... hmmm, I might fix that so you can have a tick frequency of less than 1
3dZmaster
23
Years of Service
User Offline
Joined: 30th Jun 2003
Location: Finland
Posted: 16th Jul 2003 21:32
So what is your website?

Current project: Dodge Viper Car Game (Not named yet) Other car models are going to be included soon
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Jul 2003 21:44
Well, you see that big button under my last post and this one, with 'WWW' on it ...
MikeS
Retired Moderator
23
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: United States
Posted: 16th Jul 2003 21:44
http://www.matrix1.demon.co.uk/

It's right under his post. the "www" sign.



Yellow:Wanna publish my game microsoft, cuz i no u rich so...Can I have my bag of money now?
Microsoft: *snicker* Tip of the month-Microsoft will never(probebly) publish your game.
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 16th Jul 2003 21:50
Quote: "Well, you see that big button under my last post and this one, with 'WWW' on it"


...and I thought I was the only sarcastic person around here...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins and other exciting things - oh my, yes!
iaretony
23
Years of Service
User Offline
Joined: 6th Jun 2003
Location:
Posted: 16th Jul 2003 22:07
The real trick is to stop thinking about moving you're sprites or objects a certain amount per frame, and start thinking about moving you're sprites or objects a certain amount per timeslice (IE, speed).

For instance, imagine a simple top down car driving game. In this game, you know how fast you're car is traveling, in miles per hour.

Notice that this is a unit of distance per a unit of time.

The first thing you're going to need to figure out is the amount of time that has elapsed since your last time through the main loop. You can do this by simply subtracting from the current time, the time you last ran through the loop. This elapsed time is going to be some fraction of a second (so you'l need to store it in a variable that can store values smaller than one, IE float)

Next, you convert MPH into miles per milisecond:

60*60*1000 = milliseconds per hour

Now, to figure out what fraction of a mile you need to move you're car this timeslice you simply multiply you're "elapsed time" by you're milliseconds per hour.

Now, all that is left is to convert you're "miles" into some number of pixels. This part is real easy, you can say that any number of pixles you want equals 1 mile, you must simply remember to be consistent.

Does this help?

Tony

3dZmaster
23
Years of Service
User Offline
Joined: 30th Jun 2003
Location: Finland
Posted: 16th Jul 2003 22:11
Hope it does. Yeah, thanx to all.

Current project: Dodge Viper Car Game (Not named yet) Other car models are going to be included soon
3dZmaster
23
Years of Service
User Offline
Joined: 30th Jun 2003
Location: Finland
Posted: 16th Jul 2003 22:30
How can I use these plug-ins on your web site IanM? I mean, I know where to put the help and other stuff, but does the dlls goes and what to do to activate them?

Current project: Dodge Viper Car Game (Not named yet) Other car models are going to be included soon
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Jul 2003 23:10
From your DBPro folder in program groups:

Put the DLL in Compiler\plugins-user
Put the ini in Editor\Keywords

Nothing else is required, except for editor version 1.09b and DBPro Patch 4.1
3dZmaster
23
Years of Service
User Offline
Joined: 30th Jun 2003
Location: Finland
Posted: 16th Jul 2003 23:27
OK. Thanx. You are great!

Current project: Dodge Viper Car Game (Not named yet) Other car models are going to be included soon
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Jul 2003 23:47 Edited at: 16th Jul 2003 23:48
I know ... OMG, I'm turning into toady
3dZmaster
23
Years of Service
User Offline
Joined: 30th Jun 2003
Location: Finland
Posted: 17th Jul 2003 00:57 Edited at: 17th Jul 2003 00:57
Hey!!! Should the help files appear at the index? Didn't happen! What am I doing wrong? I unrared the helpfiles into the folder Dark Basic PRO\Help\Commands

Current project: Dodge Viper Car Game (Not named yet) Other car models are going to be included soon
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 17th Jul 2003 01:01
Quote: "I'm turning into toady"

Nothing wrong with that...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins and other exciting things - oh my, yes!
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Jul 2003 01:38
Yeah? Let's take a vote on that

3dZmaster: Sorry, but there are no help files provided, except for what appears in the readme.txt ... I can't be bothered with all that HTML nonsense - it's taken me over half a year to get my site to where it's at
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 17th Jul 2003 01:57
I'll vote for that...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins and other exciting things - oh my, yes!

Login to post a reply

Server time is: 2026-07-21 12:49:17
Your offset time is: 2026-07-21 12:49:17