diff options
author | Starla Insigna <starla4444@gmail.com> | 2011-09-04 11:17:44 -0400 |
---|---|---|
committer | Starla Insigna <starla4444@gmail.com> | 2011-09-04 11:17:44 -0400 |
commit | 339f8e2cb2fce18f6d32b3881a5cd390c0be488e (patch) | |
tree | cb17c635d664838259e591f4b345ae6349931d49 /Classes/Cart.m | |
parent | 9f4bf94a763afba795fb991006081505c3ae466b (diff) | |
download | cartcollect-339f8e2cb2fce18f6d32b3881a5cd390c0be488e.tar.gz cartcollect-339f8e2cb2fce18f6d32b3881a5cd390c0be488e.tar.bz2 cartcollect-339f8e2cb2fce18f6d32b3881a5cd390c0be488e.zip |
Implemented Jump mode (BETA) jump
Dear god this is beta. I think I'll release a build for the testers soon so I can see what people think and then hammer out the bugs. Refs #204
Diffstat (limited to 'Classes/Cart.m')
-rw-r--r-- | Classes/Cart.m | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/Classes/Cart.m b/Classes/Cart.m index 45c370c..cfe7ee7 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; | 13 | @synthesize sprite, immobile, delegate, falling; |
14 | 14 | ||
15 | - (id)initWithSprite:(CCSprite*)m_sprite | 15 | - (id)initWithSprite:(CCSprite*)m_sprite |
16 | { | 16 | { |
@@ -20,6 +20,7 @@ | |||
20 | { | 20 | { |
21 | sprite = m_sprite; | 21 | sprite = m_sprite; |
22 | immobile = NO; | 22 | immobile = NO; |
23 | falling = NO; | ||
23 | } | 24 | } |
24 | 25 | ||
25 | return self; | 26 | return self; |
@@ -30,7 +31,27 @@ | |||
30 | if (!immobile) | 31 | if (!immobile) |
31 | { | 32 | { |
32 | // Move the cart based on acceleration gathered from accelerometer | 33 | // Move the cart based on acceleration gathered from accelerometer |
34 | CGPoint prevLoc = sprite.position; | ||
33 | sprite.position = ccp(MIN(MAX(sprite.position.x+accelX, 16),464), sprite.position.y); | 35 | sprite.position = ccp(MIN(MAX(sprite.position.x+accelX, 16),464), sprite.position.y); |
36 | |||
37 | if ((delegate != nil) && ([delegate respondsToSelector:@selector(cartIsObstructed:)])) | ||
38 | { | ||
39 | if ([delegate cartIsObstructed:self]) | ||
40 | { | ||
41 | sprite.position = prevLoc; | ||
42 | } | ||
43 | } | ||
44 | |||
45 | if (falling) | ||
46 | { | ||
47 | if ((delegate != nil) && ([delegate respondsToSelector:@selector(cartShouldFall:)])) | ||
48 | { | ||
49 | int bottom = [delegate cartShouldFall:self]; | ||
50 | sprite.position = ccp(sprite.position.x, MAX(bottom, sprite.position.y-6)); | ||
51 | } else { | ||
52 | NSLog(@"Falling is set on a cart without a compatible game mode."); | ||
53 | } | ||
54 | } | ||
34 | } | 55 | } |
35 | } | 56 | } |
36 | 57 | ||