2008-03-02

The Secret Posts - Name Change, Collisions, Sounds

(Written 05/02/2008)

The name change is done. The game is now “Chroma-X”, with the addition of the hyphen hopefully reducing the likelihood of any inadvertant association with medication.

(I’ve just discovered that there is actually a product with that name – why didn’t that turn up the first time I googled for it? How embarrassing. It’s like having a shoot-em-up called “Aspirin”. Rubbish. You can guarantee I’m going to get endless comment spam now.)

Collision detection works. I’ve used two traditional methods in unison to provide a speedy routine – it checks bounding box collisions first, then pixel accurate collisions if the first check is true. Player bullets are managed by an instance of a new “BulletManager” class that replaces the existing “PlayerBulletManager”. It’s the same thing, but with a more generic name. Enemy bullets are handled by another instance of the same class. Collisions between bullets and other sprites are checked by just looping through the BulletManager’s sprite arrays and calling sprite->checkCollision(enemy).

It’s now possible to destroy enemies, which explode using the previously created ParticleManager class. Nothing happens yet when the player crashes into an enemy or when the player gets shot.

Sounds are now working, after a fashion. All sound management and playback is handled by a new “SoundPlayer” class. There is one big problem with the SDL_Mixer library – playback of samples is delayed by half a second. Googling it reveals hundreds of pages complaining about the problem, but no solutions other than “decrease the number of buffers”. This “fix” doesn’t actually fix the problem, but it does reduce the sound quality of the audio. Great. I’ve tried a few things, such as ensuring the WAV files are all the same frequency, but to no avail. It’s like trying to get audio working properly in Flash MX: an exercise in futility. My plan is to just get some basic sounds in the game but not spend too much time on it if the results aren’t going to be very good.

Score bubbles now work, too.

EDIT:

Some fiddling later, I’ve got sounds working correctly on the GP2x by – yep – decreasing the number of buffers from 512 to 128. Windows hates this and mangles the samples, so I’ve added a preprocessor if block to change the buffer for the 2x and I’ll just live with the delay in Windows. The volume buttons are all wired up correctly – they refused to do anything until I noticed that they were inside the wrong part of another conditional compile block.