Infinite loop?

I just get white screened when i try any while, for, or do loop. This is what i have I dont understand why it doesn't work.


This just says that if the cursor overlaps the item then change certain bools to make it disappear and make the next item appear.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
	int n = 0;
		 if (facex-5 <= itemx+5 && facex+5 >= itemx-5 && facey-5 <= itemy+5 && facey+5 >= itemy-5) {
				stage1=false,stage2=true,n++;}
		 if (facex-5 <= item2x+5 && facex+5 >= item2x-5 && facey-5 <= item2y+5 && facey+5 >= item2y-5) {
				stage2=false,stage3=true;n++;}
		 if (facex-5 <= item3x+5 && facex+5 >= item3x-5 && facey-5 <= item3y+5 && facey+5 >= item3y-5) {
				stage3=false,n++;}
	do {
		 if(stage1==true&&n==0){
			 Drawitem(itemx,itemy,0,255,0 );}
		 if (stage2==true&&n==1){
			 Drawitem(item2x,item2y,0,255,0);}
		 if (stage3==true&&n==2){
			 Drawitem(item3x,item3y,0,0,255 );
		 	 if (facex<400){item3x=item3x+4,item3y=item3y-4;}}
		}
	while(n<3);
1
2
3
4
5
6
// say n==2 at this point
do 
{
        // ...
}
while (n<3 ) ;


Where are you modifying the value of n so that n<3 becomes false and the loop is ended?
After each overlap, n is increased by one "n++". After you collect 3 items the loop shall end. How should i do this any other way?
n value must be changed in do while loop other wise program will not end. I think you forget to include following code in loop.

1
2
3
4
5
6
if (facex-5 <= itemx+5 && facex+5 >= itemx-5 && facey-5 <= itemy+5 && facey+5 >= itemy-5) {
				stage1=false,stage2=true,n++;}
		 if (facex-5 <= item2x+5 && facex+5 >= item2x-5 && facey-5 <= item2y+5 && facey+5 >= item2y-5) {
				stage2=false,stage3=true;n++;}
		 if (facex-5 <= item3x+5 && facex+5 >= item3x-5 && facey-5 <= item3y+5 && facey+5 >= item3y-5) {
				stage3=false,n++;}
Topic archived. No new replies allowed.