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 / After advice on speeding the game up DBC

Author
Message
Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 24th Jul 2007 02:30 Edited at: 24th Jul 2007 02:32
Hi, I read through most of the posts in the "how to speed your game up" sticky which have helped but am still hitting performance issues that are really slowing down my 3D space game (which works on a 2D (X,Y) plane - i.e Z = 0 always). I get 30 FPS on my 1.6Ghz laptop, when only my ship is in screen but once planets and other ships appear, and especially when explosion frames are loaded into plains the FPS drops to 19. It will drop even further when I include an attack routine and particle emission effects! Now here is a general description of my routine and I am hoping someone might be able to point out what might be the most FPS consuming aspect (along with a possible remedy).

Sync on
Sync rate 0
Sync once per loop

in the main loop

Do
textured a 3D plain with a space nebula image, positioning the plain whereever the players ship goes and scrolling the texture to give the movement effect.

placing another 3D plain near the foot of the screen which operates kind of as a HUD. On it I draw several boxes to represent shields, hull strength fuel levels etc), and I draw a circle for the radar. Now I use dots (dot X,Y) to represent ships on the radar but draw small circles to represent planets (and this seems to really slow down things) - any ideas to speed things up here (should I use say spheres - not DBs as I gather these are bad for performance).

Next I do a test to see if any of the 10 other NPC ships (polys are about 500-600 per ship which I dont think is a problem but let me know if you disagree) are on screen, if not then I hide them (same with planets). The ships go through a routine to update their position. At the minute all they do is fly from planet to planet - I havent even coded a routine yet to get them to attack, nor have I included animations yet for thruster emitions. No doubt when I do allow for this, the FPS will slow down to 10 mabye if I am lucky!
For thruster emitions, I was thinking of creating tiny spheres and randomly colouring them (redish-blue) to expell from the rear of the ship as emission effects. I suspect this is a bad idea and should probably look to blender or anim8or say to produce particle emissions frames.

I do another check for bullets which is this. Each ship can have a maximum of 16 lasers (or bullets as i define them) on screen at one time
Bullet1#(ShipNo,IsitActive?,XPos,Ypos,Damage,timer)...Bullet16#(... etc). If a Bullet is active then it goes to a subroutine, updates and checks for collisions. Its occurred to me this maybe isnt the best approach. I though of just having one array for bullets - the trouble is I cant see how to easily solve for the following. When a bullet disapear from range (and is deleted), then when the next bullet is fired, I need to go through the whole array to find the next bullet which will take up time.

One thing that occurred to me when reading the sticky thread on speeding up your game, is that when a ship blows up, I alter the X:Y ratio of the explosion plain depending upone the size and shape of the ship. e.g. if the ship is long and skinny, then I do, make object plain ObjNo,20,100. Then I texture the object with the different explosion frames. I wonder if because the texture has to "contort" itself to fit into the plain, does this cause a huge performance hit?

On another note, I find DBC crashes alot (maybe 1 time in every 5 that I run my program) and I suspect its due to the DOGA L3 models I am using. Someone told me that DBC doesnt support certain features of Direct 9x from which some of the parts DOGA L3 depends. DOGA L3 contains various ship parts and I "stick" them together in DOGA L3 before exporting to .x files. Its weird because I know some parts of DOGA L3 crash every time I import them, some others never do, and with the rest it seems to be probability based!! E.g. I import a model and to test it I load and delete it in a For / Next loop say 100 times. DBC crashes sometimes after the 10th loop, other times the 50th - just seems random. Has anyone else come accross this and if so is there a way to import .x files into another modelling program (to clean them up from Direc 9x support) so I can re-export them as .x files that DBC will like 100% of the time?

Sorry, this is a longwinded post - thanks for your patience and any advice you might have.
FERSIS
20
Years of Service
User Offline
Joined: 17th May 2006
Location:
Posted: 24th Jul 2007 03:25
Did you try with backdrop off ?
it usually gives a couple of FPS extra
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 24th Jul 2007 03:56
@Hangar18

Hello,

Well, a major slow down in any program are nested loops. If you are running through separate loops to handle all of your updates (planet, ship positions, whether an object is hidden or not, etc.) this will definately eat processing time. If you can find a way to update one thing at a time with each iteration of the main loop, or stagger some of the updates for say, every third iteration of the main loop, your game speed should increase.

If you have a lot of bitmap screen active where you are drawing things in the background, that will sap speed.

Quote: "Then I texture the object with the different explosion frames. I wonder if because the texture has to "contort" itself to fit into the plain, does this cause a huge performance hit?"


In general, once you make an object of a particluar size and shape, it is set up with UV coordiates that basically describe how to stretch a texture over it. The texture's properties don't change, it stays as it is. The object UV coords will handle whether the texture is painted oblong or not. Depending on the size of your textures, cycling them will slow performance.

Are your explosion images predefined or are you capturing the images or loading them each time you are using them? I wonder if you could just create a small avi of the explosion and position it. I don't know how that would affect performance.

There's a bit of a misconception in regards to polygon count and frames per second. While there is a correlation: as the polygon count goes up, the frame rate goes down - it doesn't describe the whole picture. If you are to create a single cube, you have 12 polygons. If you create six planes, you have 12 polygons, but a lower frame rate. The reason being is each object is "indexed" in memory. To draw 6 separate planes, the processor has to cycle through memory addresses and render each plane. With the cube, it only has to check one index. Also, in general, you will have 24 different vertices for the 6 plains and possibly only 8 for the cube - the faces will be reusing vertices.

I ran a series of tests on matrices versus directx object grids, vs plains, vs triangles - (this being only a brief recap of the data) that more objects with relative polygon counts affect the frame rate more than single objects with higher polygon counts. Matrices and grid objects perform almost identically as the number of grid squares increase.

Quote: "if so is there a way to import .x files into another modelling program (to clean them up from Direc 9x support) so I can re-export them as .x files that DBC will like 100% of the time?"


If the directx file is causing a severe exception, (I'm not sure what you mean by crashing) in DBC - I've usually seen this as a result of inconsistant frame handling in the directx file itself. When I created my DBC exporter for Blender and also one for Anim8or, I found DBC was very particular about how the frames were set up and handled (A Frame in a directx file is like a box that holds all of the mesh information and also is referenced by any animation - it's basically the definition of a limb.) Depending on how DOGA creates it's export, there may be issues.

If your models aren't animated, I've always had great success in importing directx models into Deled 3d and then exporting them back out with Deleds X exporter. They seem to work flawlessly with DBC. But I haven't updated Deled 3d in about 8 months.


Quote: "Next I do a test to see if any of the 10 other NPC ships (polys are about 500-600 per ship which I dont think is a problem but let me know if you disagree) are on screen, if not then I hide them (same with planets). "


Perhaps hide the 10 ships from the get go and don't do any tests to update them. Create a random routine that positions the ships at some planet. Also have another routine that randomly selects 2 or three of the ships to attack or whatever when your ship is a certain distance from somewhere or something. Keep the whereabouts and what ships will attack in an array(s) and only make them appear or update their popsition when your ship has entered a "danger zone". This way, your program never has manage the enemy ships until your ship's position triggers something to happen. And when it does, the program will only deal with the two or three ships you have stored in the attack array - instead of cycling through all 10.

The bullet thing, well if the bullets are objects, their position is already stored in OBJECT POSITION. I created a rain function and it ran through a loop of all the rain drops (if they weren't onscreen they weren't visible). When the rain drop reached a certain ground height, it's position was reset to somewhere up above. A variation of this would be to have the function triggered by a trigger pull (mouse click or whatever), one of the parameters being the start number of a bullet, and then increasing the bullet number (up to 16) as long as the the trigger is pulled (thus going through the loop). At 16, the function always returns so it doesn't stay in an infinite loops and returns the last bullet fired (so you could actually leave the function after say 5 shots were fired). You could reseed the function with the last shot so you can get the correct position updates. This probably doesn't make sense as I'm getting very sleepy. Anyway, that's it for now... can't type anymore.

Enjoy your day.
Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 24th Jul 2007 06:39
@ Fersis: Thanks didnt know that and will give it a try.

@ Latch: Thanks for all your advice. I will definitely try exporting into and out of Deled 3D in the hope it will "clean" the models. Good idea re: not updating everything every sync will try experimenting with that too.

My bullet routine probably needs revamping somewhat although I'm inclined to believe its not going to make much diff because I disabled its routine along with some others in an experiment to see the diff it made - all of 1 FPS - LOL. I'm wondering though if its the DOGA L3 models that are slowing things up. The reason I say that is this - There was one particular model that caused DB to crash frequently but when DB "accepted" the load, it would run real slow. Hopefully Deled can fix this problem. Also when I said crash, I meant "this program has encountered an error and has to close, please contact microsoft for help" sort of crash although I do occaisonally get a "severe exception" error crash too.

Another thing I forgot to mention is that some of my explosion animations arent 100% black round the flames so typing set object Obno 1,0,1 to make black parts transparent isnt as effective as it I'd like. Is there any easy way to make this better?

Cheers
TDK
Retired Moderator
23
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 24th Jul 2007 07:26
What graphics chipset is in your laptop?

Some can very quickly get bogged down when using DB - especially those with SiS chipsets.

I know because I was daft enough to buy one!

Mine is a P4 2.6Gig with 512MB, but the SiS GFX card, despite being 3D, doesn't need much in DBC before it grinds to a halt.

TDK_Man

Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 24th Jul 2007 09:27
Yes very good point! its actually one that work gave me to enable working from home (financial modelling in XL sheets and the like) and the like so the graphics card is likely to be very basic. I suspect its just the vga default. However I have a 3.0 Ghz with a decent card in the study that I will try out. The laptop though is just so hand to whip out and it keeps the wife happy if I can sit with her in the lounge while programming.
Anto
20
Years of Service
User Offline
Joined: 30th Oct 2005
Location: Brisbane, AUS
Posted: 24th Jul 2007 09:36
Hah, exactly same here! keep the lady happy. work on my games and sitting next to her at same time

Can be annoying cos lose some focus
Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 25th Jul 2007 02:57
@Fersis
Didnt notice much of a change in FPS with setting backdrop to off but thanks for the suggestion anyway

@Latch
Your advice on importing into Deled has been invaluable. Thank you!! having imported all Doga models, 2 of them came up with a point error or invalid float number from which I was able to identify the guilty spaceship part. So far I have had no crashes and Deled looks like a fantastic 3d Modeler (at least for my purposes anyhow). I am seriously considering buying the professional package. Thanks again, your advice has really helped.

@Anto
Good to know I'm not alone. And yes very easy to lose focus while having to background listen to some of the things the Mrs likes to watch (e.g. Big Brother and top model - yuck to both).

Login to post a reply

Server time is: 2026-07-06 06:44:43
Your offset time is: 2026-07-06 06:44:43