summary refs log tree commit diff stats
path: root/Classes/JumpGameMode.m
diff options
context:
space:
mode:
Diffstat (limited to 'Classes/JumpGameMode.m')
-rw-r--r--Classes/JumpGameMode.m29
1 files changed, 20 insertions, 9 deletions
diff --git a/Classes/JumpGameMode.m b/Classes/JumpGameMode.m index 1e55b48..b192058 100644 --- a/Classes/JumpGameMode.m +++ b/Classes/JumpGameMode.m
@@ -30,7 +30,19 @@
30 30
31@end 31@end
32 32
33// FallingObject flag 0 is whether the object is floating in water 33@implementation FallingObject (Flags)
34
35- (BOOL)fellDuringWave
36{
37 return flags[0];
38}
39
40- (void)setFellDuringWave:(BOOL)value
41{
42 flags[0] = value;
43}
44
45@end
34 46
35@implementation JumpGameMode 47@implementation JumpGameMode
36 48
@@ -118,10 +130,12 @@
118 } 130 }
119 } 131 }
120 132
133 [ledges minusSet:discardedSet];
134
121 NSMutableSet* discardedObjects = [NSMutableSet set]; 135 NSMutableSet* discardedObjects = [NSMutableSet set];
122 for (FallingObject* object in objects) 136 for (FallingObject* object in objects)
123 { 137 {
124 if ((object.sprite.position.y < 86) && (![object flag:0])) 138 if (object.sprite.position.y < (64+object.sprite.boundingBox.size.height/2))
125 { 139 {
126 for (CCSprite* ledge in ledges) 140 for (CCSprite* ledge in ledges)
127 { 141 {
@@ -144,20 +158,14 @@
144 } 158 }
145 } 159 }
146 160
147 if ((waterTick >= 180) || ((waterTick > 0) && ([object flag:0]))) 161 if (object.fellDuringWave)
148 { 162 {
149 object.sprite.position = ccp(object.sprite.position.x, MAX(object.sprite.position.y, water.position.y+80+11)); 163 object.sprite.position = ccp(object.sprite.position.x, MAX(object.sprite.position.y, water.position.y+80+11));
150 } else { 164 } else {
151 object.sprite.position = ccp(object.sprite.position.x-ledgeScrollSpeed, object.sprite.position.y); 165 object.sprite.position = ccp(object.sprite.position.x-ledgeScrollSpeed, object.sprite.position.y);
152 } 166 }
153
154 if ((waterTick > 0) && (object.sprite.position.y <= (water.position.y+80+11)))
155 {
156 [object setFlag:0 withValue:YES];
157 }
158 } 167 }
159 168
160 [ledges minusSet:discardedSet];
161 [objects minusSet:discardedObjects]; 169 [objects minusSet:discardedObjects];
162 170
163 if (rightmost <= 480) 171 if (rightmost <= 480)
@@ -396,6 +404,7 @@
396 404
397 object.sprite.position = ccp(objectX, 360); 405 object.sprite.position = ccp(objectX, 360);
398 object.sprite.scale = 1; 406 object.sprite.scale = 1;
407 object.fellDuringWave = waterTick > 0;
399 [self addChild:object.sprite]; 408 [self addChild:object.sprite];
400 409
401 [objects addObject:object]; 410 [objects addObject:object];
@@ -429,6 +438,7 @@
429 438
430 object.sprite.position = ccp(objectX, 360); 439 object.sprite.position = ccp(objectX, 360);
431 object.sprite.scale = 1; 440 object.sprite.scale = 1;
441 object.fellDuringWave = waterTick > 0;
432 [self addChild:object.sprite]; 442 [self addChild:object.sprite];
433 443
434 [objects addObject:object]; 444 [objects addObject:object];
@@ -464,6 +474,7 @@
464 474
465 object.sprite.position = ccp(objectX, 360); 475 object.sprite.position = ccp(objectX, 360);
466 object.sprite.scale = 1; 476 object.sprite.scale = 1;
477 object.fellDuringWave = waterTick > 0;
467 [self addChild:object.sprite]; 478 [self addChild:object.sprite];
468 479
469 [objects addObject:object]; 480 [objects addObject:object];