Major slowdown creating more than 600 particles.

BlitzMax Forums/BlitzMax Beginners Area/Major slowdown creating more than 600 particles.

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.


Is this efficiant enough? I was thinking that instead of deleting a star when it exits the screen borders to actually reuse it and change its y position to the top of the screen again. Would that be better than creating a new star each time?



Yes. Creating an Object is very expensive compared to reusing an existing one. I have star code that uses DrawRect and I can do 10,000 stars in about 4.9ms. That is A LOT of time (and way too many stars :-).

You figure at 60FPS, you have approximately 16.67ms to do EVERYTHING. Taking up 25+% of the time drawing stars is bad. (1000ms/60FPS = 16.67ms per Frame)

I use 100 stars for my game, which looks just fine and that drawing time is something along the lines of less than 0.5ms which is plenty fast for my needs (right now).

You should create your stars outside of your main loop and don't destory them unless it's absolutely necessary (or it is not noticble to the user).

I would also recommend taking a more OOP approach and create a Star Object with Methods rather then what you have here. If you're not sure how to do that, I can post some code for you later.