Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Optimization using Allegro in C++

Name: Anonymous 2009-01-03 0:14

What's up /prog/,
I'm currently trying to write an rts/ shooter using C++ and allegro. By shooter/rts, I mean shooter in the terms of ikuraga, and rts in that you will be switching control of units as well as being able to "freeze" the area around the ship you are currently controlling and que some command for the flotilla you are commanding.
Seeing as I have this in mind, I need to be able to have at least 90 units in the game without visible slowdown, so if you have some suggestions, I'm open to anything.

Thanks!

Name: Anonymous 2009-01-03 1:53

Store pointers to objects in your array. Do comparisons using the object references. This will be faster since this time, you're only swapping pointers (ie. 32-bit integers) inside your array. Currently, the swap function is taking the address of the two objects in your array, and copying entire objects. This involves copying A to temporary store, a copy from B to A, then a copy from temp. store to B. Depending on what goes on inside the constructor and destructor of your class, this can be very costly indeed, especially if you're doing this inside a tight loop.

I also just noticed counter < (counter < TempNumOfBull2) inside that second for loop. Are you aware that (counter < TempNumOfBull2) will only be 0 or 1? Was this the intent?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List