diff options
Diffstat (limited to 'Classes')
-rw-r--r-- | Classes/GameMode.h | 2 | ||||
-rw-r--r-- | Classes/GameMode.m | 22 | ||||
-rw-r--r-- | Classes/JumpGameMode.m | 46 | ||||
-rw-r--r-- | Classes/PointMultiplier.h | 15 | ||||
-rw-r--r-- | Classes/PointMultiplier.m | 36 |
5 files changed, 98 insertions, 23 deletions
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 @@ | |||
16 | NSMutableSet* objects; | 16 | NSMutableSet* objects; |
17 | int score; | 17 | int score; |
18 | int lives; | 18 | int lives; |
19 | int pointMultiplier; | ||
19 | Cart* cart; | 20 | Cart* cart; |
20 | 21 | ||
21 | CCLayerColor* shadedLayer; | 22 | CCLayerColor* shadedLayer; |
@@ -32,6 +33,7 @@ | |||
32 | @property (readonly) Cart* cart; | 33 | @property (readonly) Cart* cart; |
33 | @property (nonatomic,assign) int score; | 34 | @property (nonatomic,assign) int score; |
34 | @property (nonatomic,assign) int lives; | 35 | @property (nonatomic,assign) int lives; |
36 | @property (nonatomic,assign) int pointMultiplier; | ||
35 | @property (readonly) BOOL isPaused; | 37 | @property (readonly) BOOL isPaused; |
36 | + (CCScene*)scene; | 38 | + (CCScene*)scene; |
37 | - (void)tick:(ccTime)dt; | 39 | - (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 @@ | |||
12 | 12 | ||
13 | @implementation GameMode | 13 | @implementation GameMode |
14 | 14 | ||
15 | @synthesize cart, score, lives, isPaused; | 15 | @synthesize cart, score, lives, isPaused, pointMultiplier; |
16 | 16 | ||
17 | + (CCScene*)scene | 17 | + (CCScene*)scene |
18 | { | 18 | { |
@@ -53,6 +53,7 @@ | |||
53 | 53 | ||
54 | score = 0; | 54 | score = 0; |
55 | lives = 3; | 55 | lives = 3; |
56 | pointMultiplier = 1; | ||
56 | 57 | ||
57 | if ([self canPause]) | 58 | if ([self canPause]) |
58 | { | 59 | { |
@@ -159,7 +160,12 @@ | |||
159 | { | 160 | { |
160 | score = m_score; | 161 | score = m_score; |
161 | 162 | ||
162 | [scoreLabel setString:[NSString stringWithFormat:@"Score: %d", score]]; | 163 | if (pointMultiplier > 1) |
164 | { | ||
165 | [scoreLabel setString:[NSString stringWithFormat:@"Score: %d x%d", score, pointMultiplier]]; | ||
166 | } else { | ||
167 | [scoreLabel setString:[NSString stringWithFormat:@"Score: %d", score]]; | ||
168 | } | ||
163 | } | 169 | } |
164 | 170 | ||
165 | - (void)setLives:(int)m_lives | 171 | - (void)setLives:(int)m_lives |
@@ -169,6 +175,18 @@ | |||
169 | [livesLabel setString:[NSString stringWithFormat:@"Lives: %d", lives]]; | 175 | [livesLabel setString:[NSString stringWithFormat:@"Lives: %d", lives]]; |
170 | } | 176 | } |
171 | 177 | ||
178 | - (void)setPointMultiplier:(int)m_pointMultiplier | ||
179 | { | ||
180 | pointMultiplier = m_pointMultiplier; | ||
181 | |||
182 | if (pointMultiplier > 1) | ||
183 | { | ||
184 | [scoreLabel setString:[NSString stringWithFormat:@"Score: %d x%d", score, pointMultiplier]]; | ||
185 | } else { | ||
186 | [scoreLabel setString:[NSString stringWithFormat:@"Score: %d", score]]; | ||
187 | } | ||
188 | } | ||
189 | |||
172 | - (void)scheduleDelayedAction:(void(^)(void))m_delayedAction delay:(float)delay | 190 | - (void)scheduleDelayedAction:(void(^)(void))m_delayedAction delay:(float)delay |
173 | { | 191 | { |
174 | delayedAction = Block_copy([m_delayedAction retain]); | 192 | 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 @@ | |||
14 | #import "OneUp.h" | 14 | #import "OneUp.h" |
15 | #import "Rock.h" | 15 | #import "Rock.h" |
16 | #import "GameOverScene.h" | 16 | #import "GameOverScene.h" |
17 | #import "PointMultiplier.h" | ||
17 | 18 | ||
18 | #define kMinimumGestureLength 25 | 19 | #define kMinimumGestureLength 25 |
19 | 20 | ||
@@ -308,26 +309,17 @@ | |||
308 | { | 309 | { |
309 | FallingObject* object; | 310 | FallingObject* object; |
310 | 311 | ||
311 | if (score < 120) | 312 | int randomval = arc4random()%100; |
312 | { | 313 | |
313 | int randomval = arc4random()%100; | 314 | if (randomval < 50) |
314 | 315 | { | |
315 | if (randomval < 80) | 316 | object = [[Rock alloc] init]; |
316 | { | 317 | } else if (randomval < 75) |
317 | object = [[Rock alloc] init]; | 318 | { |
318 | } else { | 319 | object = [[PointMultiplier alloc] init]; |
319 | object = [[OneUp alloc] init]; | 320 | } else { |
320 | } | 321 | object = [[OneUp alloc] init]; |
321 | } else { | 322 | } |
322 | int randomval = arc4random()%100; | ||
323 | |||
324 | if (randomval < 70) | ||
325 | { | ||
326 | object = [[Rock alloc] init]; | ||
327 | } else { | ||
328 | object = [[OneUp alloc] init]; | ||
329 | } | ||
330 | } | ||
331 | 323 | ||
332 | int objectX; | 324 | int objectX; |
333 | 325 | ||
@@ -434,7 +426,19 @@ | |||
434 | 426 | ||
435 | - (void)incrementScore | 427 | - (void)incrementScore |
436 | { | 428 | { |
437 | [self setScore:self.score+1]; | 429 | [self setScore:self.score+pointMultiplier]; |
430 | } | ||
431 | |||
432 | - (void)setLives:(int)m_lives | ||
433 | { | ||
434 | int oldLives = lives; | ||
435 | |||
436 | [super setLives:m_lives]; | ||
437 | |||
438 | if (oldLives > lives) | ||
439 | { | ||
440 | [self setPointMultiplier:1]; | ||
441 | } | ||
438 | } | 442 | } |
439 | 443 | ||
440 | @end | 444 | @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 @@ | |||
1 | // | ||
2 | // PointMultiplier.h | ||
3 | // Cartographic | ||
4 | // | ||
5 | // Created by Starla Insigna on 9/10/11. | ||
6 | // Copyright (c) 2011 Four Island. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import "FallingObject.h" | ||
10 | |||
11 | @interface PointMultiplier : FallingObject | ||
12 | |||
13 | - (id)init; | ||
14 | |||
15 | @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 @@ | |||
1 | // | ||
2 | // PointMultiplier.m | ||
3 | // Cartographic | ||
4 | // | ||
5 | // Created by Starla Insigna on 9/10/11. | ||
6 | // Copyright (c) 2011 Four Island. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import "PointMultiplier.h" | ||
10 | #import "GameMode.h" | ||
11 | #import "SimpleAudioEngine.h" | ||
12 | |||
13 | @implementation PointMultiplier | ||
14 | |||
15 | - (id)init | ||
16 | { | ||
17 | self = [super init]; | ||
18 | |||
19 | if (nil != self) | ||
20 | { | ||
21 | sprite = [CCSprite spriteWithFile:@"multiplier.png"]; | ||
22 | weight = 8; | ||
23 | } | ||
24 | |||
25 | return self; | ||
26 | } | ||
27 | |||
28 | - (void)collideWithCart | ||
29 | { | ||
30 | GameMode* gameLayer = ((GameMode*) sprite.parent); | ||
31 | [gameLayer setPointMultiplier:gameLayer.pointMultiplier+1]; | ||
32 | |||
33 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Item1" ofType:@"wav"]]; | ||
34 | } | ||
35 | |||
36 | @end | ||