Game Freeze!

Hi all,

I’m developing space-shooter style game and I’m using a 3D program to generate some very neat animations for the game. After adding many animations to the game, it started to freeze a heck of alot during game play, and it’ll remain frozen (i.e. I have to shut down the process).

This might have something to do with the fact that each animation is a good 120 frames of PNG images with alpha transparency. A couple of things which have already been done:

  1. The images are compressed as much as possible in terms of size.
  2. All of the images are only loaded ONCE and are stored as a static “animation” object which is cloned each time the animation needs to occur.
  3. The heap size of the JVM is already being raised to 256 MB, which is pretty darn high!

So if anyone has any suggestions regarding faster, more effecient proper animation it would be greatly appreicated.

Thanks guys!

  1. The images are compressed as much as possible in terms of size.

That doesn’t matter. The images will stored in an uncompressed form (in ram/vram). Widthheightchannels+some overhead is needed

  1. All of the images are only loaded ONCE and are stored as
    a static “animation” object which is cloned each time the
    animation needs to occur.

Cloned?! What for?

Well, say an explosion animation may occur several times on the screen, so one animation object is created and a clone of it is used for another explosion.

Now, I’ve read on another topic that the maximum size for images to be stored in accelerated memory is 256x256. I’ve changed my animation images so that they fit this criteria. I also disabled 2 sound clips which were played on each ship explosion and bullet fired by the player. I’ve ran the game several times and it hasnt frozen, but I’d still like to know if there’s a better way of loading animations.

Regards.

use 1 single array for your Images. Your animation objects should keep track of indexes in that array, not the array themselves. Copying (I’m assuming this is what you meant with the clone idea) is going to take way too long and it’s totally unnecessary. Let the animation object reach back from a single global array for the images, and pick the one it needs when it draws. All of your animations can pick from this same array.

You’re loading it once, that’s fine… but then you’re copying them all an endless number of times, which is kind of defeating your purpose.

using png as animated object is no good idea, use your own animation engine

for e.g. you have a 50kb png with 20 frames and you clone it 100 times you will have 50kb times 100 memory wasted, if you use hw accel images ( these 20 frames ) and blit em like you want u use only 50kb.