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 / Can someone help me optimize this code?

Author
Message
Ghost Pirate Bob
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location:
Posted: 17th Jul 2004 15:54
I've got this code, see...
and it runs every game cycle see

and it runs very slowly see

...

Any ideas on how to optimize?

GNAAR

Me
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 17th Jul 2004 18:45 Edited at: 17th Jul 2004 18:48
You call Object Collision(j,0) twice per loop, just call it once and put the value in a variable.
Also, since object collision(7,0) will be a constant, get the value of it before you enter the loop, store it and use the variable.

Also, the Delete Object command is what is the major slow-down.
If you still need the objects, or even if you don't, instead of deleting them, just move them to some rediculously far-away place and hide them

Like this;


That should give you a speed boost

Jess.

[EDIT]
Just noticed that you're calling Object Collision(j,0) way too many times,
I moved it out of the For k and For i loops so that it is only called 3 times per function call instead of the 288 times it was before.
[/EDIT]


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Ghost Pirate Bob
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location:
Posted: 18th Jul 2004 11:32
Hey, thanks a whole bunches...

I did end up having to go with the delete object command... (it just went with the rest of my code much better)

That seriously nearly quadrupled the speed I was running at, my hat is off to you *tips*

GNAAAR

Me
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 18th Jul 2004 23:47
Anytime mate

Jess.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy

Login to post a reply

Server time is: 2025-05-26 00:37:06
Your offset time is: 2025-05-26 00:37:06