How to make my explosions play all the way through?

How to get the explosion sprite to play all the way through on my vert

Page 1 of 1

1 Replies - 1441 Views - Last Post: 08 November 2009 - 07:17 PM Rate Topic: -----

#1 ovan35  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-October 09

How to make my explosions play all the way through?

Posted 08 November 2009 - 04:17 PM

Alright I'm making this vertical shooter using dark gdk.My problem resides with the collision of the player bullet with the enemy.Each time my bullet hits a enemy plane I get a different frame of the sprite animation.What I want is for the explosion sprite animation to play all the way through when a enemy plane gets hit.can anyone help me..Here is the code so far.

void collision()
{
	for(int i =5; i <9; i++)
	{
	
	if(dbSpriteCollision(3,i))
	{

		enemyDestroyed = 1; //we want our explosion to happpen just before the plane is deleted
		dbCreateAnimatedSprite(50,"explosion.png",4,4,50); //Animated Sprite for our explosion
		dbSetSpritePriority(50,2);
		if(dbSpriteFrame(50) < 16)
		{
		dbPlaySprite(50,1,16,200); //play explosion sprite
		dbPasteSprite(50,dbSpriteX(i), dbSpriteY(i));
		}
		if(dbSpriteFrame(50)== 16) //if we have no more frames for the explosion
		{
			dbDeleteSprite(50); //delete the explosion
		}
		dbDeleteSprite(3); //delete bullet
		dbHideSprite(i); // delete the enemy plane
		
		
		dbPlaySound(3); //Let's hear the explosion
		score+= 100; //increase score by 100

		
		//reposition code went here

		dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i ); //reposition enemy plane at top of screen
		dbShowSprite(i);
		dbScaleSprite(i,50); //make them half the original image size

		//updateScore();
		return;
		
		
	}
	}

	  for(int j = 10; j < 15; j++)
	  {
		  if(dbSpriteCollision(j,2)) //If the enemy bullets collide with the player's plane
		  {
			  dbDeleteSprite(j); //delete the enemy bullet
			  dbDeleteSprite(2); // delete the player's plane
			  dbPlaySound(3); //play explosion
			  
		  }
	  }

	

 
	   
	   
}





Is This A Good Question/Topic? 0
  • +

Replies To: How to make my explosions play all the way through?

#2 ovan35  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 06-October 09

Re: How to make my explosions play all the way through?

Posted 08 November 2009 - 07:17 PM

I just wanted to let everyone know that I figured it out.Just in case there might be someone going through a similar problem I will post the solution.Basically I needed to break down the program into smaller pieces.I was trying to get it all done in the collision portion of the code but it just wouldn't work that way.So I basically created the explosion and set the frame to one in the collision portion.Then later in the explosion function I made I had the function look for the explosion sprite.If it saw the explosion sprite its' job was to continue the animation from that part on.The last part deletes the explosion sprite once it reaches the last frame.

Collision function

void collision()
{
	for(int i =5; i <9; i++)
	{
	
	if(dbSpriteCollision(3,i))
	{

		enemyDestroyed = 1; //we want our explosion to happpen just before the plane is deleted
		dbCreateAnimatedSprite(50,"explosion.png",4,4,50); //Animated Sprite for our explosion
		dbSetSpriteFrame(50,1);
		dbSetSpritePriority(50,1);
		dbSprite(50,dbSpriteX(i), dbSpriteY(i),50);
		
		dbDeleteSprite(3); //delete bullet
		dbHideSprite(i); // delete the enemy plane
		
		
		dbPlaySound(3); //Let's hear the explosion
		score+= 100; //increase score by 100

		
		//reposition code went here

		dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i ); //reposition enemy plane at top of screen
		dbShowSprite(i);
		dbScaleSprite(i,50); //make them half the original image size

		//updateScore();
		return;
		
		
	}
	}

	  for(int j = 10; j < 15; j++)
	  {
		  if(dbSpriteCollision(j,2)) //If the enemy bullets collide with the player's plane
		  {
			  dbDeleteSprite(j); //delete the enemy bullet
			  dbDeleteSprite(2); // delete the player's plane
			  dbPlaySound(3); //play explosion
			  
		  }
	  }



explosion function

void Explosion() 
  {
if(dbSpriteExist(50)==1)
		{
		dbPlaySprite(50,1,16,100); //play explosion sprite
		
		}
		if(dbSpriteFrame(50)== 16) //if we have no more frames for the explosion
		{
			dbDeleteSprite(50); //delete the explosion
		}
  }


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1