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 / First Time - Program Optimization

Author
Message
HZence
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 18th Jul 2003 08:54
Here's my question:

I'm in the midst of finishing the base engine of the current project that I'm helping with. When it comes time to release the game publicly, naturally we will want it to run equally well on all systems despite spec differences. I've never really done anything like this before, so...

Any suggestions? I'd really like some help on this - thanks in advance.
SW Games - www.freewebs.com/swgames

Yeah, I know, I only have one game. Yeah, I know it sucks. But I made it! Me!
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 18th Jul 2003 11:04
Make sure movement is based on the computer speed (using timers).
Have options for different resolutions and allow complex graphic bits to be switched on or off...

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!
HZence
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 18th Jul 2003 19:47 Edited at: 18th Jul 2003 19:47
Well, we won't need to worry about the complex graphics thing - lol.

Now, you mentioned making sure that movement is based on the system's speed using timers. Could you give me an example of this? The way that I've traditiontally done it is like this:



Thanks again, MrTAToad.

SW Games - www.freewebs.com/swgames

Yeah, I know, I only have one game. Yeah, I know it sucks. But I made it! Me!
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 18th Jul 2003 19:51
Can't we just depend on the sync rate to ensure our game looks the same speed across different computer.

I know if the computer speed is slow, it will be less likely to achieve the required sync rate. But we can't really do much on that right? i.e. the game will definitely run slower.

If the computer speed is faster, it will be synchronized with the sync rate and thus our game still maintain at the same speed we want.

Correct me if I am wrong.

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 18th Jul 2003 19:52
No, the sync rate can't be depended on, except, perhaps in FSEM, but even then other running programs could affect movement etc...

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!
HZence
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 18th Jul 2003 19:54
Thanks for clearing that up. By the way, my program uses manual sync at a rate of zero.

Hey MrTAToad, think you could answer my question then? (3rd post down from the top) Thanks!

SW Games - www.freewebs.com/swgames

Yeah, I know, I only have one game. Yeah, I know it sucks. But I made it! Me!
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 18th Jul 2003 20:01
The system I used for my abandon F-Eight game was :



Thus, it would work out like :




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!
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 18th Jul 2003 20:10
WOW! Imagine that you need to do that for every single animation or motion. Won't it be very tedious? Any shortcut? Hehe... I am always looking for neat and easy way to do things.

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
HZence
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 18th Jul 2003 20:27
Thanks Toad. And yeah, like Bulleyes said, if there are any shortcuts you'd like to let us in on, don't hesitate

SW Games - www.freewebs.com/swgames

Yeah, I know, I only have one game. Yeah, I know it sucks. But I made it! Me!
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 18th Jul 2003 20:31
The answer is:

If you want to move 1 unit per second, you do this.

Refresh = screen fps()

xratio# = 1/refresh
x# = x# + 1*xratio#

-Basically, save the screen fps() to a variable (ONLY EVER CALL SCREEN FPS() ONCE PER SYNC)
-Define all your movements to be how far to move in one second.

If you have 100FPS then the above code will run 100 times in one second. x=x+1*(1/100) when run 100 times will be equivilent to x=x+1 ran once. Basically:

x=x+1*(1/100) Ran 100 times =
x=x+1*(1/60) ran 60 times =
x=x+1*(1/1) ran once.

So to summarise that:
(1) Save Screen FPS() to a variable at the start or end of your program loop. Never ever call it more than once per loop.
(2) Make a variable TimeRatio# or something be equal to (1/ScreenRefesh)
(3) Define all your movements as how far to travel in one second.
(4) Multiply them all by TimeRatio#

It's worth point out however that although:
x=x+1*(1/100) ran 100 times
and
x=x+1*(1/20) ran 20 times

are the same, this is not ...

x=x*10*(1/100) ran 100 times
and
x=x*10*(1/20) ran 20 times.

Basically, only additions of values can be times by the ratio. Multiplications (which are more complex movements anyway) cannot.

Machine: P4 2200, 1GB RAM, GeForce4 64MB, Audigy Platinum
http://www.breakbeat-terrorism.co.uk
(It's not all about the coding)
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 18th Jul 2003 20:36
I forgot to mention though, that personally, I just set the sync rate to 60 or 100 or something, and allow screen detail to be turned on and off to reach this desired frame rate. If with all the detail switched off the comp still cant reach it, then they shouldnt be playing my game and they can suck my balls. hehehehe.!

Machine: P4 2200, 1GB RAM, GeForce4 64MB, Audigy Platinum
http://www.breakbeat-terrorism.co.uk
(It's not all about the coding)
HZence
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 18th Jul 2003 20:36
Wow, this seems even better (also I understand it more). Tell ya what. Until I finish my program, I'm going to leave all the movements the way they are. When I'm finished with my program and ready to test it on multiple systems, I'll try both of the suggestions I have so far.

Thanks again to MrTAToad and Fallout.

SW Games - www.freewebs.com/swgames

Yeah, I know, I only have one game. Yeah, I know it sucks. But I made it! Me!
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 18th Jul 2003 20:41
And unfortunately there is no shortcuts for it - its got to be done on all non-static objects.

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!
HZence
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 18th Jul 2003 21:10
Alright - thanks

SW Games - www.freewebs.com/swgames

Yeah, I know, I only have one game. Yeah, I know it sucks. But I made it! Me!
lcfcfan
23
Years of Service
User Offline
Joined: 19th Feb 2003
Location: North East, UK
Posted: 18th Jul 2003 21:44
could you use for next if u have loads of the same object like trees to do this toady?

HZence
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 18th Jul 2003 21:55 Edited at: 18th Jul 2003 21:55
I imagine you could, just utilize an array - ie have one X variable for each object, then use for/next to inc or dec the variable.

SW Games - www.freewebs.com/swgames

Yeah, I know, I only have one game. Yeah, I know it sucks. But I made it! Me!
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 18th Jul 2003 23:29 Edited at: 18th Jul 2003 23:32
Yes, FOR/NEXT would be okay if you're using arrays...

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!
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 23rd Jul 2003 10:15
I think this synchronization thingy is even more critical in a multiplayer game. Does anyone knows how to deal with the timing sync in a multiplayer networking game? It can't be the player on a fast PC will be moving like lightning, whereas the slow PC will be crawling, which makes the game unfair or imbalance.

Any ideas? Thanks!

Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
Philip
23
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 23rd Jul 2003 20:14
Bananas. They are the answer to your question.

Phil

What do you mean, bears aren't supposed to wear hats and a tie?

Login to post a reply

Server time is: 2026-07-21 20:54:15
Your offset time is: 2026-07-21 20:54:15