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!