diff options
author | Starla Insigna <starla4444@gmail.com> | 2011-09-10 14:33:27 -0400 |
---|---|---|
committer | Starla Insigna <starla4444@gmail.com> | 2011-09-10 14:33:27 -0400 |
commit | 5ccc4fc305f502a552b1ac7e815e576c93a8159a (patch) | |
tree | 5bf4ede55160769ab74ffde1488f5382ed3ba93f | |
parent | f7ce2c458df032f65c4c1eb31cf705bb284a3ee7 (diff) | |
download | cartcollect-0.4.6.tar.gz cartcollect-0.4.6.tar.bz2 cartcollect-0.4.6.zip |
Jump: Allowed cart to be pushed off side of screen when below ledges v0.4.6
Closes #227
-rw-r--r-- | Classes/Cart.h | 2 | ||||
-rw-r--r-- | Classes/Cart.m | 11 | ||||
-rw-r--r-- | Classes/JumpGameMode.m | 13 |
3 files changed, 23 insertions, 3 deletions
diff --git a/Classes/Cart.h b/Classes/Cart.h index 302e5ec..1058025 100644 --- a/Classes/Cart.h +++ b/Classes/Cart.h | |||
@@ -16,12 +16,14 @@ | |||
16 | BOOL immobile; | 16 | BOOL immobile; |
17 | id<CartDelegate> delegate; | 17 | id<CartDelegate> delegate; |
18 | BOOL falling; | 18 | BOOL falling; |
19 | BOOL boundedByScreen; | ||
19 | } | 20 | } |
20 | 21 | ||
21 | @property (readonly) CCSprite* sprite; | 22 | @property (readonly) CCSprite* sprite; |
22 | @property (assign) BOOL immobile; | 23 | @property (assign) BOOL immobile; |
23 | @property (nonatomic,retain) id<CartDelegate> delegate; | 24 | @property (nonatomic,retain) id<CartDelegate> delegate; |
24 | @property (assign) BOOL falling; | 25 | @property (assign) BOOL falling; |
26 | @property (assign) BOOL boundedByScreen; | ||
25 | - (id)initWithSprite:(CCSprite*)sprite; | 27 | - (id)initWithSprite:(CCSprite*)sprite; |
26 | - (void)tick; | 28 | - (void)tick; |
27 | - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration; | 29 | - (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration; |
diff --git a/Classes/Cart.m b/Classes/Cart.m index cfe7ee7..0344bdf 100644 --- a/Classes/Cart.m +++ b/Classes/Cart.m | |||
@@ -10,7 +10,7 @@ | |||
10 | 10 | ||
11 | @implementation Cart | 11 | @implementation Cart |
12 | 12 | ||
13 | @synthesize sprite, immobile, delegate, falling; | 13 | @synthesize sprite, immobile, delegate, falling, boundedByScreen; |
14 | 14 | ||
15 | - (id)initWithSprite:(CCSprite*)m_sprite | 15 | - (id)initWithSprite:(CCSprite*)m_sprite |
16 | { | 16 | { |
@@ -21,6 +21,7 @@ | |||
21 | sprite = m_sprite; | 21 | sprite = m_sprite; |
22 | immobile = NO; | 22 | immobile = NO; |
23 | falling = NO; | 23 | falling = NO; |
24 | boundedByScreen = YES; | ||
24 | } | 25 | } |
25 | 26 | ||
26 | return self; | 27 | return self; |
@@ -32,7 +33,13 @@ | |||
32 | { | 33 | { |
33 | // Move the cart based on acceleration gathered from accelerometer | 34 | // Move the cart based on acceleration gathered from accelerometer |
34 | CGPoint prevLoc = sprite.position; | 35 | CGPoint prevLoc = sprite.position; |
35 | sprite.position = ccp(MIN(MAX(sprite.position.x+accelX, 16),464), sprite.position.y); | 36 | |
37 | if (boundedByScreen) | ||
38 | { | ||
39 | sprite.position = ccp(MIN(MAX(sprite.position.x+accelX, 16),464), sprite.position.y); | ||
40 | } else { | ||
41 | sprite.position = ccp(sprite.position.x+accelX, sprite.position.y); | ||
42 | } | ||
36 | 43 | ||
37 | if ((delegate != nil) && ([delegate respondsToSelector:@selector(cartIsObstructed:)])) | 44 | if ((delegate != nil) && ([delegate respondsToSelector:@selector(cartIsObstructed:)])) |
38 | { | 45 | { |
diff --git a/Classes/JumpGameMode.m b/Classes/JumpGameMode.m index e4f3c8b..15b0e16 100644 --- a/Classes/JumpGameMode.m +++ b/Classes/JumpGameMode.m | |||
@@ -179,13 +179,24 @@ | |||
179 | 179 | ||
180 | [super tick:dt]; | 180 | [super tick:dt]; |
181 | 181 | ||
182 | if ((cart.sprite.position.y < 86) && (cart.boundedByScreen)) | ||
183 | { | ||
184 | cart.boundedByScreen = NO; | ||
185 | } | ||
186 | |||
182 | if (cart.sprite.position.y == (0-cart.sprite.boundingBox.size.height/2)) | 187 | if (cart.sprite.position.y == (0-cart.sprite.boundingBox.size.height/2)) |
183 | { | 188 | { |
184 | [self setLives:self.lives-1]; | 189 | [self setLives:self.lives-1]; |
190 | cart.boundedByScreen = YES; | ||
185 | 191 | ||
186 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Damage1" ofType:@"wav"]]; | 192 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Damage1" ofType:@"wav"]]; |
187 | 193 | ||
188 | cart.sprite.position = ccp(cart.sprite.position.x, 320 + cart.sprite.boundingBox.size.height/2); | 194 | if (cart.sprite.position.x < cart.sprite.boundingBox.size.width/2) |
195 | { | ||
196 | cart.sprite.position = ccp(cart.sprite.boundingBox.size.width, 320 + cart.sprite.boundingBox.size.height/2); | ||
197 | } else { | ||
198 | cart.sprite.position = ccp(cart.sprite.position.x, 320 + cart.sprite.boundingBox.size.height/2); | ||
199 | } | ||
189 | } | 200 | } |
190 | 201 | ||
191 | if (lives <= 0) | 202 | if (lives <= 0) |