diff options
author | Starla Insigna <starla4444@gmail.com> | 2011-09-10 10:25:25 -0400 |
---|---|---|
committer | Starla Insigna <starla4444@gmail.com> | 2011-09-10 10:25:25 -0400 |
commit | c5edc8808e9f9dbb1daeda760ba74ef0cf2e9dce (patch) | |
tree | 07a4064c546cab9a130a3f3b13c762c190f9749a /Classes/JumpGameMode.m | |
parent | ab9f7381455b334fa0df563e21775410be74ea45 (diff) | |
download | cartcollect-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/JumpGameMode.m')
-rw-r--r-- | Classes/JumpGameMode.m | 37 |
1 files changed, 35 insertions, 2 deletions
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]; |