laser[index].state = LASER_STATE_OFF;
to this:
laser[index].attr = laser[index].attr & ~BOB_ATTR_VISIBLE;
Does this work???
laser[index].state = LASER_STATE_OFF;
to this:
laser[index].attr = laser[index].attr & ~BOB_ATTR_VISIBLE;
Does this work???
if ( bot.attr & BOB_ATTR_VISIBLE )
{
for (index=0; index {
if ( (laser[index].attr & BOB_ATTR_VISIBLE) && (Collision_BOBS(⊥, &laser[index])) )
{
laser[index].state = LASER_STATE_OFF;
Start_Burst(laser[index].x, laser[index].y,
68+rand()%12,54+rand()%10,
bot.xv>>1, bot.yv>>1);
laser_hit++;
if (laser_hit == 36000)
{
Hide_BOB(⊥);
boton = 2;
score = score + 300;
laser_hit = 0;
}
}
}
}
(I know this code wouldn't destroy the enemy in three hits because I test the counter for 36000 but I did this because if I put it to 3 it counts up so fast that you barely can see it)This code is in Move_Laser(); which is runned in the Game_Main();. Now I figured out that the laser just kept hitting it because I displayed the counter variable on the screen. Now it should have gone from 0 to 1 when my laser beam hit the enemy instead it went to 1 and then just kept on counting up which means that even though the laser gets turned off (LASER_STATE_OFF) and it goes invisible somehow its still hitting the enemy. Even if the laser is hidden it shouldn't be hitting it because I make sure that its not invisible by putting if ( (laser[index].attr & BOB_ATTR_VISIBLE)... Does anyone see an error in the code above that would be causing this?
Thanx,
ViPeR
BTW, Im using the GPDUMB engine from one of Andre Lamothes books.
[This message has been edited by ViPeR007 (edited December 26, 1999).]
void Fire_Laser(int x,int y, int vel)
{
for (int index=0; index {
if (laser[index].state == LASER_STATE_OFF)
{
// start this one up
laser[index].x = x;
laser[index].y = y;
laser[index].yv = -vel;
laser[index].curr_frame = 0;
laser[index].state = LASER_STATE_ON;
// start sound up
for (int sound_index=0; sound_index < MAX_FIRE_SOUNDS; sound_index++)
{
// test if this sound is playing
if (Status_Sound(fire_ids[sound_index])==0)
{
Play_Sound(fire_ids[sound_index]);
break;
} // end if
} // end for sound_index
return;
} // end if
} // end for
}
I have no idea why it will only let me take two shots because my MAX_LASER is set to 50. When I put it back to the way it was (broken) it can fire as many shots as you want it to. I know for a fact (through testing) that all my functions dealing with the laser are executing but for some reason its not being drawn to the screen and its not dectecting a collision with the enemy. Does anyone know why this one line can make my whole laser go away (after 2 shots that collide)?
Thanx,
ViPeR