Hello, I recently posted about a problem I was haveing triggering sound with a collision, but didin't get any replies, probably becuase I didn't explain myself very well and am a bit of a newcomer to this. However them prolem with my code still remains and I'm desperately trying to sort it out. So if anyone could have a quick look at this I would really appreciate it!! so here's the deal. As I said before I am tying to trigger an audio file from a collision in my game. The problem is that it works when the trutle and starfish collide, but not when the turtle and Jackfish collide. Sounds rediculous but that's what happens. the code for the startfish collision that works looks like this;
[source lang=cpp]
if (check_collision( stars.return_box(), myTurtle.return_box() )){
if( Mix_PlayChannel(2, gulp, 0 ) == -1 ){
return 1;
}
Then, the code for the jackfish collision looks like this
[source lang=cpp]
if (check_collision( jacks.return_box(), myTurtle.return_box() )){
collision = 1;
}
}
if (jacks.pos() < -200 - jack_rand_limit){
//cout << i << " " << shoal.pos() << endl;
jack_off_screen++;
}
}
if (jack_off_screen == 1){
jacks.clear();
jack_finished = 1;
}
if (collision){
beta += 4;
if (Mix_PlayChannel(2, gulp, 0 ) == -1 ){
return 1;
}
As you can see, the code that plays the sound is nested in a loop that also controls the screen fade out, beta, when the collision happens, but I get no sound. Nil. Can anyone see what I'm doing wrong here? Would really appreciate some kind of feedback if anyone has time. Thank you very much.