summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2011-09-10 17:07:13 -0400
committerStarla Insigna <starla4444@gmail.com>2011-09-10 17:07:13 -0400
commitfd58a0cde1bb5473e39e6cb82d28113da84b9ae0 (patch)
tree8d36b2fedc3c056c002a881e78340c7b56bbabea
parent5ccc4fc305f502a552b1ac7e815e576c93a8159a (diff)
downloadcartcollect-fd58a0cde1bb5473e39e6cb82d28113da84b9ae0.tar.gz
cartcollect-fd58a0cde1bb5473e39e6cb82d28113da84b9ae0.tar.bz2
cartcollect-fd58a0cde1bb5473e39e6cb82d28113da84b9ae0.zip
Reworked falling objects
Previously, every type of falling object had to have its own class that defined the object type's sprite, weight, and reaction to the cart/floor. This was pretty messy considering how many object types may only be used in one game mode--for instance, the many power ups in Power mode, once it's created, will never be used outside of Power mode. So, to increase customizability and decrease class clutter, game modes now use a FallingObjectFactory to define recipes (basically a sprite filename, a weight and an identifier) that can easily be built throughout the game mode using the identifier. FallingObjectDelegate is now used for all reactions to the cart/floor, rather than defining a standard reaction in the FallingObject subclass and then putting extra stuff in FallingObjectDelegate.
-rwxr-xr-xCartographic.xcodeproj/project.pbxproj44
-rwxr-xr-xClasses/Bottle.h18
-rwxr-xr-xClasses/Bottle.m32
-rwxr-xr-xClasses/Cherry.h18
-rwxr-xr-xClasses/Cherry.m32
-rwxr-xr-xClasses/ClassicGameMode.h3
-rwxr-xr-xClasses/ClassicGameMode.m71
-rwxr-xr-xClasses/FallingObject.h6
-rwxr-xr-xClasses/FallingObject.m22
-rw-r--r--Classes/FallingObjectFactory.h20
-rw-r--r--Classes/FallingObjectFactory.m70
-rw-r--r--Classes/GameMode.h2
-rw-r--r--Classes/GameMode.m2
-rw-r--r--Classes/JumpGameMode.h5
-rw-r--r--Classes/JumpGameMode.m58
-rwxr-xr-xClasses/OneUp.h18
-rwxr-xr-xClasses/OneUp.m36
-rw-r--r--Classes/PointMultiplier.h15
-rw-r--r--Classes/PointMultiplier.m36
-rwxr-xr-xClasses/Rock.h18
-rwxr-xr-xClasses/Rock.m37
-rw-r--r--Classes/TutorialMode.h2
-rw-r--r--Classes/TutorialMode.m90
-rw-r--r--Classes/ValuableObject.h15
-rw-r--r--Classes/ValuableObject.m46
25 files changed, 272 insertions, 444 deletions
diff --git a/Cartographic.xcodeproj/project.pbxproj b/Cartographic.xcodeproj/project.pbxproj index 75343b3..5aed3f5 100755 --- a/Cartographic.xcodeproj/project.pbxproj +++ b/Cartographic.xcodeproj/project.pbxproj
@@ -31,14 +31,10 @@
31 3F6C7C3413D5DEB100C038FE /* Damage1.wav in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7C3313D5DEB100C038FE /* Damage1.wav */; }; 31 3F6C7C3413D5DEB100C038FE /* Damage1.wav in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7C3313D5DEB100C038FE /* Damage1.wav */; };
32 3F6C7C4913D5DEDB00C038FE /* Item1.wav in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7C4813D5DEDB00C038FE /* Item1.wav */; }; 32 3F6C7C4913D5DEDB00C038FE /* Item1.wav in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7C4813D5DEDB00C038FE /* Item1.wav */; };
33 3F6C7C4F13D5E1B600C038FE /* FallingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F6C7C4E13D5E1B600C038FE /* FallingObject.m */; }; 33 3F6C7C4F13D5E1B600C038FE /* FallingObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F6C7C4E13D5E1B600C038FE /* FallingObject.m */; };
34 3F6C7C6D13D5E51800C038FE /* Cherry.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F6C7C6C13D5E51800C038FE /* Cherry.m */; };
35 3F6C7C7013D5E54E00C038FE /* Bottle.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F6C7C6F13D5E54E00C038FE /* Bottle.m */; };
36 3F6C7C7313D5E57100C038FE /* OneUp.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F6C7C7213D5E57100C038FE /* OneUp.m */; };
37 3F6C7E9C13D6315D00C038FE /* helvetica.fnt in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7E9B13D6315D00C038FE /* helvetica.fnt */; }; 34 3F6C7E9C13D6315D00C038FE /* helvetica.fnt in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7E9B13D6315D00C038FE /* helvetica.fnt */; };
38 3F6C7EAD13D6323600C038FE /* helvetica.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7EAC13D6323600C038FE /* helvetica.png */; }; 35 3F6C7EAD13D6323600C038FE /* helvetica.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7EAC13D6323600C038FE /* helvetica.png */; };
39 3F6C7EC613D6335A00C038FE /* 1up.wav in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7EC513D6335A00C038FE /* 1up.wav */; }; 36 3F6C7EC613D6335A00C038FE /* 1up.wav in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7EC513D6335A00C038FE /* 1up.wav */; };
40 3F6C7EE113D636BE00C038FE /* rock.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7EE013D636BE00C038FE /* rock.png */; }; 37 3F6C7EE113D636BE00C038FE /* rock.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7EE013D636BE00C038FE /* rock.png */; };
41 3F6C7EE413D636CF00C038FE /* Rock.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F6C7EE313D636CF00C038FE /* Rock.m */; };
42 3F6C7EE913D6377D00C038FE /* GameOverScene.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F6C7EE813D6377D00C038FE /* GameOverScene.m */; }; 38 3F6C7EE913D6377D00C038FE /* GameOverScene.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F6C7EE813D6377D00C038FE /* GameOverScene.m */; };
43 3F6C7F2413D63E6500C038FE /* SeaBeach.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7F2313D63E6500C038FE /* SeaBeach.png */; }; 39 3F6C7F2413D63E6500C038FE /* SeaBeach.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7F2313D63E6500C038FE /* SeaBeach.png */; };
44 3F6C7F4B13D647A600C038FE /* GameOver.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7F4A13D647A600C038FE /* GameOver.png */; }; 40 3F6C7F4B13D647A600C038FE /* GameOver.png in Resources */ = {isa = PBXBuildFile; fileRef = 3F6C7F4A13D647A600C038FE /* GameOver.png */; };
@@ -98,7 +94,6 @@
98 50F4144910692EE7002A0D5E /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 50F4144410692EE7002A0D5E /* Default.png */; }; 94 50F4144910692EE7002A0D5E /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 50F4144410692EE7002A0D5E /* Default.png */; };
99 50F4144A10692EE7002A0D5E /* fps_images.png in Resources */ = {isa = PBXBuildFile; fileRef = 50F4144510692EE7002A0D5E /* fps_images.png */; }; 95 50F4144A10692EE7002A0D5E /* fps_images.png in Resources */ = {isa = PBXBuildFile; fileRef = 50F4144510692EE7002A0D5E /* fps_images.png */; };
100 50F4144B10692EE7002A0D5E /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 50F4144610692EE7002A0D5E /* Icon.png */; }; 96 50F4144B10692EE7002A0D5E /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 50F4144610692EE7002A0D5E /* Icon.png */; };
101 6C0C140E13F1C3EC003A31B2 /* ValuableObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C0C140D13F1C3EC003A31B2 /* ValuableObject.m */; };
102 6C0C141113F2099B003A31B2 /* Cart.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C0C141013F2099B003A31B2 /* Cart.m */; }; 97 6C0C141113F2099B003A31B2 /* Cart.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C0C141013F2099B003A31B2 /* Cart.m */; };
103 6C0C141413F20E98003A31B2 /* GameMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C0C141313F20E98003A31B2 /* GameMode.m */; }; 98 6C0C141413F20E98003A31B2 /* GameMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C0C141313F20E98003A31B2 /* GameMode.m */; };
104 6C18C3CA1402AD9C0005AA4C /* UIImage+ColorMasking.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C18C3C91402AD9C0005AA4C /* UIImage+ColorMasking.m */; }; 99 6C18C3CA1402AD9C0005AA4C /* UIImage+ColorMasking.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C18C3C91402AD9C0005AA4C /* UIImage+ColorMasking.m */; };
@@ -129,9 +124,9 @@
129 6CC89DD913F2F4E6003704F7 /* Entitlements.plist in Resources */ = {isa = PBXBuildFile; fileRef = 6CC89DD813F2F4E6003704F7 /* Entitlements.plist */; }; 124 6CC89DD913F2F4E6003704F7 /* Entitlements.plist in Resources */ = {isa = PBXBuildFile; fileRef = 6CC89DD813F2F4E6003704F7 /* Entitlements.plist */; };
130 6CC89DDF13F31413003704F7 /* TutorialMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CC89DDE13F31413003704F7 /* TutorialMode.m */; }; 125 6CC89DDF13F31413003704F7 /* TutorialMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CC89DDE13F31413003704F7 /* TutorialMode.m */; };
131 6CDBE80C14092DB00072F287 /* ledge.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CDBE80B14092DB00072F287 /* ledge.png */; }; 126 6CDBE80C14092DB00072F287 /* ledge.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CDBE80B14092DB00072F287 /* ledge.png */; };
132 6CF64C09141B9FA300F3B702 /* PointMultiplier.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CF64C08141B9FA300F3B702 /* PointMultiplier.m */; };
133 6CF64C0B141BA37000F3B702 /* multiplier.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CF64C0A141BA37000F3B702 /* multiplier.png */; }; 127 6CF64C0B141BA37000F3B702 /* multiplier.png in Resources */ = {isa = PBXBuildFile; fileRef = 6CF64C0A141BA37000F3B702 /* multiplier.png */; };
134 6CF64C11141BA84200F3B702 /* Absorption2.wav in Resources */ = {isa = PBXBuildFile; fileRef = 6CF64C10141BA84200F3B702 /* Absorption2.wav */; }; 128 6CF64C11141BA84200F3B702 /* Absorption2.wav in Resources */ = {isa = PBXBuildFile; fileRef = 6CF64C10141BA84200F3B702 /* Absorption2.wav */; };
129 6CF64C1D141BFA9600F3B702 /* FallingObjectFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 6CF64C1C141BFA9600F3B702 /* FallingObjectFactory.m */; };
135 DC6640030F83B3EA000B3E49 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */; }; 130 DC6640030F83B3EA000B3E49 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */; };
136 DC6640050F83B3EA000B3E49 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640040F83B3EA000B3E49 /* OpenAL.framework */; }; 131 DC6640050F83B3EA000B3E49 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640040F83B3EA000B3E49 /* OpenAL.framework */; };
137 DCCBF1B70F6022AE0040855A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */; }; 132 DCCBF1B70F6022AE0040855A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */; };
@@ -354,18 +349,10 @@
354 3F6C7C4813D5DEDB00C038FE /* Item1.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = Item1.wav; sourceTree = "<group>"; }; 349 3F6C7C4813D5DEDB00C038FE /* Item1.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = Item1.wav; sourceTree = "<group>"; };
355 3F6C7C4D13D5E1B600C038FE /* FallingObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FallingObject.h; sourceTree = "<group>"; }; 350 3F6C7C4D13D5E1B600C038FE /* FallingObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FallingObject.h; sourceTree = "<group>"; };
356 3F6C7C4E13D5E1B600C038FE /* FallingObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FallingObject.m; sourceTree = "<group>"; }; 351 3F6C7C4E13D5E1B600C038FE /* FallingObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FallingObject.m; sourceTree = "<group>"; };
357 3F6C7C6B13D5E51800C038FE /* Cherry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cherry.h; sourceTree = "<group>"; };
358 3F6C7C6C13D5E51800C038FE /* Cherry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Cherry.m; sourceTree = "<group>"; };
359 3F6C7C6E13D5E54E00C038FE /* Bottle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bottle.h; sourceTree = "<group>"; };
360 3F6C7C6F13D5E54E00C038FE /* Bottle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bottle.m; sourceTree = "<group>"; };
361 3F6C7C7113D5E57100C038FE /* OneUp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OneUp.h; sourceTree = "<group>"; };
362 3F6C7C7213D5E57100C038FE /* OneUp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OneUp.m; sourceTree = "<group>"; };
363 3F6C7E9B13D6315D00C038FE /* helvetica.fnt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = helvetica.fnt; sourceTree = "<group>"; }; 352 3F6C7E9B13D6315D00C038FE /* helvetica.fnt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = helvetica.fnt; sourceTree = "<group>"; };
364 3F6C7EAC13D6323600C038FE /* helvetica.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = helvetica.png; sourceTree = "<group>"; }; 353 3F6C7EAC13D6323600C038FE /* helvetica.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = helvetica.png; sourceTree = "<group>"; };
365 3F6C7EC513D6335A00C038FE /* 1up.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = 1up.wav; sourceTree = "<group>"; }; 354 3F6C7EC513D6335A00C038FE /* 1up.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = 1up.wav; sourceTree = "<group>"; };
366 3F6C7EE013D636BE00C038FE /* rock.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = rock.png; sourceTree = "<group>"; }; 355 3F6C7EE013D636BE00C038FE /* rock.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = rock.png; sourceTree = "<group>"; };
367 3F6C7EE213D636CF00C038FE /* Rock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Rock.h; sourceTree = "<group>"; };
368 3F6C7EE313D636CF00C038FE /* Rock.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Rock.m; sourceTree = "<group>"; };
369 3F6C7EE713D6377D00C038FE /* GameOverScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameOverScene.h; sourceTree = "<group>"; }; 356 3F6C7EE713D6377D00C038FE /* GameOverScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameOverScene.h; sourceTree = "<group>"; };
370 3F6C7EE813D6377D00C038FE /* GameOverScene.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameOverScene.m; sourceTree = "<group>"; }; 357 3F6C7EE813D6377D00C038FE /* GameOverScene.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameOverScene.m; sourceTree = "<group>"; };
371 3F6C7F2313D63E6500C038FE /* SeaBeach.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = SeaBeach.png; sourceTree = "<group>"; }; 358 3F6C7F2313D63E6500C038FE /* SeaBeach.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = SeaBeach.png; sourceTree = "<group>"; };
@@ -424,8 +411,6 @@
424 50F4144510692EE7002A0D5E /* fps_images.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fps_images.png; sourceTree = "<group>"; }; 411 50F4144510692EE7002A0D5E /* fps_images.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fps_images.png; sourceTree = "<group>"; };
425 50F4144610692EE7002A0D5E /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = "<group>"; }; 412 50F4144610692EE7002A0D5E /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = "<group>"; };
426 50F4144710692EE7002A0D5E /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 413 50F4144710692EE7002A0D5E /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
427 6C0C140C13F1C3EC003A31B2 /* ValuableObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValuableObject.h; sourceTree = "<group>"; };
428 6C0C140D13F1C3EC003A31B2 /* ValuableObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ValuableObject.m; sourceTree = "<group>"; };
429 6C0C140F13F2099B003A31B2 /* Cart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cart.h; sourceTree = "<group>"; }; 414 6C0C140F13F2099B003A31B2 /* Cart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cart.h; sourceTree = "<group>"; };
430 6C0C141013F2099B003A31B2 /* Cart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Cart.m; sourceTree = "<group>"; }; 415 6C0C141013F2099B003A31B2 /* Cart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Cart.m; sourceTree = "<group>"; };
431 6C0C141213F20E98003A31B2 /* GameMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameMode.h; sourceTree = "<group>"; }; 416 6C0C141213F20E98003A31B2 /* GameMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameMode.h; sourceTree = "<group>"; };
@@ -474,10 +459,10 @@
474 6CC89DE013F3197F003704F7 /* FallingObjectDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FallingObjectDelegate.h; sourceTree = "<group>"; }; 459 6CC89DE013F3197F003704F7 /* FallingObjectDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FallingObjectDelegate.h; sourceTree = "<group>"; };
475 6CDBE80B14092DB00072F287 /* ledge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ledge.png; sourceTree = "<group>"; }; 460 6CDBE80B14092DB00072F287 /* ledge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ledge.png; sourceTree = "<group>"; };
476 6CDBE80E140936CF0072F287 /* CartDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CartDelegate.h; sourceTree = "<group>"; }; 461 6CDBE80E140936CF0072F287 /* CartDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CartDelegate.h; sourceTree = "<group>"; };
477 6CF64C07141B9FA300F3B702 /* PointMultiplier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PointMultiplier.h; sourceTree = "<group>"; };
478 6CF64C08141B9FA300F3B702 /* PointMultiplier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PointMultiplier.m; sourceTree = "<group>"; };
479 6CF64C0A141BA37000F3B702 /* multiplier.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = multiplier.png; sourceTree = "<group>"; }; 462 6CF64C0A141BA37000F3B702 /* multiplier.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = multiplier.png; sourceTree = "<group>"; };
480 6CF64C10141BA84200F3B702 /* Absorption2.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = Absorption2.wav; sourceTree = "<group>"; }; 463 6CF64C10141BA84200F3B702 /* Absorption2.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = Absorption2.wav; sourceTree = "<group>"; };
464 6CF64C1B141BFA9600F3B702 /* FallingObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FallingObjectFactory.h; sourceTree = "<group>"; };
465 6CF64C1C141BFA9600F3B702 /* FallingObjectFactory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FallingObjectFactory.m; sourceTree = "<group>"; };
481 DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 466 DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
482 DC6640040F83B3EA000B3E49 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; 467 DC6640040F83B3EA000B3E49 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; };
483 DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 468 DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
@@ -968,22 +953,12 @@
968 children = ( 953 children = (
969 3F6C7C4D13D5E1B600C038FE /* FallingObject.h */, 954 3F6C7C4D13D5E1B600C038FE /* FallingObject.h */,
970 3F6C7C4E13D5E1B600C038FE /* FallingObject.m */, 955 3F6C7C4E13D5E1B600C038FE /* FallingObject.m */,
971 3F6C7C6B13D5E51800C038FE /* Cherry.h */, 956 6CC89DE013F3197F003704F7 /* FallingObjectDelegate.h */,
972 3F6C7C6C13D5E51800C038FE /* Cherry.m */, 957 6CF64C1B141BFA9600F3B702 /* FallingObjectFactory.h */,
973 3F6C7C6E13D5E54E00C038FE /* Bottle.h */, 958 6CF64C1C141BFA9600F3B702 /* FallingObjectFactory.m */,
974 3F6C7C6F13D5E54E00C038FE /* Bottle.m */,
975 3F6C7C7113D5E57100C038FE /* OneUp.h */,
976 3F6C7C7213D5E57100C038FE /* OneUp.m */,
977 3F6C7EE213D636CF00C038FE /* Rock.h */,
978 3F6C7EE313D636CF00C038FE /* Rock.m */,
979 6C0C140C13F1C3EC003A31B2 /* ValuableObject.h */,
980 6C0C140D13F1C3EC003A31B2 /* ValuableObject.m */,
981 6C0C140F13F2099B003A31B2 /* Cart.h */, 959 6C0C140F13F2099B003A31B2 /* Cart.h */,
982 6C0C141013F2099B003A31B2 /* Cart.m */, 960 6C0C141013F2099B003A31B2 /* Cart.m */,
983 6CC89DE013F3197F003704F7 /* FallingObjectDelegate.h */,
984 6CDBE80E140936CF0072F287 /* CartDelegate.h */, 961 6CDBE80E140936CF0072F287 /* CartDelegate.h */,
985 6CF64C07141B9FA300F3B702 /* PointMultiplier.h */,
986 6CF64C08141B9FA300F3B702 /* PointMultiplier.m */,
987 ); 962 );
988 name = Items; 963 name = Items;
989 sourceTree = "<group>"; 964 sourceTree = "<group>";
@@ -1523,16 +1498,11 @@
1523 E0F81038120A173C005866B8 /* RootViewController.m in Sources */, 1498 E0F81038120A173C005866B8 /* RootViewController.m in Sources */,
1524 3FE79CD413D4DE37001A6B93 /* ClassicGameMode.m in Sources */, 1499 3FE79CD413D4DE37001A6B93 /* ClassicGameMode.m in Sources */,
1525 3F6C7C4F13D5E1B600C038FE /* FallingObject.m in Sources */, 1500 3F6C7C4F13D5E1B600C038FE /* FallingObject.m in Sources */,
1526 3F6C7C6D13D5E51800C038FE /* Cherry.m in Sources */,
1527 3F6C7C7013D5E54E00C038FE /* Bottle.m in Sources */,
1528 3F6C7C7313D5E57100C038FE /* OneUp.m in Sources */,
1529 3F6C7EE413D636CF00C038FE /* Rock.m in Sources */,
1530 3F6C7EE913D6377D00C038FE /* GameOverScene.m in Sources */, 1501 3F6C7EE913D6377D00C038FE /* GameOverScene.m in Sources */,
1531 3F83955313D739B10059AEE8 /* MainMenuLayer.m in Sources */, 1502 3F83955313D739B10059AEE8 /* MainMenuLayer.m in Sources */,
1532 3F03221613D78F8C00E6A708 /* HighscoreListController.m in Sources */, 1503 3F03221613D78F8C00E6A708 /* HighscoreListController.m in Sources */,
1533 3F03221913D7904E00E6A708 /* Highscore.m in Sources */, 1504 3F03221913D7904E00E6A708 /* Highscore.m in Sources */,
1534 6C29041013EAEB590032DA0F /* TutorialBubble.m in Sources */, 1505 6C29041013EAEB590032DA0F /* TutorialBubble.m in Sources */,
1535 6C0C140E13F1C3EC003A31B2 /* ValuableObject.m in Sources */,
1536 6C0C141113F2099B003A31B2 /* Cart.m in Sources */, 1506 6C0C141113F2099B003A31B2 /* Cart.m in Sources */,
1537 6C0C141413F20E98003A31B2 /* GameMode.m in Sources */, 1507 6C0C141413F20E98003A31B2 /* GameMode.m in Sources */,
1538 6CC89DDF13F31413003704F7 /* TutorialMode.m in Sources */, 1508 6CC89DDF13F31413003704F7 /* TutorialMode.m in Sources */,
@@ -1546,7 +1516,7 @@
1546 6C85834014055A44009EF100 /* CCNotifications.m in Sources */, 1516 6C85834014055A44009EF100 /* CCNotifications.m in Sources */,
1547 6C85834414055B2E009EF100 /* notificationDesign.m in Sources */, 1517 6C85834414055B2E009EF100 /* notificationDesign.m in Sources */,
1548 6C4400041415080800A9E1D7 /* ZoomFadeTransition.m in Sources */, 1518 6C4400041415080800A9E1D7 /* ZoomFadeTransition.m in Sources */,
1549 6CF64C09141B9FA300F3B702 /* PointMultiplier.m in Sources */, 1519 6CF64C1D141BFA9600F3B702 /* FallingObjectFactory.m in Sources */,
1550 ); 1520 );
1551 runOnlyForDeploymentPostprocessing = 0; 1521 runOnlyForDeploymentPostprocessing = 0;
1552 }; 1522 };
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
18typedef 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
32typedef 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
22typedef 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