Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 07-28-2010, 12:52 PM   #9 (permalink)
Paul10
Registered Member
 
Join Date: Apr 2010
Posts: 49
Default

Quote:
Originally Posted by Ubermatik View Post
Okay... how would I go about doing that? Do I simply indent all my code so it's beneath the touchesMoved code? Or should I get rid of all the {/}'s?
You'd just cut them from their location and put them inside the gameloop..so gameloop would be:

Code:
-(void) gameLoop {
	if(gameState == kGameStateRunning) {
		
		puc.center = CGPointMake(puc.center.x + pucVelocity.x , puc.center.y + pucVelocity.y);
		
		if(puc.center.x > self.view.bounds.size.width || puc.center.x < 0) {
			pucVelocity.x = -pucVelocity.x;
		}
		
		if(puc.center.y > self.view.bounds.size.height || puc.center.y < 0) {
			pucVelocity.y = -pucVelocity.y;
		}
	} else {
		if (tapToBegin.hidden) {
			tapToBegin.hidden = NO;
		}
	}

	if (CGRectIntersectsRect(puc.frame,paddleblue.frame)) {
		if(puc.center.y < paddleblue.center.y) {
			pucVelocity.y = -pucVelocity.y;
			NSLog(@"%f %f",puc.center,paddlegreen.center);
		}
	}

	if (CGRectIntersectsRect(puc.frame,paddlegreen.frame)) {
		if(puc.center.y > paddlegreen.center.y) {
			pucVelocity.y = -pucVelocity.y;
		}
	}

	//AI
	if (puc.center.y <= self.view.center.y) {
		if(puc.center.x < paddlegreen.center.x) {
			CGPoint compLocation = CGPointMake(paddlegreen.center.x - kCompMoveSpeed, paddlegreen.center.y);
			paddlegreen.center = compLocation;
		}
	
		if(puc.center.x > paddlegreen.center.x) {
			CGPoint compLocation = CGPoint(paddlegreen.center.x + kCompMoveSpeed, paddlegreen.center.y);
			paddlegreen.center = compLocation;
		}
	}

} //End of gameloop
__________________
Paul
New iPhone Developer
Paul10 is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,852
Threads: 89,217
Posts: 380,670
Top Poster: BrianSlick (7,129)
Welcome to our newest member, syrreintyia1
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:06 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.