Commits

Anonymous committed 5f5d99e

solarwolf

  • Participants
  • Parent commits 089ce33

Comments (0)

Files changed (2)

File solarwolf/Classes/solarwolfViewController.h

 -(void)moveShip:(CGPoint) move;
 -(void)colorbox;
 -(void)destroyBox;
+-(void)gameWon;
 @end
 

File solarwolf/Classes/solarwolfViewController.m

 			[box release];
 		}
 		[rows release];
-	}
-			
-		
-	
-	
-		
-	
-	
+	}	
 	
 	UIColor *color = [[UIColor alloc] initWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
 
 	
 	}
 -(void)destroyBox{
-	NSMutableArray *rows=[fatArray objectAtIndex:horzStep];
-	int k= [[rows objectAtIndex:vertStep]intValue];
+	NSMutableArray *row=[fatArray objectAtIndex:horzStep];
+	int k= [[row objectAtIndex:vertStep]intValue];
 	int a=k-1;
-	[rows replaceObjectAtIndex:vertStep	withObject:[NSNumber numberWithInt:a]];
-	[fatArray replaceObjectAtIndex:horzStep withObject:rows];
+	[row replaceObjectAtIndex:vertStep	withObject:[NSNumber numberWithInt:a]];
+	[fatArray replaceObjectAtIndex:horzStep withObject:row];
 	[self colorbox];
+	[self gameWon];
 	}
+-(void)gameWon{
+	int l=0;
+	for(int i=0; i<=11; i++){
+		NSMutableArray *row=[fatArray objectAtIndex:i];
+		for(int j=0; j<=17; j++){
+			int k=[[row	objectAtIndex:j]intValue];
+			if(k>0){
+				l++;
+			}
+		}
+	}
+	if(l>0)
+	{
+	}
+	else{
+		UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"U Won" message:@"U won the game" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
+		[alert show];
+		[alert release];
+	}
+	
+}
 -(void)moveShip:(CGPoint)move{
 	CGRect shipframe=ship.frame;
 	CGPoint click;