A different slow program

BlitzPlus Forums/BlitzPlus Beginners Area/A different slow program

Buggy(Posted 2006) [#1]
If I have the possibility of having a lot of bullets onscreen at once, which would be faster:

1. Testing for each bullet type. If a bullet is created, create it. If a bullet is deleted, nuke it. The usual.

2. Do the above, but if there are too many bullets (above a certain limit), create them but call them something else. Like this:

If numberofbullets > bulletlimit

     bullet2.bullet2 = new bullet2

     etc.

Else

     bullet1.bullet1 = new bullet1

Endif

I would suspect that the first would be faster because that way you only have to check each of the bullets once, instead of the bullet1 type and then the bullet2 type.

Please respond, though.


Grey Alien(Posted 2006) [#2]
I don't really understand what you are asking. Sorry. Can you explain a bit more?


WolRon(Posted 2006) [#3]
Why do you want to create a new kind of bullet?


Grey Alien(Posted 2006) [#4]
yeah exactly. If anything you could have a single bullet type and have a field called SubType to define slightly different behaviour.


Buggy(Posted 2006) [#5]
I'm asking if, say, it would be faster to have 100 bullets of the same type, or 20 bullets each of the types bullet1, bullet2, bullet3, bullet4, and bullet5.

I can't see any way that the latter could be faster, but my game can have a lot of onscreen bullets... any other suggestions?


WolRon(Posted 2006) [#6]
Sounds like you're interested in a single surface system...


Grey Alien(Posted 2006) [#7]
the logic of 100 bullets won't slow your game down. Drawing them or doing collision test will, but having more than one type won't affect drawing/collision. However, it's best to avoid >1 type so you can have generic functions to handle them.


Buggy(Posted 2006) [#8]
What's a single surface system, and is there any way to speed the game up?


Buggy(Posted 2006) [#9]
Can someone answer the question I posed above?


Grey Alien(Posted 2006) [#10]
google "single surface system" blitz.