From ab9f7381455b334fa0df563e21775410be74ea45 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Sat, 10 Sep 2011 10:04:18 -0400 Subject: Added point multipliers There is support for point multipliers for any game mode, but only Jump currently utilizes it. Closes #222 --- Cartographic.xcodeproj/project.pbxproj | 10 +++++++ Classes/GameMode.h | 2 ++ Classes/GameMode.m | 22 ++++++++++++++-- Classes/JumpGameMode.m | 46 ++++++++++++++++++--------------- Classes/PointMultiplier.h | 15 +++++++++++ Classes/PointMultiplier.m | 36 ++++++++++++++++++++++++++ Resources/multiplier.png | Bin 0 -> 1131 bytes 7 files changed, 108 insertions(+), 23 deletions(-) create mode 100644 Classes/PointMultiplier.h create mode 100644 Classes/PointMultiplier.m create mode 100755 Resources/multiplier.png diff --git a/Cartographic.xcodeproj/project.pbxproj b/Cartographic.xcodeproj/project.pbxproj index 8fd0d47..1a41374 100755 --- a/Cartographic.xcodeproj/project.pbxproj +++ b/Cartographic.xcodeproj/project.pbxproj @@ -129,6 +129,8 @@ 6CC89DD913F2F4E6003704F7 /* Entitlements.plist in Resources */ = {isa = PBXBuildFile; fileRef = 6CC89DD813F2F4E6003704F7 /* Entitlements.plist */; }; 6CC89DDF13F31413003704F7 /* TutorialMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CC89DDE13F31413003704F7 /* TutorialMode.m */; }; 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 */; }; 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 */; }; @@ -471,6 +473,9 @@ 6CC89DE013F3197F003704F7 /* FallingObjectDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FallingObjectDelegate.h; sourceTree = ""; }; 6CDBE80B14092DB00072F287 /* ledge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ledge.png; sourceTree = ""; }; 6CDBE80E140936CF0072F287 /* CartDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CartDelegate.h; sourceTree = ""; }; + 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 = ""; }; 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; }; @@ -788,6 +793,7 @@ 3F6C7F4D13D647B600C038FE /* Sprites */ = { isa = PBXGroup; children = ( + 6CF64C0A141BA37000F3B702 /* multiplier.png */, 6CDBE80B14092DB00072F287 /* ledge.png */, 6C39CFE613FC46CD002B21AF /* water.png */, 6C29041113EAEC8A0032DA0F /* framestuff.png */, @@ -973,6 +979,8 @@ 6C0C141013F2099B003A31B2 /* Cart.m */, 6CC89DE013F3197F003704F7 /* FallingObjectDelegate.h */, 6CDBE80E140936CF0072F287 /* CartDelegate.h */, + 6CF64C07141B9FA300F3B702 /* PointMultiplier.h */, + 6CF64C08141B9FA300F3B702 /* PointMultiplier.m */, ); name = Items; sourceTree = ""; @@ -1479,6 +1487,7 @@ 6C39CFEB13FC8ACA002B21AF /* jump.png in Resources */, 6C85834614056E57009EF100 /* venice.png in Resources */, 6CDBE80C14092DB00072F287 /* ledge.png in Resources */, + 6CF64C0B141BA37000F3B702 /* multiplier.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1533,6 +1542,7 @@ 6C85834014055A44009EF100 /* CCNotifications.m in Sources */, 6C85834414055B2E009EF100 /* notificationDesign.m in Sources */, 6C4400041415080800A9E1D7 /* ZoomFadeTransition.m in Sources */, + 6CF64C09141B9FA300F3B702 /* PointMultiplier.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Classes/GameMode.h b/Classes/GameMode.h index 0659a57..e82ad10 100644 --- a/Classes/GameMode.h +++ b/Classes/GameMode.h @@ -16,6 +16,7 @@ NSMutableSet* objects; int score; int lives; + int pointMultiplier; Cart* cart; CCLayerColor* shadedLayer; @@ -32,6 +33,7 @@ @property (readonly) Cart* cart; @property (nonatomic,assign) int score; @property (nonatomic,assign) int lives; +@property (nonatomic,assign) int pointMultiplier; @property (readonly) BOOL isPaused; + (CCScene*)scene; - (void)tick:(ccTime)dt; diff --git a/Classes/GameMode.m b/Classes/GameMode.m index f0eb02f..1e80237 100644 --- a/Classes/GameMode.m +++ b/Classes/GameMode.m @@ -12,7 +12,7 @@ @implementation GameMode -@synthesize cart, score, lives, isPaused; +@synthesize cart, score, lives, isPaused, pointMultiplier; + (CCScene*)scene { @@ -53,6 +53,7 @@ score = 0; lives = 3; + pointMultiplier = 1; if ([self canPause]) { @@ -159,7 +160,12 @@ { score = m_score; - [scoreLabel setString:[NSString stringWithFormat:@"Score: %d", score]]; + if (pointMultiplier > 1) + { + [scoreLabel setString:[NSString stringWithFormat:@"Score: %d x%d", score, pointMultiplier]]; + } else { + [scoreLabel setString:[NSString stringWithFormat:@"Score: %d", score]]; + } } - (void)setLives:(int)m_lives @@ -169,6 +175,18 @@ [livesLabel setString:[NSString stringWithFormat:@"Lives: %d", lives]]; } +- (void)setPointMultiplier:(int)m_pointMultiplier +{ + pointMultiplier = m_pointMultiplier; + + if (pointMultiplier > 1) + { + [scoreLabel setString:[NSString stringWithFormat:@"Score: %d x%d", score, pointMultiplier]]; + } else { + [scoreLabel setString:[NSString stringWithFormat:@"Score: %d", score]]; + } +} + - (void)scheduleDelayedAction:(void(^)(void))m_delayedAction delay:(float)delay { delayedAction = Block_copy([m_delayedAction retain]); diff --git a/Classes/JumpGameMode.m b/Classes/JumpGameMode.m index 0cf916a..9076426 100644 --- a/Classes/JumpGameMode.m +++ b/Classes/JumpGameMode.m @@ -14,6 +14,7 @@ #import "OneUp.h" #import "Rock.h" #import "GameOverScene.h" +#import "PointMultiplier.h" #define kMinimumGestureLength 25 @@ -308,26 +309,17 @@ { FallingObject* object; - if (score < 120) - { - int randomval = arc4random()%100; - - if (randomval < 80) - { - object = [[Rock alloc] init]; - } else { - object = [[OneUp alloc] init]; - } - } else { - int randomval = arc4random()%100; - - if (randomval < 70) - { - object = [[Rock alloc] init]; - } else { - object = [[OneUp alloc] init]; - } - } + int randomval = arc4random()%100; + + if (randomval < 50) + { + object = [[Rock alloc] init]; + } else if (randomval < 75) + { + object = [[PointMultiplier alloc] init]; + } else { + object = [[OneUp alloc] init]; + } int objectX; @@ -434,7 +426,19 @@ - (void)incrementScore { - [self setScore:self.score+1]; + [self setScore:self.score+pointMultiplier]; +} + +- (void)setLives:(int)m_lives +{ + int oldLives = lives; + + [super setLives:m_lives]; + + if (oldLives > lives) + { + [self setPointMultiplier:1]; + } } @end diff --git a/Classes/PointMultiplier.h b/Classes/PointMultiplier.h new file mode 100644 index 0000000..9d009cb --- /dev/null +++ b/Classes/PointMultiplier.h @@ -0,0 +1,15 @@ +// +// PointMultiplier.h +// Cartographic +// +// Created by Starla Insigna on 9/10/11. +// Copyright (c) 2011 Four Island. All rights reserved. +// + +#import "FallingObject.h" + +@interface PointMultiplier : FallingObject + +- (id)init; + +@end diff --git a/Classes/PointMultiplier.m b/Classes/PointMultiplier.m new file mode 100644 index 0000000..a14bf68 --- /dev/null +++ b/Classes/PointMultiplier.m @@ -0,0 +1,36 @@ +// +// PointMultiplier.m +// Cartographic +// +// Created by Starla Insigna on 9/10/11. +// Copyright (c) 2011 Four Island. All rights reserved. +// + +#import "PointMultiplier.h" +#import "GameMode.h" +#import "SimpleAudioEngine.h" + +@implementation PointMultiplier + +- (id)init +{ + self = [super init]; + + if (nil != self) + { + sprite = [CCSprite spriteWithFile:@"multiplier.png"]; + weight = 8; + } + + return self; +} + +- (void)collideWithCart +{ + GameMode* gameLayer = ((GameMode*) sprite.parent); + [gameLayer setPointMultiplier:gameLayer.pointMultiplier+1]; + + [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Item1" ofType:@"wav"]]; +} + +@end diff --git a/Resources/multiplier.png b/Resources/multiplier.png new file mode 100755 index 0000000..94f5719 Binary files /dev/null and b/Resources/multiplier.png differ -- cgit 1.4.1