diff options
Diffstat (limited to 'Classes')
-rwxr-xr-x | Classes/Bottle.h | 18 | ||||
-rwxr-xr-x | Classes/Bottle.m | 32 | ||||
-rwxr-xr-x | Classes/Cherry.h | 18 | ||||
-rwxr-xr-x | Classes/Cherry.m | 32 | ||||
-rwxr-xr-x | Classes/ClassicGameMode.h | 3 | ||||
-rwxr-xr-x | Classes/ClassicGameMode.m | 71 | ||||
-rwxr-xr-x | Classes/FallingObject.h | 6 | ||||
-rwxr-xr-x | Classes/FallingObject.m | 22 | ||||
-rw-r--r-- | Classes/FallingObjectFactory.h | 20 | ||||
-rw-r--r-- | Classes/FallingObjectFactory.m | 70 | ||||
-rw-r--r-- | Classes/GameMode.h | 2 | ||||
-rw-r--r-- | Classes/GameMode.m | 2 | ||||
-rw-r--r-- | Classes/JumpGameMode.h | 5 | ||||
-rw-r--r-- | Classes/JumpGameMode.m | 58 | ||||
-rwxr-xr-x | Classes/OneUp.h | 18 | ||||
-rwxr-xr-x | Classes/OneUp.m | 36 | ||||
-rw-r--r-- | Classes/PointMultiplier.h | 15 | ||||
-rw-r--r-- | Classes/PointMultiplier.m | 36 | ||||
-rwxr-xr-x | Classes/Rock.h | 18 | ||||
-rwxr-xr-x | Classes/Rock.m | 37 | ||||
-rw-r--r-- | Classes/TutorialMode.h | 2 | ||||
-rw-r--r-- | Classes/TutorialMode.m | 90 | ||||
-rw-r--r-- | Classes/ValuableObject.h | 15 | ||||
-rw-r--r-- | Classes/ValuableObject.m | 46 |
24 files changed, 265 insertions, 407 deletions
diff --git a/Classes/Bottle.h b/Classes/Bottle.h deleted file mode 100755 index 71e94e9..0000000 --- a/Classes/Bottle.h +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | // | ||
2 | // Bottle.h | ||
3 | // Cart Collect | ||
4 | // | ||
5 | // Created by iD Student Account on 7/19/11. | ||
6 | // Copyright 2011 __MyCompanyName__. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import <Foundation/Foundation.h> | ||
10 | #import "ValuableObject.h" | ||
11 | |||
12 | @interface Bottle : ValuableObject { | ||
13 | |||
14 | } | ||
15 | |||
16 | - (id)init; | ||
17 | |||
18 | @end | ||
diff --git a/Classes/Bottle.m b/Classes/Bottle.m deleted file mode 100755 index bae2716..0000000 --- a/Classes/Bottle.m +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | // | ||
2 | // Bottle.m | ||
3 | // Cart Collect | ||
4 | // | ||
5 | // Created by iD Student Account on 7/19/11. | ||
6 | // Copyright 2011 __MyCompanyName__. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import "Bottle.h" | ||
10 | |||
11 | |||
12 | @implementation Bottle | ||
13 | |||
14 | - (id)init | ||
15 | { | ||
16 | self = [super init]; | ||
17 | |||
18 | if (nil != self) | ||
19 | { | ||
20 | sprite = [CCSprite spriteWithFile:@"bottle.png"]; | ||
21 | weight = 6; | ||
22 | } | ||
23 | |||
24 | return self; | ||
25 | } | ||
26 | |||
27 | - (int)pointValue | ||
28 | { | ||
29 | return 25; | ||
30 | } | ||
31 | |||
32 | @end | ||
diff --git a/Classes/Cherry.h b/Classes/Cherry.h deleted file mode 100755 index 0a7e450..0000000 --- a/Classes/Cherry.h +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | // | ||
2 | // Cherry.h | ||
3 | // Cart Collect | ||
4 | // | ||
5 | // Created by iD Student Account on 7/19/11. | ||
6 | // Copyright 2011 __MyCompanyName__. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import <Foundation/Foundation.h> | ||
10 | #import "ValuableObject.h" | ||
11 | |||
12 | @interface Cherry : ValuableObject { | ||
13 | |||
14 | } | ||
15 | |||
16 | - (id)init; | ||
17 | |||
18 | @end | ||
diff --git a/Classes/Cherry.m b/Classes/Cherry.m deleted file mode 100755 index f53c86e..0000000 --- a/Classes/Cherry.m +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | // | ||
2 | // Cherry.m | ||
3 | // Cart Collect | ||
4 | // | ||
5 | // Created by iD Student Account on 7/19/11. | ||
6 | // Copyright 2011 __MyCompanyName__. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import "Cherry.h" | ||
10 | |||
11 | |||
12 | @implementation Cherry | ||
13 | |||
14 | - (id)init | ||
15 | { | ||
16 | self = [super init]; | ||
17 | |||
18 | if (nil != self) | ||
19 | { | ||
20 | sprite = [CCSprite spriteWithFile:@"cherry.png"]; | ||
21 | weight = 5; | ||
22 | } | ||
23 | |||
24 | return self; | ||
25 | } | ||
26 | |||
27 | - (int)pointValue | ||
28 | { | ||
29 | return 10; | ||
30 | } | ||
31 | |||
32 | @end | ||
diff --git a/Classes/ClassicGameMode.h b/Classes/ClassicGameMode.h index bbce029..898a5e7 100755 --- a/Classes/ClassicGameMode.h +++ b/Classes/ClassicGameMode.h | |||
@@ -9,8 +9,9 @@ | |||
9 | #import <Foundation/Foundation.h> | 9 | #import <Foundation/Foundation.h> |
10 | #import "cocos2d.h" | 10 | #import "cocos2d.h" |
11 | #import "GameMode.h" | 11 | #import "GameMode.h" |
12 | #import "FallingObjectDelegate.h" | ||
12 | 13 | ||
13 | @interface ClassicGameMode : GameMode { | 14 | @interface ClassicGameMode : GameMode <FallingObjectDelegate> { |
14 | float addSpeed; | 15 | float addSpeed; |
15 | } | 16 | } |
16 | 17 | ||
diff --git a/Classes/ClassicGameMode.m b/Classes/ClassicGameMode.m index 46ad337..306c1d1 100755 --- a/Classes/ClassicGameMode.m +++ b/Classes/ClassicGameMode.m | |||
@@ -8,10 +8,6 @@ | |||
8 | 8 | ||
9 | #import "ClassicGameMode.h" | 9 | #import "ClassicGameMode.h" |
10 | #import "FallingObject.h" | 10 | #import "FallingObject.h" |
11 | #import "Cherry.h" | ||
12 | #import "Bottle.h" | ||
13 | #import "OneUp.h" | ||
14 | #import "Rock.h" | ||
15 | #import "GameOverScene.h" | 11 | #import "GameOverScene.h" |
16 | #import "SimpleAudioEngine.h" | 12 | #import "SimpleAudioEngine.h" |
17 | #import "CCNotifications.h" | 13 | #import "CCNotifications.h" |
@@ -19,6 +15,13 @@ | |||
19 | 15 | ||
20 | @implementation ClassicGameMode | 16 | @implementation ClassicGameMode |
21 | 17 | ||
18 | typedef enum { | ||
19 | kCherryObject = 0, | ||
20 | kEnergyDrinkObject, | ||
21 | kOneUpObject, | ||
22 | kRockObject | ||
23 | } FallingObjects; | ||
24 | |||
22 | - (void)tick:(ccTime)dt | 25 | - (void)tick:(ccTime)dt |
23 | { | 26 | { |
24 | int lastScore = score; | 27 | int lastScore = score; |
@@ -83,6 +86,7 @@ | |||
83 | { | 86 | { |
84 | FallingObject* object; | 87 | FallingObject* object; |
85 | int oneuppercent = 98 - (lives == 1 ? 1 : 0); | 88 | int oneuppercent = 98 - (lives == 1 ? 1 : 0); |
89 | int recipeIdentifier; | ||
86 | 90 | ||
87 | if (score < 1000) | 91 | if (score < 1000) |
88 | { | 92 | { |
@@ -90,31 +94,33 @@ | |||
90 | 94 | ||
91 | if (randomval < 65) | 95 | if (randomval < 65) |
92 | { | 96 | { |
93 | object = [[Cherry alloc] init]; | 97 | recipeIdentifier = kCherryObject; |
94 | } else if (randomval < oneuppercent) | 98 | } else if (randomval < oneuppercent) |
95 | { | 99 | { |
96 | object = [[Bottle alloc] init]; | 100 | recipeIdentifier = kEnergyDrinkObject; |
97 | } else { | 101 | } else { |
98 | object = [[OneUp alloc] init]; | 102 | recipeIdentifier = kOneUpObject; |
99 | } | 103 | } |
100 | } else { | 104 | } else { |
101 | int randomval = arc4random()%100; | 105 | int randomval = arc4random()%100; |
102 | 106 | ||
103 | if (randomval < 40) | 107 | if (randomval < 40) |
104 | { | 108 | { |
105 | object = [[Cherry alloc] init]; | 109 | recipeIdentifier = kCherryObject; |
106 | } else if (randomval < 70) | 110 | } else if (randomval < 70) |
107 | { | 111 | { |
108 | object = [[Rock alloc] init]; | 112 | recipeIdentifier = kRockObject; |
109 | } else if (randomval < oneuppercent) | 113 | } else if (randomval < oneuppercent) |
110 | { | 114 | { |
111 | object = [[Bottle alloc] init]; | 115 | recipeIdentifier = kEnergyDrinkObject; |
112 | } else { | 116 | } else { |
113 | object = [[OneUp alloc] init]; | 117 | recipeIdentifier = kOneUpObject; |
114 | } | 118 | } |
115 | } | 119 | } |
116 | 120 | ||
117 | int objectX = arc4random()%448+16; | 121 | int objectX = arc4random()%448+16; |
122 | object = [[objectFactory buildFallingObjectWithRecipeIdentifier:recipeIdentifier] retain]; | ||
123 | object.delegate = self; | ||
118 | object.sprite.position = ccp(objectX, 360); | 124 | object.sprite.position = ccp(objectX, 360); |
119 | object.sprite.scale = 1; | 125 | object.sprite.scale = 1; |
120 | [self addChild:object.sprite]; | 126 | [self addChild:object.sprite]; |
@@ -126,8 +132,8 @@ | |||
126 | { | 132 | { |
127 | if (arc4random() % 100 > 80) | 133 | if (arc4random() % 100 > 80) |
128 | { | 134 | { |
129 | object = [[Rock alloc] init]; | 135 | object = [[objectFactory buildFallingObjectWithRecipeIdentifier:kRockObject] retain]; |
130 | 136 | object.delegate = self; | |
131 | objectX = arc4random()%448+16; | 137 | objectX = arc4random()%448+16; |
132 | object.sprite.position = ccp(objectX, 360); | 138 | object.sprite.position = ccp(objectX, 360); |
133 | object.sprite.scale = 1; | 139 | object.sprite.scale = 1; |
@@ -142,8 +148,8 @@ | |||
142 | { | 148 | { |
143 | if (arc4random() % 100 > 80) | 149 | if (arc4random() % 100 > 80) |
144 | { | 150 | { |
145 | object = [[Rock alloc] init]; | 151 | object = [[objectFactory buildFallingObjectWithRecipeIdentifier:kRockObject] retain]; |
146 | 152 | object.delegate = self; | |
147 | objectX = arc4random()%448+16; | 153 | objectX = arc4random()%448+16; |
148 | object.sprite.position = ccp(objectX, 360); | 154 | object.sprite.position = ccp(objectX, 360); |
149 | object.sprite.scale = 1; | 155 | object.sprite.scale = 1; |
@@ -166,6 +172,11 @@ | |||
166 | [self addChild:backgroundImage z:-1]; | 172 | [self addChild:backgroundImage z:-1]; |
167 | 173 | ||
168 | addSpeed = 2.5f; | 174 | addSpeed = 2.5f; |
175 | |||
176 | [objectFactory createRecipeWithIdentifier:kCherryObject spriteFilename:@"cherry.png" weight:5]; | ||
177 | [objectFactory createRecipeWithIdentifier:kEnergyDrinkObject spriteFilename:@"bottle.png" weight:6]; | ||
178 | [objectFactory createRecipeWithIdentifier:kOneUpObject spriteFilename:@"oneup.png" weight:10]; | ||
179 | [objectFactory createRecipeWithIdentifier:kRockObject spriteFilename:@"rock.png" weight:7]; | ||
169 | } | 180 | } |
170 | 181 | ||
171 | return self; | 182 | return self; |
@@ -178,4 +189,34 @@ | |||
178 | [self schedule:@selector(randomlyAddObject:) interval:addSpeed]; | 189 | [self schedule:@selector(randomlyAddObject:) interval:addSpeed]; |
179 | } | 190 | } |
180 | 191 | ||
192 | - (void)didCatchItem:(FallingObject *)item | ||
193 | { | ||
194 | if (item.objectType == kCherryObject) | ||
195 | { | ||
196 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Item1" ofType:@"wav"]]; | ||
197 | self.score += 10; | ||
198 | } else if (item.objectType == kEnergyDrinkObject) | ||
199 | { | ||
200 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Item1" ofType:@"wav"]]; | ||
201 | self.score += 25; | ||
202 | } else if (item.objectType == kOneUpObject) | ||
203 | { | ||
204 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"1up" ofType:@"wav"]]; | ||
205 | self.lives++; | ||
206 | } else if (item.objectType == kRockObject) | ||
207 | { | ||
208 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Damage1" ofType:@"wav"]]; | ||
209 | self.lives--; | ||
210 | } | ||
211 | } | ||
212 | |||
213 | - (void)didMissItem:(FallingObject *)item | ||
214 | { | ||
215 | if ((item.objectType == kCherryObject) || (item.objectType == kEnergyDrinkObject)) | ||
216 | { | ||
217 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Damage1" ofType:@"wav"]]; | ||
218 | self.lives--; | ||
219 | } | ||
220 | } | ||
221 | |||
181 | @end | 222 | @end |
diff --git a/Classes/FallingObject.h b/Classes/FallingObject.h index d3ac638..d9406d5 100755 --- a/Classes/FallingObject.h +++ b/Classes/FallingObject.h | |||
@@ -15,15 +15,15 @@ | |||
15 | int weight; | 15 | int weight; |
16 | id<FallingObjectDelegate> delegate; | 16 | id<FallingObjectDelegate> delegate; |
17 | BOOL flags[4]; | 17 | BOOL flags[4]; |
18 | int objectType; | ||
18 | } | 19 | } |
19 | 20 | ||
20 | @property (readonly) CCSprite* sprite; | 21 | @property (readonly) CCSprite* sprite; |
21 | @property (readonly) int weight; | 22 | @property (readonly) int weight; |
23 | @property (readonly) int objectType; | ||
22 | @property (nonatomic,retain) id<FallingObjectDelegate> delegate; | 24 | @property (nonatomic,retain) id<FallingObjectDelegate> delegate; |
23 | - (id)init; | 25 | - (id)initWithSpriteFilename:(NSString*)filename weight:(int)weight objectType:(int)objectType; |
24 | - (BOOL)tick; | 26 | - (BOOL)tick; |
25 | - (void)collideWithCart; | ||
26 | - (void)collideWithFloor; | ||
27 | - (BOOL)flag:(int)flag; | 27 | - (BOOL)flag:(int)flag; |
28 | - (void)setFlag:(int)flag withValue:(BOOL)value; | 28 | - (void)setFlag:(int)flag withValue:(BOOL)value; |
29 | 29 | ||
diff --git a/Classes/FallingObject.m b/Classes/FallingObject.m index 86edd15..460372e 100755 --- a/Classes/FallingObject.m +++ b/Classes/FallingObject.m | |||
@@ -11,15 +11,17 @@ | |||
11 | 11 | ||
12 | @implementation FallingObject | 12 | @implementation FallingObject |
13 | 13 | ||
14 | @synthesize sprite, weight, delegate; | 14 | @synthesize sprite, weight, objectType, delegate; |
15 | 15 | ||
16 | - (id)init | 16 | - (id)initWithSpriteFilename:(NSString*)filename weight:(int)m_weight objectType:(int)m_objectType |
17 | { | 17 | { |
18 | self = [super init]; | 18 | self = [super init]; |
19 | 19 | ||
20 | if (nil != self) | 20 | if (nil != self) |
21 | { | 21 | { |
22 | 22 | sprite = [CCSprite spriteWithFile:filename]; | |
23 | weight = m_weight; | ||
24 | objectType = m_objectType; | ||
23 | } | 25 | } |
24 | 26 | ||
25 | return self; | 27 | return self; |
@@ -44,8 +46,6 @@ | |||
44 | { | 46 | { |
45 | if (gameLayer.cart.sprite.position.y < (sprite.position.y + second.height/2 + first.height/2)) | 47 | if (gameLayer.cart.sprite.position.y < (sprite.position.y + second.height/2 + first.height/2)) |
46 | { | 48 | { |
47 | [self collideWithCart]; | ||
48 | |||
49 | if ((delegate != nil) && ([delegate respondsToSelector:@selector(didCatchItem:)])) | 49 | if ((delegate != nil) && ([delegate respondsToSelector:@selector(didCatchItem:)])) |
50 | { | 50 | { |
51 | [delegate didCatchItem:self]; | 51 | [delegate didCatchItem:self]; |
@@ -65,8 +65,6 @@ | |||
65 | // Collision detection with floor | 65 | // Collision detection with floor |
66 | if (sprite.position.y - (sprite.contentSize.height/2) < 0) | 66 | if (sprite.position.y - (sprite.contentSize.height/2) < 0) |
67 | { | 67 | { |
68 | [self collideWithFloor]; | ||
69 | |||
70 | if ((delegate != nil) && ([delegate respondsToSelector:@selector(didMissItem:)])) | 68 | if ((delegate != nil) && ([delegate respondsToSelector:@selector(didMissItem:)])) |
71 | { | 69 | { |
72 | [delegate didMissItem:self]; | 70 | [delegate didMissItem:self]; |
@@ -83,16 +81,6 @@ | |||
83 | return NO; | 81 | return NO; |
84 | } | 82 | } |
85 | 83 | ||
86 | - (void)collideWithCart | ||
87 | { | ||
88 | |||
89 | } | ||
90 | |||
91 | - (void)collideWithFloor | ||
92 | { | ||
93 | |||
94 | } | ||
95 | |||
96 | - (BOOL)flag:(int)flag | 84 | - (BOOL)flag:(int)flag |
97 | { | 85 | { |
98 | return flags[flag]; | 86 | return flags[flag]; |
diff --git a/Classes/FallingObjectFactory.h b/Classes/FallingObjectFactory.h new file mode 100644 index 0000000..a861d06 --- /dev/null +++ b/Classes/FallingObjectFactory.h | |||
@@ -0,0 +1,20 @@ | |||
1 | // | ||
2 | // FallingObjectFactory.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 <Foundation/Foundation.h> | ||
10 | #import "FallingObject.h" | ||
11 | |||
12 | @interface FallingObjectFactory : NSObject { | ||
13 | NSMutableDictionary* recipes; | ||
14 | } | ||
15 | |||
16 | - (id)init; | ||
17 | - (void)createRecipeWithIdentifier:(int)identifier spriteFilename:(NSString*)filename weight:(int)weight; | ||
18 | - (FallingObject*)buildFallingObjectWithRecipeIdentifier:(int)identifier; | ||
19 | |||
20 | @end | ||
diff --git a/Classes/FallingObjectFactory.m b/Classes/FallingObjectFactory.m new file mode 100644 index 0000000..dfd6424 --- /dev/null +++ b/Classes/FallingObjectFactory.m | |||
@@ -0,0 +1,70 @@ | |||
1 | // | ||
2 | // FallingObjectFactory.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 "FallingObjectFactory.h" | ||
10 | |||
11 | @interface FallingObjectRecipe : NSObject { | ||
12 | NSString* spriteFilename; | ||
13 | int weight; | ||
14 | } | ||
15 | |||
16 | @property (readonly) NSString* spriteFilename; | ||
17 | @property (readonly) int weight; | ||
18 | - (id)initWithSpriteFilename:(NSString*)filename weight:(int)m_weight; | ||
19 | |||
20 | @end | ||
21 | |||
22 | @implementation FallingObjectRecipe | ||
23 | |||
24 | @synthesize spriteFilename, weight; | ||
25 | |||
26 | - (id)initWithSpriteFilename:(NSString*)filename weight:(int)m_weight | ||
27 | { | ||
28 | self = [super init]; | ||
29 | |||
30 | if (nil != self) | ||
31 | { | ||
32 | spriteFilename = [filename retain]; | ||
33 | weight = m_weight; | ||
34 | } | ||
35 | |||
36 | return self; | ||
37 | } | ||
38 | |||
39 | @end | ||
40 | |||
41 | @implementation FallingObjectFactory | ||
42 | |||
43 | - (id)init | ||
44 | { | ||
45 | self = [super init]; | ||
46 | |||
47 | if (nil != self) | ||
48 | { | ||
49 | recipes = [[NSMutableDictionary alloc] init]; | ||
50 | } | ||
51 | |||
52 | return self; | ||
53 | } | ||
54 | |||
55 | - (void)createRecipeWithIdentifier:(int)identifier spriteFilename:(NSString*)filename weight:(int)weight | ||
56 | { | ||
57 | FallingObjectRecipe* recipe = [[FallingObjectRecipe alloc] initWithSpriteFilename:filename weight:weight]; | ||
58 | [recipes setObject:recipe forKey:[NSNumber numberWithInt:identifier]]; | ||
59 | [recipe release]; | ||
60 | } | ||
61 | |||
62 | - (FallingObject*)buildFallingObjectWithRecipeIdentifier:(int)identifier | ||
63 | { | ||
64 | FallingObjectRecipe* recipe = [recipes objectForKey:[NSNumber numberWithInt:identifier]]; | ||
65 | FallingObject* object = [[FallingObject alloc] initWithSpriteFilename:recipe.spriteFilename weight:recipe.weight objectType:identifier]; | ||
66 | |||
67 | return [object autorelease]; | ||
68 | } | ||
69 | |||
70 | @end | ||
diff --git a/Classes/GameMode.h b/Classes/GameMode.h index e82ad10..cd0359d 100644 --- a/Classes/GameMode.h +++ b/Classes/GameMode.h | |||
@@ -8,6 +8,7 @@ | |||
8 | 8 | ||
9 | #import "CCLayer.h" | 9 | #import "CCLayer.h" |
10 | #import "Cart.h" | 10 | #import "Cart.h" |
11 | #import "FallingObjectFactory.h" | ||
11 | 12 | ||
12 | #define GAME_SCENE 436 | 13 | #define GAME_SCENE 436 |
13 | #define GAME_LAYER 437 | 14 | #define GAME_LAYER 437 |
@@ -18,6 +19,7 @@ | |||
18 | int lives; | 19 | int lives; |
19 | int pointMultiplier; | 20 | int pointMultiplier; |
20 | Cart* cart; | 21 | Cart* cart; |
22 | FallingObjectFactory* objectFactory; | ||
21 | 23 | ||
22 | CCLayerColor* shadedLayer; | 24 | CCLayerColor* shadedLayer; |
23 | CCLayer* pauseLayer; | 25 | CCLayer* pauseLayer; |
diff --git a/Classes/GameMode.m b/Classes/GameMode.m index 1e80237..1f2451d 100644 --- a/Classes/GameMode.m +++ b/Classes/GameMode.m | |||
@@ -54,6 +54,8 @@ | |||
54 | score = 0; | 54 | score = 0; |
55 | lives = 3; | 55 | lives = 3; |
56 | pointMultiplier = 1; | 56 | pointMultiplier = 1; |
57 | |||
58 | objectFactory = [[FallingObjectFactory alloc] init]; | ||
57 | 59 | ||
58 | if ([self canPause]) | 60 | if ([self canPause]) |
59 | { | 61 | { |
diff --git a/Classes/JumpGameMode.h b/Classes/JumpGameMode.h index 0b6c5d2..b18fd5a 100644 --- a/Classes/JumpGameMode.h +++ b/Classes/JumpGameMode.h | |||
@@ -7,10 +7,11 @@ | |||
7 | // | 7 | // |
8 | 8 | ||
9 | #import "GameMode.h" | 9 | #import "GameMode.h" |
10 | #import "FallingObjectDelegate.h" | ||
10 | 11 | ||
11 | @class LedgeFactory; | 12 | @class LedgeFactory; |
12 | 13 | ||
13 | @interface JumpGameMode : GameMode <CCStandardTouchDelegate> { | 14 | @interface JumpGameMode : GameMode <CCStandardTouchDelegate, FallingObjectDelegate> { |
14 | CCSprite* water; | 15 | CCSprite* water; |
15 | int waterTick; | 16 | int waterTick; |
16 | BOOL wave; | 17 | BOOL wave; |
@@ -20,7 +21,7 @@ | |||
20 | BOOL jump; | 21 | BOOL jump; |
21 | float expectedAngle; | 22 | float expectedAngle; |
22 | NSMutableSet* ledges; | 23 | NSMutableSet* ledges; |
23 | LedgeFactory* factory; | 24 | LedgeFactory* ledgeFactory; |
24 | int ledgeScrollSpeed; | 25 | int ledgeScrollSpeed; |
25 | float ledgeAccelerationRate; | 26 | float ledgeAccelerationRate; |
26 | float addSpeed; | 27 | float addSpeed; |
diff --git a/Classes/JumpGameMode.m b/Classes/JumpGameMode.m index 15b0e16..a5c2b8f 100644 --- a/Classes/JumpGameMode.m +++ b/Classes/JumpGameMode.m | |||
@@ -9,12 +9,7 @@ | |||
9 | #import "JumpGameMode.h" | 9 | #import "JumpGameMode.h" |
10 | #import "SimpleAudioEngine.h" | 10 | #import "SimpleAudioEngine.h" |
11 | #import "FallingObject.h" | 11 | #import "FallingObject.h" |
12 | #import "Cherry.h" | ||
13 | #import "Bottle.h" | ||
14 | #import "OneUp.h" | ||
15 | #import "Rock.h" | ||
16 | #import "GameOverScene.h" | 12 | #import "GameOverScene.h" |
17 | #import "PointMultiplier.h" | ||
18 | 13 | ||
19 | #define kMinimumGestureLength 25 | 14 | #define kMinimumGestureLength 25 |
20 | 15 | ||
@@ -34,6 +29,12 @@ | |||
34 | 29 | ||
35 | @implementation JumpGameMode | 30 | @implementation JumpGameMode |
36 | 31 | ||
32 | typedef enum { | ||
33 | kRockObject = 0, | ||
34 | kOneUpObject, | ||
35 | kPointMultiplierObject | ||
36 | } FallingObjects; | ||
37 | |||
37 | - (id)init | 38 | - (id)init |
38 | { | 39 | { |
39 | self = [super init]; | 40 | self = [super init]; |
@@ -57,9 +58,9 @@ | |||
57 | waterTick = 0; | 58 | waterTick = 0; |
58 | wave = NO; | 59 | wave = NO; |
59 | 60 | ||
60 | factory = [[LedgeFactory alloc] init]; | 61 | ledgeFactory = [[LedgeFactory alloc] init]; |
61 | ledges = [[NSMutableSet alloc] init]; | 62 | ledges = [[NSMutableSet alloc] init]; |
62 | CCTexture2D* texture = [[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:6 height:2]]; | 63 | CCTexture2D* texture = [[CCTexture2D alloc] initWithImage:[ledgeFactory createLedgeWithWidth:6 height:2]]; |
63 | CCSprite* ledge = [CCSprite spriteWithTexture:texture]; | 64 | CCSprite* ledge = [CCSprite spriteWithTexture:texture]; |
64 | ledge.position = ccp(80, 32); | 65 | ledge.position = ccp(80, 32); |
65 | [self addChild:ledge]; | 66 | [self addChild:ledge]; |
@@ -67,7 +68,7 @@ | |||
67 | [texture release]; | 68 | [texture release]; |
68 | 69 | ||
69 | CCSprite* firstLedge = ledge; | 70 | CCSprite* firstLedge = ledge; |
70 | texture = [[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:10 height:2]]; | 71 | texture = [[CCTexture2D alloc] initWithImage:[ledgeFactory createLedgeWithWidth:10 height:2]]; |
71 | ledge = [CCSprite spriteWithTexture:texture]; | 72 | ledge = [CCSprite spriteWithTexture:texture]; |
72 | ledge.position = ccp(80 + firstLedge.boundingBox.size.width/2 + ledge.boundingBox.size.width/2+64, 32); | 73 | ledge.position = ccp(80 + firstLedge.boundingBox.size.width/2 + ledge.boundingBox.size.width/2+64, 32); |
73 | [self addChild:ledge]; | 74 | [self addChild:ledge]; |
@@ -77,6 +78,10 @@ | |||
77 | ledgeScrollSpeed = 0; | 78 | ledgeScrollSpeed = 0; |
78 | ledgeAccelerationRate = 20.0f; | 79 | ledgeAccelerationRate = 20.0f; |
79 | addSpeed = 2.5f; | 80 | addSpeed = 2.5f; |
81 | |||
82 | [objectFactory createRecipeWithIdentifier:kRockObject spriteFilename:@"rock.png" weight:7]; | ||
83 | [objectFactory createRecipeWithIdentifier:kOneUpObject spriteFilename:@"oneup.png" weight:10]; | ||
84 | [objectFactory createRecipeWithIdentifier:kPointMultiplierObject spriteFilename:@"multiplier.png" weight:8]; | ||
80 | } | 85 | } |
81 | 86 | ||
82 | return self; | 87 | return self; |
@@ -164,7 +169,7 @@ | |||
164 | { | 169 | { |
165 | int ledgeWidth = arc4random() % 9 + 1; | 170 | int ledgeWidth = arc4random() % 9 + 1; |
166 | int ledgeDistance = arc4random() % (ledgeScrollSpeed*ledgeScrollSpeed+1)*3/2; | 171 | int ledgeDistance = arc4random() % (ledgeScrollSpeed*ledgeScrollSpeed+1)*3/2; |
167 | CCTexture2D* texture = [[CCTexture2D alloc] initWithImage:[factory createLedgeWithWidth:ledgeWidth height:2]]; | 172 | CCTexture2D* texture = [[CCTexture2D alloc] initWithImage:[ledgeFactory createLedgeWithWidth:ledgeWidth height:2]]; |
168 | CCSprite* ledge = [CCSprite spriteWithTexture:texture]; | 173 | CCSprite* ledge = [CCSprite spriteWithTexture:texture]; |
169 | ledge.position = ccp(rightmost + rightwidth + ledge.boundingBox.size.width/2+64+ledgeDistance, 32); | 174 | ledge.position = ccp(rightmost + rightwidth + ledge.boundingBox.size.width/2+64+ledgeDistance, 32); |
170 | [self addChild:ledge]; | 175 | [self addChild:ledge]; |
@@ -351,23 +356,22 @@ | |||
351 | 356 | ||
352 | - (void)randomlyAddObject:(ccTime)dt | 357 | - (void)randomlyAddObject:(ccTime)dt |
353 | { | 358 | { |
354 | FallingObject* object; | 359 | int recipeIdentifier; |
355 | |||
356 | int randomval = arc4random()%100; | 360 | int randomval = arc4random()%100; |
357 | int pmChance = (5-pointMultiplier)*5 + 30; | 361 | int pmChance = (5-pointMultiplier)*5 + 30; |
358 | 362 | ||
359 | if (randomval < 30) | 363 | if (randomval < 30) |
360 | { | 364 | { |
361 | object = [[OneUp alloc] init]; | 365 | recipeIdentifier = kOneUpObject; |
362 | } else if (randomval < pmChance) | 366 | } else if (randomval < pmChance) |
363 | { | 367 | { |
364 | object = [[PointMultiplier alloc] init]; | 368 | recipeIdentifier = kPointMultiplierObject; |
365 | } else { | 369 | } else { |
366 | object = [[Rock alloc] init]; | 370 | recipeIdentifier = kRockObject; |
367 | } | 371 | } |
368 | 372 | ||
373 | FallingObject* object = [[objectFactory buildFallingObjectWithRecipeIdentifier:recipeIdentifier] retain]; | ||
369 | int objectX; | 374 | int objectX; |
370 | |||
371 | CGSize first = [cart.sprite boundingBox].size; | 375 | CGSize first = [cart.sprite boundingBox].size; |
372 | CGSize second = [object.sprite boundingBox].size; | 376 | CGSize second = [object.sprite boundingBox].size; |
373 | 377 | ||
@@ -391,6 +395,7 @@ | |||
391 | break; | 395 | break; |
392 | } | 396 | } |
393 | 397 | ||
398 | object.delegate = self; | ||
394 | object.sprite.position = ccp(objectX, 360); | 399 | object.sprite.position = ccp(objectX, 360); |
395 | object.sprite.scale = 1; | 400 | object.sprite.scale = 1; |
396 | [self addChild:object.sprite]; | 401 | [self addChild:object.sprite]; |
@@ -402,7 +407,7 @@ | |||
402 | { | 407 | { |
403 | if (arc4random() % 100 > 80) | 408 | if (arc4random() % 100 > 80) |
404 | { | 409 | { |
405 | object = [[Rock alloc] init]; | 410 | object = [[objectFactory buildFallingObjectWithRecipeIdentifier:kRockObject] retain]; |
406 | 411 | ||
407 | for (;;) | 412 | for (;;) |
408 | { | 413 | { |
@@ -424,6 +429,7 @@ | |||
424 | break; | 429 | break; |
425 | } | 430 | } |
426 | 431 | ||
432 | object.delegate = self; | ||
427 | object.sprite.position = ccp(objectX, 360); | 433 | object.sprite.position = ccp(objectX, 360); |
428 | object.sprite.scale = 1; | 434 | object.sprite.scale = 1; |
429 | [self addChild:object.sprite]; | 435 | [self addChild:object.sprite]; |
@@ -437,7 +443,7 @@ | |||
437 | { | 443 | { |
438 | if (arc4random() % 100 > 80) | 444 | if (arc4random() % 100 > 80) |
439 | { | 445 | { |
440 | object = [[Rock alloc] init]; | 446 | object = [[objectFactory buildFallingObjectWithRecipeIdentifier:kRockObject] retain]; |
441 | 447 | ||
442 | for (;;) | 448 | for (;;) |
443 | { | 449 | { |
@@ -459,6 +465,7 @@ | |||
459 | break; | 465 | break; |
460 | } | 466 | } |
461 | 467 | ||
468 | object.delegate = self; | ||
462 | object.sprite.position = ccp(objectX, 360); | 469 | object.sprite.position = ccp(objectX, 360); |
463 | object.sprite.scale = 1; | 470 | object.sprite.scale = 1; |
464 | [self addChild:object.sprite]; | 471 | [self addChild:object.sprite]; |
@@ -486,6 +493,23 @@ | |||
486 | } | 493 | } |
487 | } | 494 | } |
488 | 495 | ||
496 | - (void)didCatchItem:(FallingObject *)item | ||
497 | { | ||
498 | if (item.objectType == kRockObject) | ||
499 | { | ||
500 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Damage1" ofType:@"wav"]]; | ||
501 | self.lives--; | ||
502 | } else if (item.objectType == kOneUpObject) | ||
503 | { | ||
504 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"1up" ofType:@"wav"]]; | ||
505 | self.lives++; | ||
506 | } else if (item.objectType == kPointMultiplierObject) | ||
507 | { | ||
508 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Absorption2" ofType:@"wav"]]; | ||
509 | self.pointMultiplier++; | ||
510 | } | ||
511 | } | ||
512 | |||
489 | @end | 513 | @end |
490 | 514 | ||
491 | @implementation LedgeFactory | 515 | @implementation LedgeFactory |
diff --git a/Classes/OneUp.h b/Classes/OneUp.h deleted file mode 100755 index 8bd4c66..0000000 --- a/Classes/OneUp.h +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | // | ||
2 | // OneUp.h | ||
3 | // Cart Collect | ||
4 | // | ||
5 | // Created by iD Student Account on 7/19/11. | ||
6 | // Copyright 2011 __MyCompanyName__. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import <Foundation/Foundation.h> | ||
10 | #import "FallingObject.h" | ||
11 | |||
12 | @interface OneUp : FallingObject { | ||
13 | |||
14 | } | ||
15 | |||
16 | - (id)init; | ||
17 | |||
18 | @end | ||
diff --git a/Classes/OneUp.m b/Classes/OneUp.m deleted file mode 100755 index 9e0d4f0..0000000 --- a/Classes/OneUp.m +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | // | ||
2 | // OneUp.m | ||
3 | // Cart Collect | ||
4 | // | ||
5 | // Created by iD Student Account on 7/19/11. | ||
6 | // Copyright 2011 __MyCompanyName__. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import "OneUp.h" | ||
10 | #import "GameMode.h" | ||
11 | #import "SimpleAudioEngine.h" | ||
12 | |||
13 | @implementation OneUp | ||
14 | |||
15 | - (id)init | ||
16 | { | ||
17 | self = [super init]; | ||
18 | |||
19 | if (nil != self) | ||
20 | { | ||
21 | sprite = [CCSprite spriteWithFile:@"oneup.png"]; | ||
22 | weight = 10; | ||
23 | } | ||
24 | |||
25 | return self; | ||
26 | } | ||
27 | |||
28 | - (void)collideWithCart | ||
29 | { | ||
30 | GameMode* gameLayer = ((GameMode*) sprite.parent); | ||
31 | [gameLayer setLives:gameLayer.lives+1]; | ||
32 | |||
33 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"1up" ofType:@"wav"]]; | ||
34 | } | ||
35 | |||
36 | @end | ||
diff --git a/Classes/PointMultiplier.h b/Classes/PointMultiplier.h deleted file mode 100644 index 9d009cb..0000000 --- a/Classes/PointMultiplier.h +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
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 deleted file mode 100644 index 0a9649d..0000000 --- a/Classes/PointMultiplier.m +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
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:@"Absorption2" ofType:@"wav"]]; | ||
34 | } | ||
35 | |||
36 | @end | ||
diff --git a/Classes/Rock.h b/Classes/Rock.h deleted file mode 100755 index 7382d99..0000000 --- a/Classes/Rock.h +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | // | ||
2 | // Rock.h | ||
3 | // Cart Collect | ||
4 | // | ||
5 | // Created by iD Student Account on 7/19/11. | ||
6 | // Copyright 2011 __MyCompanyName__. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import <Foundation/Foundation.h> | ||
10 | #import "FallingObject.h" | ||
11 | |||
12 | @interface Rock : FallingObject { | ||
13 | |||
14 | } | ||
15 | |||
16 | - (id)init; | ||
17 | |||
18 | @end | ||
diff --git a/Classes/Rock.m b/Classes/Rock.m deleted file mode 100755 index aac1aaf..0000000 --- a/Classes/Rock.m +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | // | ||
2 | // Rock.m | ||
3 | // Cart Collect | ||
4 | // | ||
5 | // Created by iD Student Account on 7/19/11. | ||
6 | // Copyright 2011 __MyCompanyName__. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import "Rock.h" | ||
10 | #import "GameMode.h" | ||
11 | #import "SimpleAudioEngine.h" | ||
12 | |||
13 | @implementation Rock | ||
14 | |||
15 | - (id)init | ||
16 | { | ||
17 | self = [super init]; | ||
18 | |||
19 | if (nil != self) | ||
20 | { | ||
21 | sprite = [CCSprite spriteWithFile:@"rock.png"]; | ||
22 | weight = 7; | ||
23 | } | ||
24 | |||
25 | return self; | ||
26 | } | ||
27 | |||
28 | - (void)collideWithCart | ||
29 | { | ||
30 | GameMode* gameLayer = ((GameMode*) sprite.parent); | ||
31 | [gameLayer setLives:gameLayer.lives-1]; | ||
32 | |||
33 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Damage1" ofType:@"wav"]]; | ||
34 | } | ||
35 | |||
36 | |||
37 | @end | ||
diff --git a/Classes/TutorialMode.h b/Classes/TutorialMode.h index 6380483..697c688 100644 --- a/Classes/TutorialMode.h +++ b/Classes/TutorialMode.h | |||
@@ -18,7 +18,7 @@ | |||
18 | 18 | ||
19 | @property (nonatomic,retain) TutorialBubble* currentTutorial; | 19 | @property (nonatomic,retain) TutorialBubble* currentTutorial; |
20 | - (void)endTutorial; | 20 | - (void)endTutorial; |
21 | - (FallingObject*)dropSpecificItem:(FallingObject*)item; | 21 | - (FallingObject*)dropSpecificItem:(int)objectType; |
22 | - (FallingObject*)dropRandomItem; | 22 | - (FallingObject*)dropRandomItem; |
23 | - (void)randomlyAddObject:(ccTime)dt; | 23 | - (void)randomlyAddObject:(ccTime)dt; |
24 | 24 | ||
diff --git a/Classes/TutorialMode.m b/Classes/TutorialMode.m index 3c70a46..156b939 100644 --- a/Classes/TutorialMode.m +++ b/Classes/TutorialMode.m | |||
@@ -8,11 +8,8 @@ | |||
8 | 8 | ||
9 | #import "TutorialMode.h" | 9 | #import "TutorialMode.h" |
10 | #import "FallingObject.h" | 10 | #import "FallingObject.h" |
11 | #import "Cherry.h" | ||
12 | #import "Bottle.h" | ||
13 | #import "OneUp.h" | ||
14 | #import "Rock.h" | ||
15 | #import "GameModeSelectionLayer.h" | 11 | #import "GameModeSelectionLayer.h" |
12 | #import "SimpleAudioEngine.h" | ||
16 | 13 | ||
17 | // Item tags: | 14 | // Item tags: |
18 | // 2000 - first dropped item | 15 | // 2000 - first dropped item |
@@ -22,6 +19,13 @@ | |||
22 | // 2009 - rock | 19 | // 2009 - rock |
23 | // 2010 - random item dropped after death from first rock | 20 | // 2010 - random item dropped after death from first rock |
24 | 21 | ||
22 | typedef enum { | ||
23 | kCherryObject = 0, | ||
24 | kEnergyDrinkObject, | ||
25 | kOneUpObject, | ||
26 | kRockObject | ||
27 | } FallingObjects; | ||
28 | |||
25 | @implementation TutorialMode | 29 | @implementation TutorialMode |
26 | 30 | ||
27 | @synthesize currentTutorial; | 31 | @synthesize currentTutorial; |
@@ -38,6 +42,11 @@ | |||
38 | 42 | ||
39 | showedDeathBubble = NO; | 43 | showedDeathBubble = NO; |
40 | randomItemsDropped = 0; | 44 | randomItemsDropped = 0; |
45 | |||
46 | [objectFactory createRecipeWithIdentifier:kCherryObject spriteFilename:@"cherry.png" weight:5]; | ||
47 | [objectFactory createRecipeWithIdentifier:kEnergyDrinkObject spriteFilename:@"bottle.png" weight:6]; | ||
48 | [objectFactory createRecipeWithIdentifier:kOneUpObject spriteFilename:@"oneup.png" weight:10]; | ||
49 | [objectFactory createRecipeWithIdentifier:kRockObject spriteFilename:@"rock.png" weight:7]; | ||
41 | } | 50 | } |
42 | 51 | ||
43 | return self; | 52 | return self; |
@@ -79,6 +88,24 @@ | |||
79 | 88 | ||
80 | - (void)didCatchItem:(FallingObject *)item | 89 | - (void)didCatchItem:(FallingObject *)item |
81 | { | 90 | { |
91 | if (item.objectType == kCherryObject) | ||
92 | { | ||
93 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Item1" ofType:@"wav"]]; | ||
94 | self.score += 10; | ||
95 | } else if (item.objectType == kEnergyDrinkObject) | ||
96 | { | ||
97 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Item1" ofType:@"wav"]]; | ||
98 | self.score += 25; | ||
99 | } else if (item.objectType == kOneUpObject) | ||
100 | { | ||
101 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"1up" ofType:@"wav"]]; | ||
102 | self.lives++; | ||
103 | } else if (item.objectType == kRockObject) | ||
104 | { | ||
105 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Damage1" ofType:@"wav"]]; | ||
106 | self.lives--; | ||
107 | } | ||
108 | |||
82 | if (item.sprite.tag == 2000) | 109 | if (item.sprite.tag == 2000) |
83 | { | 110 | { |
84 | TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"Congratulations! If you look at your score, you'll see it increased. Catching items is good. Now, let's see what happens when you don't catch an item." name:@"caught-first"]; | 111 | TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"Congratulations! If you look at your score, you'll see it increased. Catching items is good. Now, let's see what happens when you don't catch an item." name:@"caught-first"]; |
@@ -94,6 +121,12 @@ | |||
94 | 121 | ||
95 | - (void)didMissItem:(FallingObject *)item | 122 | - (void)didMissItem:(FallingObject *)item |
96 | { | 123 | { |
124 | if ((item.objectType == kCherryObject) || (item.objectType == kEnergyDrinkObject)) | ||
125 | { | ||
126 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Damage1" ofType:@"wav"]]; | ||
127 | self.lives--; | ||
128 | } | ||
129 | |||
97 | if (item.sprite.tag == 2000) | 130 | if (item.sprite.tag == 2000) |
98 | { | 131 | { |
99 | TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"Whoops, you missed it! Look at your lives counter--you lost one! If you lose all of your lives, you lose the game. Try catching the item again." name:@"missed-first"]; | 132 | TutorialBubble* bubble = [[TutorialBubble alloc] initWithText:@"Whoops, you missed it! Look at your lives counter--you lost one! If you lose all of your lives, you lose the game. Try catching the item again." name:@"missed-first"]; |
@@ -111,7 +144,6 @@ | |||
111 | [self scheduleDelayedAction:^{ | 144 | [self scheduleDelayedAction:^{ |
112 | FallingObject* object = [self dropRandomItem]; | 145 | FallingObject* object = [self dropRandomItem]; |
113 | object.sprite.tag = 2002; | 146 | object.sprite.tag = 2002; |
114 | [object release]; | ||
115 | } delay:1.0f]; | 147 | } delay:1.0f]; |
116 | } | 148 | } |
117 | } | 149 | } |
@@ -181,7 +213,6 @@ | |||
181 | [self scheduleDelayedAction:^{ | 213 | [self scheduleDelayedAction:^{ |
182 | FallingObject* object = [self dropRandomItem]; | 214 | FallingObject* object = [self dropRandomItem]; |
183 | object.sprite.tag = 2000; | 215 | object.sprite.tag = 2000; |
184 | [object release]; | ||
185 | } delay:3.0f]; | 216 | } delay:3.0f]; |
186 | } else if ([currentTutorial.name isEqual:@"caught-first"]) | 217 | } else if ([currentTutorial.name isEqual:@"caught-first"]) |
187 | { | 218 | { |
@@ -198,29 +229,24 @@ | |||
198 | } | 229 | } |
199 | 230 | ||
200 | object.sprite.tag = 2001; | 231 | object.sprite.tag = 2001; |
201 | |||
202 | [object release]; | ||
203 | } delay:1.0f]; | 232 | } delay:1.0f]; |
204 | } else if ([currentTutorial.name isEqual:@"missed-first"]) | 233 | } else if ([currentTutorial.name isEqual:@"missed-first"]) |
205 | { | 234 | { |
206 | [self scheduleDelayedAction:^{ | 235 | [self scheduleDelayedAction:^{ |
207 | FallingObject* object = [self dropRandomItem]; | 236 | FallingObject* object = [self dropRandomItem]; |
208 | object.sprite.tag = 2002; | 237 | object.sprite.tag = 2002; |
209 | [object release]; | ||
210 | } delay:1.0f]; | 238 | } delay:1.0f]; |
211 | } else if (([currentTutorial.name isEqual:@"caught-second"]) || ([currentTutorial.name isEqual:@"missed-second"])) | 239 | } else if (([currentTutorial.name isEqual:@"caught-second"]) || ([currentTutorial.name isEqual:@"missed-second"])) |
212 | { | 240 | { |
213 | [self scheduleDelayedAction:^{ | 241 | [self scheduleDelayedAction:^{ |
214 | FallingObject* object = [self dropSpecificItem:[[OneUp alloc] init]]; | 242 | FallingObject* object = [self dropSpecificItem:kOneUpObject]; |
215 | object.sprite.tag = 2003; | 243 | object.sprite.tag = 2003; |
216 | [object release]; | ||
217 | } delay:2.0f]; | 244 | } delay:2.0f]; |
218 | } else if ([currentTutorial.name isEqual:@"gameover-rock"]) | 245 | } else if ([currentTutorial.name isEqual:@"gameover-rock"]) |
219 | { | 246 | { |
220 | [self scheduleDelayedAction:^{ | 247 | [self scheduleDelayedAction:^{ |
221 | FallingObject* object = [self dropRandomItem]; | 248 | FallingObject* object = [self dropRandomItem]; |
222 | object.sprite.tag = 2010; | 249 | object.sprite.tag = 2010; |
223 | [object release]; | ||
224 | } delay:1.0f]; | 250 | } delay:1.0f]; |
225 | } else if ([currentTutorial.name isEqual:@"intense"]) | 251 | } else if ([currentTutorial.name isEqual:@"intense"]) |
226 | { | 252 | { |
@@ -254,8 +280,9 @@ | |||
254 | } | 280 | } |
255 | } | 281 | } |
256 | 282 | ||
257 | - (FallingObject*)dropSpecificItem:(FallingObject*)object | 283 | - (FallingObject*)dropSpecificItem:(int)objectType |
258 | { | 284 | { |
285 | FallingObject* object = [[objectFactory buildFallingObjectWithRecipeIdentifier:objectType] retain]; | ||
259 | int objectX = arc4random()%448+16; | 286 | int objectX = arc4random()%448+16; |
260 | object.sprite.position = ccp(objectX, 360); | 287 | object.sprite.position = ccp(objectX, 360); |
261 | object.sprite.scale = 1; | 288 | object.sprite.scale = 1; |
@@ -265,27 +292,27 @@ | |||
265 | 292 | ||
266 | [objects addObject:object]; | 293 | [objects addObject:object]; |
267 | 294 | ||
268 | return object; | 295 | return [object autorelease]; |
269 | } | 296 | } |
270 | 297 | ||
271 | - (FallingObject*)dropRandomItem | 298 | - (FallingObject*)dropRandomItem |
272 | { | 299 | { |
273 | FallingObject* object; | ||
274 | int randomval = arc4random()%100; | 300 | int randomval = arc4random()%100; |
301 | int recipeIdentifier; | ||
275 | 302 | ||
276 | if (randomval < 65) | 303 | if (randomval < 65) |
277 | { | 304 | { |
278 | object = [[Cherry alloc] init]; | 305 | recipeIdentifier = kCherryObject; |
279 | } else { | 306 | } else { |
280 | object = [[Bottle alloc] init]; | 307 | recipeIdentifier = kEnergyDrinkObject; |
281 | } | 308 | } |
282 | 309 | ||
283 | return [self dropSpecificItem:object]; | 310 | return [self dropSpecificItem:recipeIdentifier]; |
284 | } | 311 | } |
285 | 312 | ||
286 | - (void)randomlyAddObject:(ccTime)dt | 313 | - (void)randomlyAddObject:(ccTime)dt |
287 | { | 314 | { |
288 | FallingObject* object; | 315 | int recipeIdentifier; |
289 | 316 | ||
290 | if (randomItemsDropped < 5) | 317 | if (randomItemsDropped < 5) |
291 | { | 318 | { |
@@ -293,17 +320,16 @@ | |||
293 | 320 | ||
294 | if (randomval < 65) | 321 | if (randomval < 65) |
295 | { | 322 | { |
296 | object = [[Cherry alloc] init]; | 323 | recipeIdentifier = kCherryObject; |
297 | } else if (randomval < 98) | 324 | } else if (randomval < 98) |
298 | { | 325 | { |
299 | object = [[Bottle alloc] init]; | 326 | recipeIdentifier = kEnergyDrinkObject; |
300 | } else { | 327 | } else { |
301 | object = [[OneUp alloc] init]; | 328 | recipeIdentifier = kOneUpObject; |
302 | } | 329 | } |
303 | } else if (randomItemsDropped == 5) | 330 | } else if (randomItemsDropped == 5) |
304 | { | 331 | { |
305 | object = [[Rock alloc] init]; | 332 | recipeIdentifier = kRockObject; |
306 | object.sprite.tag = 2009; | ||
307 | 333 | ||
308 | [self unschedule:@selector(randomlyAddObject:)]; | 334 | [self unschedule:@selector(randomlyAddObject:)]; |
309 | } else if (randomItemsDropped < 15) { | 335 | } else if (randomItemsDropped < 15) { |
@@ -311,15 +337,15 @@ | |||
311 | 337 | ||
312 | if (randomval < 40) | 338 | if (randomval < 40) |
313 | { | 339 | { |
314 | object = [[Cherry alloc] init]; | 340 | recipeIdentifier = kCherryObject; |
315 | } else if (randomval < 70) | 341 | } else if (randomval < 70) |
316 | { | 342 | { |
317 | object = [[Rock alloc] init]; | 343 | recipeIdentifier = kRockObject; |
318 | } else if (randomval < 98) | 344 | } else if (randomval < 98) |
319 | { | 345 | { |
320 | object = [[Bottle alloc] init]; | 346 | recipeIdentifier = kEnergyDrinkObject; |
321 | } else { | 347 | } else { |
322 | object = [[OneUp alloc] init]; | 348 | recipeIdentifier = kOneUpObject; |
323 | } | 349 | } |
324 | } else if (randomItemsDropped == 15) | 350 | } else if (randomItemsDropped == 15) |
325 | { | 351 | { |
@@ -341,8 +367,12 @@ | |||
341 | return; | 367 | return; |
342 | } | 368 | } |
343 | 369 | ||
344 | [self dropSpecificItem:object]; | 370 | FallingObject* object = [self dropSpecificItem:recipeIdentifier]; |
345 | [object release]; | 371 | |
372 | if (randomItemsDropped == 5) | ||
373 | { | ||
374 | object.sprite.tag = 2009; | ||
375 | } | ||
346 | 376 | ||
347 | randomItemsDropped++; | 377 | randomItemsDropped++; |
348 | } | 378 | } |
diff --git a/Classes/ValuableObject.h b/Classes/ValuableObject.h deleted file mode 100644 index 7b484d9..0000000 --- a/Classes/ValuableObject.h +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | // | ||
2 | // ValuableObject.h | ||
3 | // Cart Collect | ||
4 | // | ||
5 | // Created by Starla Insigna on 8/9/11. | ||
6 | // Copyright 2011 Four Island. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import "FallingObject.h" | ||
10 | |||
11 | @interface ValuableObject : FallingObject | ||
12 | |||
13 | - (int)pointValue; | ||
14 | |||
15 | @end | ||
diff --git a/Classes/ValuableObject.m b/Classes/ValuableObject.m deleted file mode 100644 index f1a036f..0000000 --- a/Classes/ValuableObject.m +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | // | ||
2 | // ValuableObject.m | ||
3 | // Cart Collect | ||
4 | // | ||
5 | // Created by Starla Insigna on 8/9/11. | ||
6 | // Copyright 2011 Four Island. All rights reserved. | ||
7 | // | ||
8 | |||
9 | #import "ValuableObject.h" | ||
10 | #import "GameMode.h" | ||
11 | #import "SimpleAudioEngine.h" | ||
12 | |||
13 | @implementation ValuableObject | ||
14 | |||
15 | - (id)init | ||
16 | { | ||
17 | self = [super init]; | ||
18 | if (self) { | ||
19 | // Initialization code here. | ||
20 | } | ||
21 | |||
22 | return self; | ||
23 | } | ||
24 | |||
25 | - (void)collideWithCart | ||
26 | { | ||
27 | GameMode* gameLayer = ((GameMode*) sprite.parent); | ||
28 | [gameLayer setScore:gameLayer.score+self.pointValue]; | ||
29 | |||
30 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Item1" ofType:@"wav"]]; | ||
31 | } | ||
32 | |||
33 | - (void)collideWithFloor | ||
34 | { | ||
35 | GameMode* gameLayer = ((GameMode*) sprite.parent); | ||
36 | [gameLayer setLives:gameLayer.lives-1]; | ||
37 | |||
38 | [[SimpleAudioEngine sharedEngine] playEffect:[[NSBundle mainBundle] pathForResource:@"Damage1" ofType:@"wav"]]; | ||
39 | } | ||
40 | |||
41 | - (int)pointValue | ||
42 | { | ||
43 | @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:[NSString stringWithFormat:@"You must override %@ in a subclass", NSStringFromSelector(_cmd)] userInfo:nil]; | ||
44 | } | ||
45 | |||
46 | @end | ||