summary refs log tree commit diff stats
path: root/Classes
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-09-10 10:25:25 -0400
committerStarla Insigna <starla4444@gmail.com>2011-09-10 10:25:25 -0400
commitc5edc8808e9f9dbb1daeda760ba74ef0cf2e9dce (patch)
tree07a4064c546cab9a130a3f3b13c762c190f9749a /Classes
parentab9f7381455b334fa0df563e21775410be74ea45 (diff)
downloadcartcollect-c5edc8808e9f9dbb1daeda760ba74ef0cf2e9dce.tar.gz
cartcollect-c5edc8808e9f9dbb1daeda760ba74ef0cf2e9dce.tar.bz2
cartcollect-c5edc8808e9f9dbb1daeda760ba74ef0cf2e9dce.zip
Modified behavior of falling objects in Jump v0.4.5
Also increased the distance between ledges as the game goes on, and changed the sound point multipliers make when you catch them.

Closes #221, #223
Diffstat (limited to 'Classes')
-rwxr-xr-xClasses/FallingObject.h3
-rwxr-xr-xClasses/FallingObject.m10
-rw-r--r--Classes/JumpGameMode.m37
-rw-r--r--Classes/PointMultiplier.m2
4 files changed, 49 insertions, 3 deletions
diff --git a/Classes/FallingObject.h b/Classes/FallingObject.h index 3e28903..d3ac638 100755 --- a/Classes/FallingObject.h +++ b/Classes/FallingObject.h
@@ -14,6 +14,7 @@
14 CCSprite* sprite; 14 CCSprite* sprite;
15 int weight; 15 int weight;
16 id<FallingObjectDelegate> delegate; 16 id<FallingObjectDelegate> delegate;
17 BOOL flags[4];
17} 18}
18 19
19@property (readonly) CCSprite* sprite; 20@property (readonly) CCSprite* sprite;
@@ -23,5 +24,7 @@
23- (BOOL)tick; 24- (BOOL)tick;
24- (void)collideWithCart; 25- (void)collideWithCart;
25- (void)collideWithFloor; 26- (void)collideWithFloor;
27- (BOOL)flag:(int)flag;
28- (void)setFlag:(int)flag withValue:(BOOL)value;
26 29
27@end 30@end
diff --git a/Classes/FallingObject.m b/Classes/FallingObject.m index 85ea902..86edd15 100755 --- a/Classes/FallingObject.m +++ b/Classes/FallingObject.m
@@ -93,6 +93,16 @@
93 93
94} 94}
95 95
96- (BOOL)flag:(int)flag
97{
98 return flags[flag];
99}
100
101- (void)setFlag:(int)flag withValue:(BOOL)value
102{
103 flags[flag] = value;
104}
105
96- (void)dealloc 106- (void)dealloc
97{ 107{
98 [sprite.parent removeChild:sprite cleanup:YES]; 108 [sprite.parent removeChild:sprite cleanup:YES];
diff --git a/Classes/JumpGameMode.m b/Classes/JumpGameMode.m index 9076426..14cd365 100644 --- a/Classes/JumpGameMode.m +++ b/Classes/JumpGameMode.m
@@ -30,6 +30,8 @@
30 30
31@end 31@end
32 32
33// FallingObject flag 0 is whether the object is floating in water
34
33@implementation JumpGameMode 35@implementation JumpGameMode
34 36
35- (id)init 37- (id)init
@@ -116,24 +118,55 @@
116 } 118 }
117 } 119 }
118 120
121 NSMutableSet* discardedObjects = [NSMutableSet set];
119 for (FallingObject* object in objects) 122 for (FallingObject* object in objects)
120 { 123 {
121 if (waterTick > 0) 124 if ((object.sprite.position.y < 86) && (![object flag:0]))
125 {
126 for (CCSprite* ledge in ledges)
127 {
128 CGSize first = [object.sprite boundingBox].size;
129 CGSize second = [ledge boundingBox].size;
130
131 if (object.sprite.position.x > (ledge.position.x - second.width/2 - first.width/2))
132 {
133 if (object.sprite.position.x < (ledge.position.x + second.width/2 + first.width/2))
134 {
135 if (object.sprite.position.y > (ledge.position.y - second.height/2 - first.height/2))
136 {
137 if (object.sprite.position.y < (ledge.position.y + second.height/2 + first.height/2))
138 {
139 [discardedObjects addObject:object];
140 }
141 }
142 }
143 }
144 }
145 }
146
147 if ((waterTick >= 180) || ([object flag:0]))
122 { 148 {
123 object.sprite.position = ccp(object.sprite.position.x, MAX(object.sprite.position.y, water.position.y+80+11)); 149 object.sprite.position = ccp(object.sprite.position.x, MAX(object.sprite.position.y, water.position.y+80+11));
124 } else { 150 } else {
125 object.sprite.position = ccp(object.sprite.position.x-ledgeScrollSpeed, object.sprite.position.y); 151 object.sprite.position = ccp(object.sprite.position.x-ledgeScrollSpeed, object.sprite.position.y);
126 } 152 }
153
154 if ((waterTick > 0) && (object.sprite.position.y <= (water.position.y+80+11)))
155 {
156 [object setFlag:0 withValue:YES];
157 }
127 } 158 }
128 159
129 [ledges minusSet:discardedSet]; 160 [ledges minusSet:discardedSet];
161 [objects minusSet:discardedObjects];
130 162
131 if (rightmost <= 480) 163 if (rightmost <= 480)
132 { 164 {
133 int ledgeWidth = arc4random() % 9 + 1; 165 int ledgeWidth = arc4random() % 9 + 1;
166 int ledgeDistance = arc4random() % (ledgeScrollSpeed*ledgeScrollSpeed+1)*3/2;
134 CCTexture2D* texture = [[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:ledgeWidth height:2]]; 167 CCTexture2D* texture = [[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:ledgeWidth height:2]];
135 CCSprite* ledge = [CCSprite spriteWithTexture:texture]; 168 CCSprite* ledge = [CCSprite spriteWithTexture:texture];
136 ledge.position = ccp(rightmost + rightwidth + ledge.boundingBox.size.width/2+64, 32); 169 ledge.position = ccp(rightmost + rightwidth + ledge.boundingBox.size.width/2+64+ledgeDistance, 32);
137 [self addChild:ledge]; 170 [self addChild:ledge];
138 [ledges addObject:ledge]; 171 [ledges addObject:ledge];
139 [texture release]; 172 [texture release];
diff --git a/Classes/PointMultiplier.m b/Classes/PointMultiplier.m index a14bf68..0a9649d 100644 --- a/Classes/PointMultiplier.m +++ b/Classes/PointMultiplier.m
@@ -30,7 +30,7 @@
30 GameMode* gameLayer = ((GameMode*) sprite.parent); 30 GameMode* gameLayer = ((GameMode*) sprite.parent);
31 [gameLayer setPointMultiplier:gameLayer.pointMultiplier+1]; 31 [gameLayer setPointMultiplier:gameLayer.pointMultiplier+1];
32 32
33 [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Item1" ofType:@"wav"]]; 33 [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Absorption2" ofType:@"wav"]];
34} 34}
35 35
36@end 36@end