Quote:
Originally Posted by Ubermatik
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