From c5edc8808e9f9dbb1daeda760ba74ef0cf2e9dce Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Sat, 10 Sep 2011 10:25:25 -0400 Subject: Modified behavior of falling objects in Jump 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 --- Cartographic.xcodeproj/project.pbxproj | 4 ++++ Classes/FallingObject.h | 3 +++ Classes/FallingObject.m | 10 +++++++++ Classes/JumpGameMode.m | 37 +++++++++++++++++++++++++++++++-- Classes/PointMultiplier.m | 2 +- Resources/Absorption2.wav | Bin 0 -> 51044 bytes 6 files changed, 53 insertions(+), 3 deletions(-) create mode 100755 Resources/Absorption2.wav diff --git a/Cartographic.xcodeproj/project.pbxproj b/Cartographic.xcodeproj/project.pbxproj index 1a41374..75343b3 100755 --- a/Cartographic.xcodeproj/project.pbxproj +++ b/Cartographic.xcodeproj/project.pbxproj @@ -131,6 +131,7 @@ 6CDBE80C14092DB00072F287 /* ledge.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CDBE80B14092DB00072F287 /* ledge.png */; }; 6CF64C09141B9FA300F3B702 /* PointMultiplier.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CF64C08141B9FA300F3B702 /* PointMultiplier.m */; }; 6CF64C0B141BA37000F3B702 /* multiplier.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CF64C0A141BA37000F3B702 /* multiplier.png */; }; + 6CF64C11141BA84200F3B702 /* Absorption2.wav in Resources */ = {isa = PBXBuildFile; fileRef = 6CF64C10141BA84200F3B702 /* Absorption2.wav */; }; DC6640030F83B3EA000B3E49 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */; }; DC6640050F83B3EA000B3E49 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640040F83B3EA000B3E49 /* OpenAL.framework */; }; DCCBF1B70F6022AE0040855A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */; }; @@ -476,6 +477,7 @@ 6CF64C07141B9FA300F3B702 /* PointMultiplier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PointMultiplier.h; sourceTree = ""; }; 6CF64C08141B9FA300F3B702 /* PointMultiplier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PointMultiplier.m; sourceTree = ""; }; 6CF64C0A141BA37000F3B702 /* multiplier.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = multiplier.png; sourceTree = ""; }; + 6CF64C10141BA84200F3B702 /* Absorption2.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = Absorption2.wav; sourceTree = ""; }; DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; DC6640040F83B3EA000B3E49 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; @@ -809,6 +811,7 @@ 3F6C7F4E13D647C500C038FE /* Sounds */ = { isa = PBXGroup; children = ( + 6CF64C10141BA84200F3B702 /* Absorption2.wav */, 3F6C7EC513D6335A00C038FE /* 1up.wav */, 3F6C7C4813D5DEDB00C038FE /* Item1.wav */, 3F6C7C3313D5DEB100C038FE /* Damage1.wav */, @@ -1488,6 +1491,7 @@ 6C85834614056E57009EF100 /* venice.png in Resources */, 6CDBE80C14092DB00072F287 /* ledge.png in Resources */, 6CF64C0B141BA37000F3B702 /* multiplier.png in Resources */, + 6CF64C11141BA84200F3B702 /* Absorption2.wav in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; 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 @@ CCSprite* sprite; int weight; id delegate; + BOOL flags[4]; } @property (readonly) CCSprite* sprite; @@ -23,5 +24,7 @@ - (BOOL)tick; - (void)collideWithCart; - (void)collideWithFloor; +- (BOOL)flag:(int)flag; +- (void)setFlag:(int)flag withValue:(BOOL)value; @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 @@ } +- (BOOL)flag:(int)flag +{ + return flags[flag]; +} + +- (void)setFlag:(int)flag withValue:(BOOL)value +{ + flags[flag] = value; +} + - (void)dealloc { [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 @@ @end +// FallingObject flag 0 is whether the object is floating in water + @implementation JumpGameMode - (id)init @@ -116,24 +118,55 @@ } } + NSMutableSet* discardedObjects = [NSMutableSet set]; for (FallingObject* object in objects) { - if (waterTick > 0) + if ((object.sprite.position.y < 86) && (![object flag:0])) + { + for (CCSprite* ledge in ledges) + { + CGSize first = [object.sprite boundingBox].size; + CGSize second = [ledge boundingBox].size; + + if (object.sprite.position.x > (ledge.position.x - second.width/2 - first.width/2)) + { + if (object.sprite.position.x < (ledge.position.x + second.width/2 + first.width/2)) + { + if (object.sprite.position.y > (ledge.position.y - second.height/2 - first.height/2)) + { + if (object.sprite.position.y < (ledge.position.y + second.height/2 + first.height/2)) + { + [discardedObjects addObject:object]; + } + } + } + } + } + } + + if ((waterTick >= 180) || ([object flag:0])) { object.sprite.position = ccp(object.sprite.position.x, MAX(object.sprite.position.y, water.position.y+80+11)); } else { object.sprite.position = ccp(object.sprite.position.x-ledgeScrollSpeed, object.sprite.position.y); } + + if ((waterTick > 0) && (object.sprite.position.y <= (water.position.y+80+11))) + { + [object setFlag:0 withValue:YES]; + } } [ledges minusSet:discardedSet]; + [objects minusSet:discardedObjects]; if (rightmost <= 480) { int ledgeWidth = arc4random() % 9 + 1; + int ledgeDistance = arc4random() % (ledgeScrollSpeed*ledgeScrollSpeed+1)*3/2; CCTexture2D* texture = [[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:ledgeWidth height:2]]; CCSprite* ledge = [CCSprite spriteWithTexture:texture]; - ledge.position = ccp(rightmost + rightwidth + ledge.boundingBox.size.width/2+64, 32); + ledge.position = ccp(rightmost + rightwidth + ledge.boundingBox.size.width/2+64+ledgeDistance, 32); [self addChild:ledge]; [ledges addObject:ledge]; [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 @@ GameMode* gameLayer = ((GameMode*) sprite.parent); [gameLayer setPointMultiplier:gameLayer.pointMultiplier+1]; - [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Item1" ofType:@"wav"]]; + [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Absorption2" ofType:@"wav"]]; } @end diff --git a/Resources/Absorption2.wav b/Resources/Absorption2.wav new file mode 100755 index 0000000..d508ab4 Binary files /dev/null and b/Resources/Absorption2.wav differ -- cgit 1.4.1