1. Anders Lehmann
  2. iPhone

Commits

leslie3  committed aa0417a

Har fikset nogle småting

  • Participants
  • Parent commits 22a61a2
  • Branches default

Comments (0)

Files changed (7)

File solarwolf/Classes/Platforms.h

View file
  • Ignore whitespace
 
 -(CGRect)convertPosToSquare;
 
-
--(UIView *)drawSpirint;
-
 -(void)oppositeDirection;
 
 -(void)check;
+
+-(UIView *)drawSpirint;
 		
 @end

File solarwolf/Classes/Platforms.m

View file
  • Ignore whitespace
 		spirintView.backgroundColor=[UIColor blackColor];
 	}
 	return self;
+	[spirintView release];
 }
 
 -(NSString*) sidePosition{
 		[fireball setDirection:@"Right"];
 	}
 	return fireball;
+	[fireball release];
 }
 	
 -(CGRect)convertPosToSquare{
 	}
 	
 	else if([sidePos isEqualToString:@"Right"]){
-		CGRect square=CGRectMake(25*temp.x+5, 25*temp.y+5,10, 25);
+		CGRect square=CGRectMake(25*temp.x+35, 25*temp.y+5,10, 25);
 		return square;
 	}
 	
 	[self drawSpirint];
 }
 
+-(UIView *)drawSpirint{
+	
+	CGRect frame=[self convertPosToSquare];
+	spirintView.frame=frame;
+	return spirintView;
+	
+	
+}
+
 
 	
 

File solarwolf/Classes/Ship.h

View file
  • Ignore whitespace
 
 -(void) moveShip:(CGPoint) move;
 
+-(void)move;
+-(id)initWithPos:(CGPoint) value:(NSString*)dir;
+
 @end

File solarwolf/Classes/Ship.m

View file
  • Ignore whitespace
 
 
 @implementation Ship
+-(id)initWithPos:(CGPoint) value{
+	if(self=[super init])
+	{
+		
+		position=value;
+		CGRect frame=[self convertPosToSquare];
+		
+		spirintView=[[UIView alloc]initWithFrame:frame];
+		spirintView.backgroundColor=[UIColor blueColor];
+		
+	}
+	return self;
+	[spirintView release];
+}
 
 -(void)moveShip:(CGPoint)move{
 	

File solarwolf/Classes/Spirint.m

View file
  • Ignore whitespace
 }
 
 -(void)move{
+	[UIView beginAnimations:nil context:nil];
+	[UIView setAnimationDuration: 0.5];
+	[UIView setAnimationCurve: UIViewAnimationCurveLinear];
 	CGPoint temp=[self position];
 	if([[self direction] isEqual:@"Up"]){
 		temp.y--;
 	}
 	[self setPosition:temp];
 	[self drawSpirint];
+	[UIView commitAnimations];
 
 }
 

File solarwolf/Classes/solarwolfViewController.h

View file
  • Ignore whitespace
 	Platforms* platformTop;
 	Platforms* platformBottom;
 	NSMutableArray* platformArray;
-	UIView * platformLeftView;
+	/*UIView * platformLeftView;*/
 	UIView * platformBottomView;
 }
 -(void)colorbox;

File solarwolf/Classes/solarwolfViewController.m

View file
  • Ignore whitespace
 	[shipView setBackgroundColor: color];
 	
 	platformLeft=[[Platforms alloc]initWithPos:CGPointMake(0,0):@"Down":@"Left"];
+	platformTop=[[Platforms alloc]initWithPos:CGPointMake(0,0):@"Right":@"Top"];
 	platformBottom=[[Platforms alloc]initWithPos:CGPointMake(0,17):@"Right":@"Bottom"];
-
-	platformLeftView=[platformLeft drawSpirint];
-	[myView addSubview:platformLeftView];
+	platformRight=[[Platforms alloc]initWithPos:CGPointMake(11,17):@"Up":@"Right"];
 	
+	[myView addSubview:[platformLeft drawSpirint]];
 	
+	[platformArray addObject:platformLeft];
+	[platformArray addObject:platformRight];
+	[platformArray addObject:platformTop];
+	[platformArray addObject:platformBottom];
 	
-	platformBottomView=[platformBottom drawSpirint];
-	[myView addSubview:platformBottomView];
+	NSEnumerator *e=[platformArray objectEnumerator];
+	id object;
+	while (object=[e nextObject]) {
+	UIView * platformView=[object drawSpirint];
+	[myView addSubview:platformView];
+	}
 	
 	
 	[myView addSubview:[myShip drawSpirint]];
+	[NSTimer scheduledTimerWithTimeInterval: 0.1
+									 target: self
+								   selector: @selector(gameLoop)
+								   userInfo: nil
+									repeats: YES];
 	[NSTimer scheduledTimerWithTimeInterval: 0.5
 									 target: self
-								   selector: @selector(gameLoop)
+								   selector: @selector(fireMoveLoop)
 								   userInfo: nil
 									repeats: YES];
 	[ship release];
 }
 
 -(void)gameLoop{
+	NSEnumerator* e=[fireballArray objectEnumerator];
+	id object;
+	while(object=[e nextObject]){		
+		[self uDead:[object position]];
+	}
+}
 	
-	[platformLeft move];
-	[platformBottom move];
-	Spirint* fireball=[platformLeft launchFireball];
-	UIView* fireballView = [fireball drawSpirint];
-	[myView addSubview:fireballView];
+
+-(void)fireMoveLoop{
 	NSEnumerator* e=[fireballArray objectEnumerator];
 	id object;
 	while(object=[e nextObject]){
-		[self uDead:[object position]];
+		
 		if(![object objectWillLeave]){
 		[object move];
 		}
 		else{
 			[[object view] removeFromSuperview];
+			
 		}
 	}
+	NSEnumerator *j=[platformArray objectEnumerator];
+	id platform;
+	while (platform=[j nextObject]) {
+		[platform move];
+		int value=arc4random() % 10;
+		if(value==0){
+		Spirint* fireball=[platform launchFireball];
+		UIView* fireballView = [fireball drawSpirint];
+		[myView addSubview:fireballView];
 	[fireballArray addObject:fireball];
-	
+		}
+	}
 	
 }