Completely stopping an animation loop?

Hey, so my character shoots a projectile. When space bar is pressed it enters an animation loop like:

while(character[i].xCoord < 733 && collisionTest(thunderHit, reaperHit) == false){

//animate projectile

}

'i' simply indicates which way the projectile is going. The first condition is for a wall, it stops if it hits, the second stops if it hits the enemy sprite. This works, but when it hits the enemy sprite, and the sprite moves, the thunderball reanimates and continues all the way to the wall? I guess here is the animation loop for shooting down:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
else if(i == 7){
					while(character[i].yCoord < 682 && collisionTest(thunderHit, reaperHit) == false){
						//Puts image of character on screen based on inputs from struct

						thunderHit.boundx = character[i].xCoord;
						thunderHit.boundy = character[i].yCoord;
						thunderHit.boundheight = character[i].charHeight;
						thunderHit.boundwidth = character[i].charWidth;
						thunderballSectors();

						readimagefile(character[i].frames[character[i].currentFrame],
							character[i].xCoord,
							character[i].yCoord,
							character[i].xCoord + character[i].charWidth,
							character[i].yCoord + character[i].charHeight );

						character[i].currentFrame++; //increments the "frame" by one, thus only animating one image at a time
						if(character[i].currentFrame == character[i].animationFrames){
							character[i].currentFrame = 0;}
						character[i].yCoord = character[i].yCoord + 10;
						if(collisionTest(reaperHit, thunderHit) == true){
							break;}

					}
				}


I attempted to put that break in there on hopes that the animation would stop completely when it hit the enemy.

But that is what I am after, stopping it completely upon collision with the wall or enemy. I tried changing && to || and it just went on forever and went outside of wall boundaries. I tried quite a few different things as well....

I was wondering if anyone had any suggestiosns?
Topic archived. No new replies allowed.