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 Discussion / Question about game speed

Author
Message
Aramil
21
Years of Service
User Offline
Joined: 27th Oct 2003
Location: Wherever my feet take me
Posted: 26th Jul 2004 04:27
Who has ever played any of the StarWraith games? If you have, then you know how smooth and fast it runs. In my 3D space shooter, Space Havoc 3, I have less objects, with less detail than SW, but I can't get it to run fast? Is there some secret that the maker of StarWraith uses for his game speed? Any suggestions?
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 26th Jul 2004 06:11 Edited at: 26th Jul 2004 06:12
serious optimiseation is the answer, hide what isn`t seen, switch to lower res objects at a distance, keep the textures as small as sensible, read and re-read the code for every bit you can remove or make shorter, time every loop and long calculation with the timer and see whats eating cycles, then optimise, strip out fancy stuff like realistic missile dynamics and replace them with a fudge (hack, anything that makes em behave like you want without the cpu power), strip out all sin/cos etc and replace em with lookup tables, keep the screen res as low as practicle, keep your sounds short and small, delete anything unused, make any decision check the most probable first , that way if it fails then it wont` check the rest, so nest your decisions, don`t have a whole raft of if-thens that check for all sorts of collisions with the missile, just check for a missile collision and then check what sort it is afterwards, that way you only do one check in the main loop, and when a collision occurs the delay won`t be noticed, whereas if you had a 2msec delay every loop to check all possible collisions then it would waste 1/5th sec at 100fps, but a single check that branches to the rest of the tests would use an almost immeasureably small amount of time and give you a massive speed up.

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, Nvidia FX5900 gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster.
Xander
22
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 26th Jul 2004 14:23
Nice one Mentor

A couple other things...

-When using special effects, don't bother if they won't be on the screen or if they are really far away.
-Don't grab images during the game
-Avoid 2D drawing (box, line, text) as much as possible in a 3D environment
-Re-check your 3D models for unused polygons. A space ship should only have about 500 polygons, maybe a detailed one could have 1000. Textures should be only about 256x256, maybe 512x512 for a large detailed object. However, like Mentor said, use a smaller texture for that object when it is far away.
-Don't do your large AI routines every loop. They only need to be done every half a second to every 5 seconds, depending on exactly what they are.

There is a thread at the top of the Dark Basic Classic forum by JessTicular about program speed. Check it for a lot of tips.

Good Luck

Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]
Aramil
21
Years of Service
User Offline
Joined: 27th Oct 2003
Location: Wherever my feet take me
Posted: 26th Jul 2004 23:43
Thanks!
SFSW
22
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 6th Aug 2004 02:29
Classic has been pretty good at running my complex AI routines very quickly during every main loop cycle, what really helped boost speed was two issues already mentioned: Avoid using 2D graphics as much as possible (better to render something on an object limb then in 2D) and keep the polygon counts low along with rendering as many objects as possible with only visible surfaces used (never flip the object cull setting to 0, this is a framerate killer). Only allow a cull setting of 0 for your sky-sphere/box or other objects that you must see the inside of, everything else should only have its visible surfaces rendered. Also, try to minimize the number of objects used (if you can use one object with lots of limbs for the same effect, that can help... the HUD in SW is one object with a couple dozen limbs). Hide objects when not visible or not being used (while I use about 150 objects for laser blasts, I use a sequencing routine to keep the pool of visible blasts as small as possible at all times).

A long time ago I also ran into an issue with TNL. For some reason, DB didn't seem to pick up/enable hardware TNL by default on certain cards with certain driver versions that encountered performance problems (even though the card did have hardware TNL). So just as a double-check, I usually include if tnl available()=1 then enable tnl at the beginning of my programs right after setting the screen resolution. Might do nothing for you, but it resolved some performance issues I encountered a couple of years ago (and since I've used that command in my games, the problem hasn't ever resurfaced).

Another framerate killer is the rotate limb command. Using that command just a couple of times in your routine can destroy your framerate (try to avoid ever using it, better to create a seperate object and use the object rotation commands). The scale limb command is ok, no real performance hit there, but rotating limbs greatly slows performance.

Login to post a reply

Server time is: 2025-05-25 17:15:59
Your offset time is: 2025-05-25 17:15:59