Explosion animation

Started by
4 comments, last by vman 17 years, 10 months ago
Okay , this time im sooo close to finish my game(;P) , but guess what...... i need some help (again)..hehe.. I use this function (sriteHIT()) to detect collision... (there's no problem here...)
[source language="c"]
//--Thats my collision detection function
//--..i know its simple & very basic , but at least its "self made" ;P
//EnemyX & Y is an array that stores the X & Y pos
//of the enemies..

int SpriteHIT() 

                 {
                 
for (int zz=0;zz<MAX_ENEMY+1;zz++)
                    {
if 
( 
((PlayerX >= EnemyX[zz]) && (PlayerX <= EnemyX[zz] + (Enemy[zz]->w -1) )) 
&&
((PlayerY >= EnemyY[zz]) && (PlayerY <= EnemyY[zz] + (Enemy[zz]->h -1) ))  
)
                    {
                     sprite_hit = true;
                     EXPLOSION_ANIME(EnemyX[zz],EnemyY[zz]);
                    break;
                    }
                     }

if ((sprite_hit)&& (life >0)) 
                             {
           sprite_hit=false;
            life -=1;
           if(sprite_hit){
            sprite_hit=false;
                         }
            }

}


!----------------------------------------------- !----------------------------------------------- Here's the problem... When i call this function , nothing happens!...and the bad thing is.... i have no idea whats wrong!. So please take a look .. !----------------------------------------------- !-----------------------------------------------
[source language="c"]

//---Explosion "animation"----
//ExplosionA,ExplosionB,ExplosionC,ExplosionD,ExplosionE 
//                 =  normal SURFACE(/S)

int EXPLOSION_ANIME(int x,int y)
  {
//counters..
  int cA,cB,cC,cD,cE =51;

// x,y = the position of the enemy..

if ( (cA > 0)&&(cB > 50)&&(cC > 50)&&(cD > 50)&&(cE > 50) ) { cA -=1;  UPDATE_POSITION(x,y,ExplosionA,screen); }
if ( (cA <= 0)&&(cB > 0)&&(cC > 50)&&(cD > 50)&&(cE > 50) ) { cB -=1;  UPDATE_POSITION(x,y,ExplosionB,screen); } 
if ( (cA <= 0)&&(cB <= 0)&&(cC > 0)&&(cD > 50)&&(cE > 50) ) { cC -=1;  UPDATE_POSITION(x,y,ExplosionC,screen); } 
if ( (cA <= 0)&&(cB <= 0)&&(cC <= 0)&&(cD > 0)&&(cE > 50) ) { cD -=1;  UPDATE_POSITION(x,y,ExplosionD,screen); } 
if ( (cA <= 0)&&(cB <= 0)&&(cC <= 0)&&(cD <= 0)&&(cE > 0) ) { cE -=1;  UPDATE_POSITION(x,y,ExplosionE,screen); }
} 


Thanks for reading this!
Advertisement
It doesn't look like you're taking the width of the player into account. Could that have anything to do with it?
XBox 360 gamertag: templewulf feel free to add me!
Quote:Original post by templewulf
It doesn't look like you're taking the width of the player into account. Could that have anything to do with it?


I think no , because when a sprite "hits" the player, the life changes..


Also , even if i place the explosion surface code in my main() function,
the sprite remains invisible...
Quote:Original post by vman
Quote:Original post by templewulf
It doesn't look like you're taking the width of the player into account. Could that have anything to do with it?


I think no , because when a sprite "hits" the player, the life changes..


Also , even if i place the explosion surface code in my main() function,
the sprite remains invisible...

Ohhh!! I thought you meant your hit detection wasn't working. Sorry for the confusion. [lol]

I did notice, however, that you didn't initialize all of your counters. The line:
int cA,cB,cC,cD,cE =51;
only initializes cE, if I remember correctly. With the other variables containing undefined information. I would do it more like
int cA,cB,cC,cD,cE;cA = cB = cC = cD = cE = 51;

I could be wrong on that, but I'm pretty sure only the one with the = sign gets your initialization value.
XBox 360 gamertag: templewulf feel free to add me!
Yes, you are correct templewulf. :)
I dont understand whats going on... even if i put UPDATE_POSITION() function in my main function , nothing happens!!.Why i cant load even a simple bitmap ?!!

This topic is closed to new replies.

Advertisement