Jump to content
  • Advertisement
Sign in to follow this  
vman

Explosion animation

This topic is 4418 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 ?!!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!