diff options
| author | Starla Insigna <starla4444@gmail.com> | 2013-01-02 23:27:26 -0500 | 
|---|---|---|
| committer | Starla Insigna <starla4444@gmail.com> | 2013-01-02 23:27:26 -0500 | 
| commit | ba19dd3f2517a95e09dcfe288a781c6f335b5e81 (patch) | |
| tree | 681e43be807ed46b75dab6b291a6a6dd3e67b6e5 /Classes | |
| parent | 28497668761472e085d0c9955aa8077d11bf353c (diff) | |
| parent | f82fdb7134632c1a52902d44c0d555dac0225898 (diff) | |
| download | cartcollect-ba19dd3f2517a95e09dcfe288a781c6f335b5e81.tar.gz cartcollect-ba19dd3f2517a95e09dcfe288a781c6f335b5e81.tar.bz2 cartcollect-ba19dd3f2517a95e09dcfe288a781c6f335b5e81.zip | |
Pulled in trunk changes because the iOS 6 bug was making it impossible to test
Diffstat (limited to 'Classes')
| -rw-r--r-- | Classes/Cart.h | 2 | ||||
| -rw-r--r-- | Classes/Cart.m | 15 | ||||
| -rwxr-xr-x | Classes/Cart_CollectAppDelegate.m | 3 | ||||
| -rw-r--r-- | Classes/GameMode.h | 6 | ||||
| -rw-r--r-- | Classes/GameMode.m | 69 | ||||
| -rwxr-xr-x | Classes/HighscoreListController.m | 22 | ||||
| -rw-r--r-- | Classes/JumpGameMode.m | 46 | 
7 files changed, 119 insertions, 44 deletions
| diff --git a/Classes/Cart.h b/Classes/Cart.h index 1058025..af463f2 100644 --- a/Classes/Cart.h +++ b/Classes/Cart.h | |||
| @@ -26,6 +26,6 @@ | |||
| 26 | @property (assign) BOOL boundedByScreen; | 26 | @property (assign) BOOL boundedByScreen; | 
| 27 | - (id)initWithSprite:(CCSprite*)sprite; | 27 | - (id)initWithSprite:(CCSprite*)sprite; | 
| 28 | - (void)tick; | 28 | - (void)tick; | 
| 29 | - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration; | 29 | - (void)deviceDidRotate:(double)pitch; | 
| 30 | 30 | ||
| 31 | @end | 31 | @end | 
| diff --git a/Classes/Cart.m b/Classes/Cart.m index 0344bdf..f9da181 100644 --- a/Classes/Cart.m +++ b/Classes/Cart.m | |||
| @@ -54,7 +54,7 @@ | |||
| 54 | if ((delegate != nil) && ([delegate respondsToSelector:@selector(cartShouldFall:)])) | 54 | if ((delegate != nil) && ([delegate respondsToSelector:@selector(cartShouldFall:)])) | 
| 55 | { | 55 | { | 
| 56 | int bottom = [delegate cartShouldFall:self]; | 56 | int bottom = [delegate cartShouldFall:self]; | 
| 57 | sprite.position = ccp(sprite.position.x, MAX(bottom, sprite.position.y-6)); | 57 | sprite.position = ccp(sprite.position.x, MAX(bottom, sprite.position.y-8)); | 
| 58 | } else { | 58 | } else { | 
| 59 | NSLog(@"Falling is set on a cart without a compatible game mode."); | 59 | NSLog(@"Falling is set on a cart without a compatible game mode."); | 
| 60 | } | 60 | } | 
| @@ -62,15 +62,14 @@ | |||
| 62 | } | 62 | } | 
| 63 | } | 63 | } | 
| 64 | 64 | ||
| 65 | - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration | 65 | #define kFilterFactor 0.05f | 
| 66 | |||
| 67 | - (void)deviceDidRotate:(double)pitch | ||
| 66 | { | 68 | { | 
| 67 | static float prevY=0; | 69 | static float prevY=0; | 
| 68 | 70 | float accelY = -((float) pitch * kFilterFactor + (1- kFilterFactor)*prevY); | |
| 69 | #define kFilterFactor 0.05f | 71 | |
| 70 | 72 | prevY = accelY; | |
| 71 | float accelY = -((float) acceleration.y * kFilterFactor + (1- kFilterFactor)*prevY); | ||
| 72 | |||
| 73 | prevY = accelY; | ||
| 74 | accelX = accelY * 750; | 73 | accelX = accelY * 750; | 
| 75 | } | 74 | } | 
| 76 | 75 | ||
| diff --git a/Classes/Cart_CollectAppDelegate.m b/Classes/Cart_CollectAppDelegate.m index 25a2aa4..c92d231 100755 --- a/Classes/Cart_CollectAppDelegate.m +++ b/Classes/Cart_CollectAppDelegate.m | |||
| @@ -114,7 +114,8 @@ | |||
| 114 | [viewController setView:glView]; | 114 | [viewController setView:glView]; | 
| 115 | 115 | ||
| 116 | // make the View Controller a child of the main window | 116 | // make the View Controller a child of the main window | 
| 117 | [window addSubview: viewController.view]; | 117 | [window setRootViewController:viewController]; | 
| 118 | //[window addSubview: viewController.view]; | ||
| 118 | 119 | ||
| 119 | [window makeKeyAndVisible]; | 120 | [window makeKeyAndVisible]; | 
| 120 | 121 | ||
| diff --git a/Classes/GameMode.h b/Classes/GameMode.h index cd41884..e208d49 100644 --- a/Classes/GameMode.h +++ b/Classes/GameMode.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #import "Cart.h" | 10 | #import "Cart.h" | 
| 11 | #import "FallingObjectFactory.h" | 11 | #import "FallingObjectFactory.h" | 
| 12 | #import "GameModeInfo.h" | 12 | #import "GameModeInfo.h" | 
| 13 | #import <CoreMotion/CoreMotion.h> | ||
| 13 | 14 | ||
| 14 | #define GAME_SCENE 436 | 15 | #define GAME_SCENE 436 | 
| 15 | #define GAME_LAYER 437 | 16 | #define GAME_LAYER 437 | 
| @@ -31,6 +32,10 @@ | |||
| 31 | void (^delayedAction)(void); | 32 | void (^delayedAction)(void); | 
| 32 | 33 | ||
| 33 | BOOL isPaused; | 34 | BOOL isPaused; | 
| 35 | |||
| 36 | BOOL hasGyroscope; | ||
| 37 | double pitch; | ||
| 38 | CMMotionManager* motionManager; | ||
| 34 | } | 39 | } | 
| 35 | 40 | ||
| 36 | @property (readonly) Cart* cart; | 41 | @property (readonly) Cart* cart; | 
| @@ -46,5 +51,6 @@ | |||
| 46 | - (void)scheduleDelayedAction:(void(^)(void))delayedAction delay:(float)delay; | 51 | - (void)scheduleDelayedAction:(void(^)(void))delayedAction delay:(float)delay; | 
| 47 | - (void)runDelayedAction; | 52 | - (void)runDelayedAction; | 
| 48 | + (GameModeInfo*)info; | 53 | + (GameModeInfo*)info; | 
| 54 | - (void)setPitch:(double)m_pitch; | ||
| 49 | 55 | ||
| 50 | @end | 56 | @end | 
| diff --git a/Classes/GameMode.m b/Classes/GameMode.m index 3e2f3ee..49d0053 100644 --- a/Classes/GameMode.m +++ b/Classes/GameMode.m | |||
| @@ -20,8 +20,6 @@ | |||
| 20 | 20 | ||
| 21 | if (nil != self) | 21 | if (nil != self) | 
| 22 | { | 22 | { | 
| 23 | isAccelerometerEnabled_ = YES; | ||
| 24 | |||
| 25 | objects = [[NSMutableSet alloc] init]; | 23 | objects = [[NSMutableSet alloc] init]; | 
| 26 | 24 | ||
| 27 | cart = [[Cart alloc] initWithSprite:[CCSprite spriteWithFile:@"cart.png"]]; | 25 | cart = [[Cart alloc] initWithSprite:[CCSprite spriteWithFile:@"cart.png"]]; | 
| @@ -53,6 +51,26 @@ | |||
| 53 | } | 51 | } | 
| 54 | 52 | ||
| 55 | isPaused = NO; | 53 | isPaused = NO; | 
| 54 | |||
| 55 | Class cmClass = (NSClassFromString(@"CMMotionManager")); | ||
| 56 | if (cmClass) | ||
| 57 | { | ||
| 58 | motionManager = [[CMMotionManager alloc] init]; | ||
| 59 | |||
| 60 | if (motionManager.gyroAvailable) | ||
| 61 | { | ||
| 62 | [motionManager setDeviceMotionUpdateInterval:1.0f/60.0f]; | ||
| 63 | isAccelerometerEnabled_ = NO; | ||
| 64 | hasGyroscope = YES; | ||
| 65 | } else { | ||
| 66 | isAccelerometerEnabled_ = YES; | ||
| 67 | motionManager = nil; | ||
| 68 | hasGyroscope = NO; | ||
| 69 | } | ||
| 70 | } else { | ||
| 71 | isAccelerometerEnabled_ = YES; | ||
| 72 | hasGyroscope = NO; | ||
| 73 | } | ||
| 56 | } | 74 | } | 
| 57 | 75 | ||
| 58 | return self; | 76 | return self; | 
| @@ -60,19 +78,39 @@ | |||
| 60 | 78 | ||
| 61 | - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration | 79 | - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration | 
| 62 | { | 80 | { | 
| 63 | [cart accelerometer:accelerometer didAccelerate:acceleration]; | 81 | self.pitch = acceleration.y; | 
| 64 | } | 82 | } | 
| 65 | 83 | ||
| 66 | - (void)onEnterTransitionDidFinish | 84 | - (void)onEnterTransitionDidFinish | 
| 67 | { | 85 | { | 
| 68 | [super onEnterTransitionDidFinish]; | 86 | [super onEnterTransitionDidFinish]; | 
| 69 | 87 | ||
| 70 | [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / 60)]; | 88 | if (hasGyroscope) | 
| 89 | { | ||
| 90 | [motionManager startDeviceMotionUpdates]; | ||
| 91 | } else { | ||
| 92 | [[UIAccelerometer sharedAccelerometer] setUpdateInterval:(1.0 / 60)]; | ||
| 93 | } | ||
| 94 | |||
| 71 | [self schedule:@selector(tick:) interval:1.0f/60.0f]; | 95 | [self schedule:@selector(tick:) interval:1.0f/60.0f]; | 
| 72 | } | 96 | } | 
| 73 | 97 | ||
| 98 | - (void)onExit | ||
| 99 | { | ||
| 100 | if (hasGyroscope) | ||
| 101 | { | ||
| 102 | [motionManager stopDeviceMotionUpdates]; | ||
| 103 | } | ||
| 104 | } | ||
| 105 | |||
| 74 | - (void)tick:(ccTime)dt | 106 | - (void)tick:(ccTime)dt | 
| 75 | { | 107 | { | 
| 108 | if (hasGyroscope) | ||
| 109 | { | ||
| 110 | CMDeviceMotion* motion = [motionManager deviceMotion]; | ||
| 111 | self.pitch = -motion.attitude.pitch; | ||
| 112 | } | ||
| 113 | |||
| 76 | [cart tick]; | 114 | [cart tick]; | 
| 77 | 115 | ||
| 78 | NSMutableSet* discardedObjects = [NSMutableSet set]; | 116 | NSMutableSet* discardedObjects = [NSMutableSet set]; | 
| @@ -100,6 +138,11 @@ | |||
| 100 | 138 | ||
| 101 | [self pauseSchedulerAndActions]; | 139 | [self pauseSchedulerAndActions]; | 
| 102 | 140 | ||
| 141 | if (hasGyroscope) | ||
| 142 | { | ||
| 143 | [motionManager stopDeviceMotionUpdates]; | ||
| 144 | } | ||
| 145 | |||
| 103 | shadedLayer = [CCLayerColor layerWithColor:ccc4(0, 0, 0, 127)]; | 146 | shadedLayer = [CCLayerColor layerWithColor:ccc4(0, 0, 0, 127)]; | 
| 104 | [[[CCDirector sharedDirector] runningScene] addChild:shadedLayer]; | 147 | [[[CCDirector sharedDirector] runningScene] addChild:shadedLayer]; | 
| 105 | 148 | ||
| @@ -132,6 +175,11 @@ | |||
| 132 | shadedLayer = nil; | 175 | shadedLayer = nil; | 
| 133 | pauseLayer = nil; | 176 | pauseLayer = nil; | 
| 134 | 177 | ||
| 178 | if (hasGyroscope) | ||
| 179 | { | ||
| 180 | [motionManager startDeviceMotionUpdates]; | ||
| 181 | } | ||
| 182 | |||
| 135 | [self resumeSchedulerAndActions]; | 183 | [self resumeSchedulerAndActions]; | 
| 136 | 184 | ||
| 137 | isPaused = NO; | 185 | isPaused = NO; | 
| @@ -202,9 +250,16 @@ | |||
| 202 | 250 | ||
| 203 | + (GameModeInfo*)info | 251 | + (GameModeInfo*)info | 
| 204 | { | 252 | { | 
| 205 | [NSException raise:@"Unimplemented method" format:@"Method -info of GameMode subclasses must be overridden"]; | 253 | [NSException raise:@"Unimplemented method" format:@"Method -info of GameMode subclasses must be overridden"]; | 
| 206 | 254 | ||
| 207 | return nil; | 255 | return nil; | 
| 256 | } | ||
| 257 | |||
| 258 | - (void)setPitch:(double)m_pitch | ||
| 259 | { | ||
| 260 | pitch = m_pitch; | ||
| 261 | |||
| 262 | [cart deviceDidRotate:pitch]; | ||
| 208 | } | 263 | } | 
| 209 | 264 | ||
| 210 | - (void)dealloc | 265 | - (void)dealloc | 
| diff --git a/Classes/HighscoreListController.m b/Classes/HighscoreListController.m index 7370da5..c746421 100755 --- a/Classes/HighscoreListController.m +++ b/Classes/HighscoreListController.m | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | if (self) { | 24 | if (self) { | 
| 25 | localHighscores = [[Highscore localHighscoreListForGameMode:@"Collect"] retain]; | 25 | localHighscores = [[Highscore localHighscoreListForGameMode:@"Collect"] retain]; | 
| 26 | 26 | ||
| 27 | navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)]; | 27 | navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 480, 44)]; | 
| 28 | myNavigationItem = [[UINavigationItem alloc] initWithTitle:@"Highscores"]; | 28 | myNavigationItem = [[UINavigationItem alloc] initWithTitle:@"Highscores"]; | 
| 29 | UIBarButtonItem* barButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(back)]; | 29 | UIBarButtonItem* barButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(back)]; | 
| 30 | myNavigationItem.leftBarButtonItem = barButton; | 30 | myNavigationItem.leftBarButtonItem = barButton; | 
| @@ -45,7 +45,7 @@ | |||
| 45 | [modeControl addTarget:self action:@selector(switchGameMode:) forControlEvents:UIControlEventValueChanged]; | 45 | [modeControl addTarget:self action:@selector(switchGameMode:) forControlEvents:UIControlEventValueChanged]; | 
| 46 | UIBarButtonItem* barButton3 = [[UIBarButtonItem alloc] initWithCustomView:modeControl]; | 46 | UIBarButtonItem* barButton3 = [[UIBarButtonItem alloc] initWithCustomView:modeControl]; | 
| 47 | 47 | ||
| 48 | toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 480-44, 320, 44)]; | 48 | toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 320-44, 480, 44)]; | 
| 49 | [toolbar setItems:[NSArray arrayWithObjects:barButton3, btnSpace, barButton2, nil] animated:NO]; | 49 | [toolbar setItems:[NSArray arrayWithObjects:barButton3, btnSpace, barButton2, nil] animated:NO]; | 
| 50 | [barButton2 release]; | 50 | [barButton2 release]; | 
| 51 | [btnSpace release]; | 51 | [btnSpace release]; | 
| @@ -55,8 +55,8 @@ | |||
| 55 | loadingGlobal = NO; | 55 | loadingGlobal = NO; | 
| 56 | 56 | ||
| 57 | tableView = [(UITableView*)self.view retain]; | 57 | tableView = [(UITableView*)self.view retain]; | 
| 58 | UIView* parentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; | 58 | UIView* parentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 480, 320)]; | 
| 59 | [tableView setFrame:CGRectMake(0, 44, 320, 480-44-44)]; | 59 | [tableView setFrame:CGRectMake(0, 44, 480, 320-44-44)]; | 
| 60 | [parentView addSubview:navigationBar]; | 60 | [parentView addSubview:navigationBar]; | 
| 61 | [parentView addSubview:tableView]; | 61 | [parentView addSubview:tableView]; | 
| 62 | [parentView addSubview:toolbar]; | 62 | [parentView addSubview:toolbar]; | 
| @@ -101,9 +101,9 @@ | |||
| 101 | */ | 101 | */ | 
| 102 | /* | 102 | /* | 
| 103 | // Override to allow orientations other than the default portrait orientation. | 103 | // Override to allow orientations other than the default portrait orientation. | 
| 104 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { | 104 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation | 
| 105 | // Return YES for supported orientations. | 105 | { | 
| 106 | return YES; | 106 | return ( interfaceOrientation == UIInterfaceOrientationLandscapeRight ); | 
| 107 | } | 107 | } | 
| 108 | */ | 108 | */ | 
| 109 | 109 | ||
| @@ -183,7 +183,7 @@ | |||
| 183 | UILabel* scoreLabel = [[UILabel alloc] init]; | 183 | UILabel* scoreLabel = [[UILabel alloc] init]; | 
| 184 | scoreLabel.text = [NSString stringWithFormat:@"%d", highscore.score]; | 184 | scoreLabel.text = [NSString stringWithFormat:@"%d", highscore.score]; | 
| 185 | CGSize labelSize = [scoreLabel.text sizeWithFont:scoreLabel.font constrainedToSize:CGSizeMake(160, 44) lineBreakMode:UILineBreakModeClip]; | 185 | CGSize labelSize = [scoreLabel.text sizeWithFont:scoreLabel.font constrainedToSize:CGSizeMake(160, 44) lineBreakMode:UILineBreakModeClip]; | 
| 186 | scoreLabel.frame = CGRectMake(320-10-labelSize.width, 22-labelSize.height/2, labelSize.width, labelSize.height); | 186 | scoreLabel.frame = CGRectMake(480-10-labelSize.width, 22-labelSize.height/2, labelSize.width, labelSize.height); | 
| 187 | [cell addSubview:scoreLabel]; | 187 | [cell addSubview:scoreLabel]; | 
| 188 | [scoreLabel release]; | 188 | [scoreLabel release]; | 
| 189 | 189 | ||
| @@ -293,10 +293,10 @@ | |||
| 293 | { | 293 | { | 
| 294 | loadingGlobal = YES; | 294 | loadingGlobal = YES; | 
| 295 | 295 | ||
| 296 | loadingView = [[UIView alloc] initWithFrame:CGRectMake(0, 44, 320, 480-44-44)]; | 296 | loadingView = [[UIView alloc] initWithFrame:CGRectMake(0, 44, 480, 320-44-44)]; | 
| 297 | activity = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(150, 228-44, 20, 20)]; | 297 | activity = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(230, 148-44, 20, 20)]; | 
| 298 | activity.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; | 298 | activity.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; | 
| 299 | statusText = [[UILabel alloc] initWithFrame:CGRectMake(0, 256-44, 320, 21)]; | 299 | statusText = [[UILabel alloc] initWithFrame:CGRectMake(80, 150, 320, 21)]; | 
| 300 | statusText.text = @"Downloading highscores..."; | 300 | statusText.text = @"Downloading highscores..."; | 
| 301 | statusText.textAlignment = UITextAlignmentCenter; | 301 | statusText.textAlignment = UITextAlignmentCenter; | 
| 302 | 302 | ||
| diff --git a/Classes/JumpGameMode.m b/Classes/JumpGameMode.m index 3788c97..f3e690c 100644 --- a/Classes/JumpGameMode.m +++ b/Classes/JumpGameMode.m | |||
| @@ -25,7 +25,19 @@ | |||
| 25 | 25 | ||
| 26 | @end | 26 | @end | 
| 27 | 27 | ||
| 28 | // FallingObject flag 0 is whether the object is floating in water | 28 | @implementation FallingObject (Flags) | 
| 29 | |||
| 30 | - (BOOL)fellDuringWave | ||
| 31 | { | ||
| 32 | return flags[0]; | ||
| 33 | } | ||
| 34 | |||
| 35 | - (void)setFellDuringWave:(BOOL)value | ||
| 36 | { | ||
| 37 | flags[0] = value; | ||
| 38 | } | ||
| 39 | |||
| 40 | @end | ||
| 29 | 41 | ||
| 30 | @implementation JumpGameMode | 42 | @implementation JumpGameMode | 
| 31 | 43 | ||
| @@ -141,10 +153,12 @@ static GameModeInfo* info; | |||
| 141 | } | 153 | } | 
| 142 | } | 154 | } | 
| 143 | 155 | ||
| 156 | [ledges minusSet:discardedSet]; | ||
| 157 | |||
| 144 | NSMutableSet* discardedObjects = [NSMutableSet set]; | 158 | NSMutableSet* discardedObjects = [NSMutableSet set]; | 
| 145 | for (FallingObject* object in objects) | 159 | for (FallingObject* object in objects) | 
| 146 | { | 160 | { | 
| 147 | if ((object.sprite.position.y < 86) && (![object flag:0])) | 161 | if (object.sprite.position.y < (64+object.sprite.boundingBox.size.height/2)) | 
| 148 | { | 162 | { | 
| 149 | for (CCSprite* ledge in ledges) | 163 | for (CCSprite* ledge in ledges) | 
| 150 | { | 164 | { | 
| @@ -167,20 +181,14 @@ static GameModeInfo* info; | |||
| 167 | } | 181 | } | 
| 168 | } | 182 | } | 
| 169 | 183 | ||
| 170 | if ((waterTick >= 180) || ((waterTick > 0) && ([object flag:0]))) | 184 | if (object.fellDuringWave) | 
| 171 | { | 185 | { | 
| 172 | object.sprite.position = ccp(object.sprite.position.x, MAX(object.sprite.position.y, water.position.y+80+11)); | 186 | object.sprite.position = ccp(object.sprite.position.x, MAX(object.sprite.position.y, water.position.y+80+11)); | 
| 173 | } else { | 187 | } else { | 
| 174 | object.sprite.position = ccp(object.sprite.position.x-ledgeScrollSpeed, object.sprite.position.y); | 188 | object.sprite.position = ccp(object.sprite.position.x-ledgeScrollSpeed, object.sprite.position.y); | 
| 175 | } | 189 | } | 
| 176 | |||
| 177 | if ((waterTick > 0) && (object.sprite.position.y <= (water.position.y+80+11))) | ||
| 178 | { | ||
| 179 | [object setFlag:0 withValue:YES]; | ||
| 180 | } | ||
| 181 | } | 190 | } | 
| 182 | 191 | ||
| 183 | [ledges minusSet:discardedSet]; | ||
| 184 | [objects minusSet:discardedObjects]; | 192 | [objects minusSet:discardedObjects]; | 
| 185 | 193 | ||
| 186 | if (rightmost <= 480) | 194 | if (rightmost <= 480) | 
| @@ -205,6 +213,9 @@ static GameModeInfo* info; | |||
| 205 | if ((cart.sprite.position.y < 86) && (cart.boundedByScreen)) | 213 | if ((cart.sprite.position.y < 86) && (cart.boundedByScreen)) | 
| 206 | { | 214 | { | 
| 207 | cart.boundedByScreen = NO; | 215 | cart.boundedByScreen = NO; | 
| 216 | } else if ((cart.sprite.position.y >= 86) && (!cart.boundedByScreen)) | ||
| 217 | { | ||
| 218 | cart.boundedByScreen = YES; | ||
| 208 | } | 219 | } | 
| 209 | 220 | ||
| 210 | if (cart.sprite.position.y == (0-cart.sprite.boundingBox.size.height/2)) | 221 | if (cart.sprite.position.y == (0-cart.sprite.boundingBox.size.height/2)) | 
| @@ -300,13 +311,6 @@ static GameModeInfo* info; | |||
| 300 | isGesturing = NO; | 311 | isGesturing = NO; | 
| 301 | } | 312 | } | 
| 302 | 313 | ||
| 303 | - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration | ||
| 304 | { | ||
| 305 | [super accelerometer:accelerometer didAccelerate:acceleration]; | ||
| 306 | |||
| 307 | expectedAngle = acceleration.y*M_PI_2; | ||
| 308 | } | ||
| 309 | |||
| 310 | - (int)cartShouldFall:(Cart *)m_cart | 314 | - (int)cartShouldFall:(Cart *)m_cart | 
| 311 | { | 315 | { | 
| 312 | int bottom = 0-m_cart.sprite.boundingBox.size.height/2; | 316 | int bottom = 0-m_cart.sprite.boundingBox.size.height/2; | 
| @@ -416,6 +420,7 @@ static GameModeInfo* info; | |||
| 416 | object.delegate = self; | 420 | object.delegate = self; | 
| 417 | object.sprite.position = ccp(objectX, 360); | 421 | object.sprite.position = ccp(objectX, 360); | 
| 418 | object.sprite.scale = 1; | 422 | object.sprite.scale = 1; | 
| 423 | object.fellDuringWave = waterTick > 0; | ||
| 419 | [self addChild:object.sprite]; | 424 | [self addChild:object.sprite]; | 
| 420 | 425 | ||
| 421 | [objects addObject:object]; | 426 | [objects addObject:object]; | 
| @@ -450,6 +455,7 @@ static GameModeInfo* info; | |||
| 450 | object.delegate = self; | 455 | object.delegate = self; | 
| 451 | object.sprite.position = ccp(objectX, 360); | 456 | object.sprite.position = ccp(objectX, 360); | 
| 452 | object.sprite.scale = 1; | 457 | object.sprite.scale = 1; | 
| 458 | object.fellDuringWave = waterTick > 0; | ||
| 453 | [self addChild:object.sprite]; | 459 | [self addChild:object.sprite]; | 
| 454 | 460 | ||
| 455 | [objects addObject:object]; | 461 | [objects addObject:object]; | 
| @@ -486,6 +492,7 @@ static GameModeInfo* info; | |||
| 486 | object.delegate = self; | 492 | object.delegate = self; | 
| 487 | object.sprite.position = ccp(objectX, 360); | 493 | object.sprite.position = ccp(objectX, 360); | 
| 488 | object.sprite.scale = 1; | 494 | object.sprite.scale = 1; | 
| 495 | object.fellDuringWave = waterTick > 0; | ||
| 489 | [self addChild:object.sprite]; | 496 | [self addChild:object.sprite]; | 
| 490 | 497 | ||
| 491 | [objects addObject:object]; | 498 | [objects addObject:object]; | 
| @@ -528,6 +535,13 @@ static GameModeInfo* info; | |||
| 528 | } | 535 | } | 
| 529 | } | 536 | } | 
| 530 | 537 | ||
| 538 | - (void)setPitch:(double)m_pitch | ||
| 539 | { | ||
| 540 | [super setPitch:m_pitch]; | ||
| 541 | |||
| 542 | expectedAngle = pitch*M_PI_2; | ||
| 543 | } | ||
| 544 | |||
| 531 | @end | 545 | @end | 
| 532 | 546 | ||
| 533 | @implementation LedgeFactory | 547 | @implementation LedgeFactory | 
