diff --git a/HeadsUpper/HUTableViewCell.h b/HeadsUpper/HUTableViewCell.h new file mode 100644 index 0000000..e240425 --- /dev/null +++ b/HeadsUpper/HUTableViewCell.h @@ -0,0 +1,19 @@ +// +// HUTableViewCell.h +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import + +@interface HUTableViewCell : UITableViewCell + +@property (nonatomic) HUCategory category; +@property (nonatomic) NSString *title; +@property (weak, nonatomic) IBOutlet UILabel *titleLabel; + +- (instancetype)initWithCategory:(HUCategory)category; + +@end diff --git a/HeadsUpper/HUTableViewCell.m b/HeadsUpper/HUTableViewCell.m new file mode 100644 index 0000000..ad9b3cb --- /dev/null +++ b/HeadsUpper/HUTableViewCell.m @@ -0,0 +1,25 @@ +// +// HUTableViewCell.m +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import "HUTableViewCell.h" + +@implementation HUTableViewCell + +- (instancetype)initWithCategory:(HUCategory)category{ + + if (self = [super init]){ + self.category = category; + return self; + } + + return nil; +} + + + +@end diff --git a/HeadsUpper/HUTableViewCell.xib b/HeadsUpper/HUTableViewCell.xib new file mode 100644 index 0000000..5eee464 --- /dev/null +++ b/HeadsUpper/HUTableViewCell.xib @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj b/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj index fb900f8..b4fc233 100644 --- a/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj +++ b/HeadsUpper/HeadsUpper.xcodeproj/project.pbxproj @@ -9,10 +9,20 @@ /* Begin PBXBuildFile section */ 8D89695C1C755D0200D32E8A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D89695B1C755D0200D32E8A /* main.m */; }; 8D89695F1C755D0200D32E8A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D89695E1C755D0200D32E8A /* AppDelegate.m */; }; - 8D8969621C755D0200D32E8A /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D8969611C755D0200D32E8A /* ViewController.m */; }; 8D8969651C755D0200D32E8A /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8D8969631C755D0200D32E8A /* Main.storyboard */; }; 8D8969671C755D0200D32E8A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8D8969661C755D0200D32E8A /* Assets.xcassets */; }; 8D89696A1C755D0200D32E8A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8D8969681C755D0200D32E8A /* LaunchScreen.storyboard */; }; + C7A853FE1C7A50D500518AF8 /* UIColor+FadeColor.m in Sources */ = {isa = PBXBuildFile; fileRef = C7A853FD1C7A50D500518AF8 /* UIColor+FadeColor.m */; }; + C7A854001C7A642200518AF8 /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C7A853FF1C7A642200518AF8 /* CoreMotion.framework */; }; + C7A854091C7A74C400518AF8 /* NSArray+Shuffle.m in Sources */ = {isa = PBXBuildFile; fileRef = C7A854081C7A74C400518AF8 /* NSArray+Shuffle.m */; }; + C7DD0BA71C7A14F500361D17 /* HUTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C7DD0BA51C7A14F500361D17 /* HUTableViewCell.m */; }; + C7DD0BA81C7A14F500361D17 /* HUTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C7DD0BA61C7A14F500361D17 /* HUTableViewCell.xib */; }; + C7DD0BAB1C7A16FA00361D17 /* HUData.m in Sources */ = {isa = PBXBuildFile; fileRef = C7DD0BAA1C7A16FA00361D17 /* HUData.m */; }; + C7DD0BB01C7A22D900361D17 /* HUTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C7DD0BAF1C7A22D900361D17 /* HUTableViewController.m */; }; + C7DD0BB31C7A23FE00361D17 /* HUCategoryGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = C7DD0BB21C7A23FE00361D17 /* HUCategoryGenerator.m */; }; + C7DD0BB61C7A2CE100361D17 /* HUGameViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C7DD0BB51C7A2CE100361D17 /* HUGameViewController.m */; }; + C7DD0BB91C7A2E7600361D17 /* HUInstructionsView.m in Sources */ = {isa = PBXBuildFile; fileRef = C7DD0BB81C7A2E7600361D17 /* HUInstructionsView.m */; }; + C7DD0BBB1C7A2E8300361D17 /* HUInstructionsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C7DD0BBA1C7A2E8300361D17 /* HUInstructionsView.xib */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -20,12 +30,31 @@ 8D89695B1C755D0200D32E8A /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 8D89695D1C755D0200D32E8A /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 8D89695E1C755D0200D32E8A /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 8D8969601C755D0200D32E8A /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; - 8D8969611C755D0200D32E8A /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 8D8969641C755D0200D32E8A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 8D8969661C755D0200D32E8A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 8D8969691C755D0200D32E8A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 8D89696B1C755D0200D32E8A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C7A853FC1C7A50D500518AF8 /* UIColor+FadeColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIColor+FadeColor.h"; path = "../UIColor+FadeColor.h"; sourceTree = ""; }; + C7A853FD1C7A50D500518AF8 /* UIColor+FadeColor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIColor+FadeColor.m"; path = "../UIColor+FadeColor.m"; sourceTree = ""; }; + C7A853FF1C7A642200518AF8 /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; }; + C7A854071C7A74C400518AF8 /* NSArray+Shuffle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+Shuffle.h"; sourceTree = ""; }; + C7A854081C7A74C400518AF8 /* NSArray+Shuffle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+Shuffle.m"; sourceTree = ""; }; + C7DD0BA41C7A14F500361D17 /* HUTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HUTableViewCell.h; path = ../HUTableViewCell.h; sourceTree = ""; }; + C7DD0BA51C7A14F500361D17 /* HUTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HUTableViewCell.m; path = ../HUTableViewCell.m; sourceTree = ""; }; + C7DD0BA61C7A14F500361D17 /* HUTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = HUTableViewCell.xib; path = ../HUTableViewCell.xib; sourceTree = ""; }; + C7DD0BA91C7A16FA00361D17 /* HUData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HUData.h; sourceTree = ""; }; + C7DD0BAA1C7A16FA00361D17 /* HUData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUData.m; sourceTree = ""; }; + C7DD0BAC1C7A1ADD00361D17 /* HUCategory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HUCategory.h; sourceTree = ""; }; + C7DD0BAD1C7A1C6100361D17 /* HeadsUp-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "HeadsUp-Prefix.pch"; sourceTree = ""; }; + C7DD0BAE1C7A22D900361D17 /* HUTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HUTableViewController.h; sourceTree = ""; }; + C7DD0BAF1C7A22D900361D17 /* HUTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUTableViewController.m; sourceTree = ""; }; + C7DD0BB11C7A23FE00361D17 /* HUCategoryGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HUCategoryGenerator.h; sourceTree = ""; }; + C7DD0BB21C7A23FE00361D17 /* HUCategoryGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUCategoryGenerator.m; sourceTree = ""; }; + C7DD0BB41C7A2CE100361D17 /* HUGameViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HUGameViewController.h; sourceTree = ""; }; + C7DD0BB51C7A2CE100361D17 /* HUGameViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUGameViewController.m; sourceTree = ""; }; + C7DD0BB71C7A2E7600361D17 /* HUInstructionsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HUInstructionsView.h; sourceTree = ""; }; + C7DD0BB81C7A2E7600361D17 /* HUInstructionsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HUInstructionsView.m; sourceTree = ""; }; + C7DD0BBA1C7A2E8300361D17 /* HUInstructionsView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HUInstructionsView.xib; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -33,6 +62,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + C7A854001C7A642200518AF8 /* CoreMotion.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -42,6 +72,7 @@ 8D89694E1C755D0200D32E8A = { isa = PBXGroup; children = ( + C7A853FF1C7A642200518AF8 /* CoreMotion.framework */, 8D8969591C755D0200D32E8A /* HeadsUpper */, 8D8969581C755D0200D32E8A /* Products */, ); @@ -58,11 +89,15 @@ 8D8969591C755D0200D32E8A /* HeadsUpper */ = { isa = PBXGroup; children = ( + C7A854051C7A73BD00518AF8 /* Enums */, + C7A854041C7A73A500518AF8 /* Categories */, + C7A854021C7A733500518AF8 /* Controllers */, + C7A854011C7A732200518AF8 /* Model */, + C7A854031C7A735C00518AF8 /* xibs */, + 8D8969631C755D0200D32E8A /* Main.storyboard */, 8D89695D1C755D0200D32E8A /* AppDelegate.h */, 8D89695E1C755D0200D32E8A /* AppDelegate.m */, - 8D8969601C755D0200D32E8A /* ViewController.h */, - 8D8969611C755D0200D32E8A /* ViewController.m */, - 8D8969631C755D0200D32E8A /* Main.storyboard */, + C7DD0BAD1C7A1C6100361D17 /* HeadsUp-Prefix.pch */, 8D8969661C755D0200D32E8A /* Assets.xcassets */, 8D8969681C755D0200D32E8A /* LaunchScreen.storyboard */, 8D89696B1C755D0200D32E8A /* Info.plist */, @@ -79,6 +114,60 @@ name = "Supporting Files"; sourceTree = ""; }; + C7A854011C7A732200518AF8 /* Model */ = { + isa = PBXGroup; + children = ( + C7DD0BA91C7A16FA00361D17 /* HUData.h */, + C7DD0BAA1C7A16FA00361D17 /* HUData.m */, + ); + name = Model; + sourceTree = ""; + }; + C7A854021C7A733500518AF8 /* Controllers */ = { + isa = PBXGroup; + children = ( + C7DD0BAE1C7A22D900361D17 /* HUTableViewController.h */, + C7DD0BAF1C7A22D900361D17 /* HUTableViewController.m */, + C7DD0BB41C7A2CE100361D17 /* HUGameViewController.h */, + C7DD0BB51C7A2CE100361D17 /* HUGameViewController.m */, + ); + name = Controllers; + sourceTree = ""; + }; + C7A854031C7A735C00518AF8 /* xibs */ = { + isa = PBXGroup; + children = ( + C7DD0BB71C7A2E7600361D17 /* HUInstructionsView.h */, + C7DD0BB81C7A2E7600361D17 /* HUInstructionsView.m */, + C7DD0BBA1C7A2E8300361D17 /* HUInstructionsView.xib */, + C7DD0BA61C7A14F500361D17 /* HUTableViewCell.xib */, + C7DD0BA41C7A14F500361D17 /* HUTableViewCell.h */, + C7DD0BA51C7A14F500361D17 /* HUTableViewCell.m */, + ); + name = xibs; + sourceTree = ""; + }; + C7A854041C7A73A500518AF8 /* Categories */ = { + isa = PBXGroup; + children = ( + C7A853FC1C7A50D500518AF8 /* UIColor+FadeColor.h */, + C7A853FD1C7A50D500518AF8 /* UIColor+FadeColor.m */, + C7A854071C7A74C400518AF8 /* NSArray+Shuffle.h */, + C7A854081C7A74C400518AF8 /* NSArray+Shuffle.m */, + ); + name = Categories; + sourceTree = ""; + }; + C7A854051C7A73BD00518AF8 /* Enums */ = { + isa = PBXGroup; + children = ( + C7DD0BAC1C7A1ADD00361D17 /* HUCategory.h */, + C7DD0BB11C7A23FE00361D17 /* HUCategoryGenerator.h */, + C7DD0BB21C7A23FE00361D17 /* HUCategoryGenerator.m */, + ); + name = Enums; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -136,6 +225,8 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + C7DD0BA81C7A14F500361D17 /* HUTableViewCell.xib in Resources */, + C7DD0BBB1C7A2E8300361D17 /* HUInstructionsView.xib in Resources */, 8D89696A1C755D0200D32E8A /* LaunchScreen.storyboard in Resources */, 8D8969671C755D0200D32E8A /* Assets.xcassets in Resources */, 8D8969651C755D0200D32E8A /* Main.storyboard in Resources */, @@ -149,8 +240,15 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8D8969621C755D0200D32E8A /* ViewController.m in Sources */, + C7DD0BA71C7A14F500361D17 /* HUTableViewCell.m in Sources */, 8D89695F1C755D0200D32E8A /* AppDelegate.m in Sources */, + C7A854091C7A74C400518AF8 /* NSArray+Shuffle.m in Sources */, + C7DD0BAB1C7A16FA00361D17 /* HUData.m in Sources */, + C7DD0BB61C7A2CE100361D17 /* HUGameViewController.m in Sources */, + C7DD0BB91C7A2E7600361D17 /* HUInstructionsView.m in Sources */, + C7A853FE1C7A50D500518AF8 /* UIColor+FadeColor.m in Sources */, + C7DD0BB01C7A22D900361D17 /* HUTableViewController.m in Sources */, + C7DD0BB31C7A23FE00361D17 /* HUCategoryGenerator.m in Sources */, 8D89695C1C755D0200D32E8A /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -203,6 +301,7 @@ GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREFIX_HEADER = "HeadsUpper/HeadsUp-Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -244,6 +343,7 @@ ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; + GCC_PREFIX_HEADER = "HeadsUpper/HeadsUp-Prefix.pch"; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -300,6 +400,7 @@ 8D8969701C755D0200D32E8A /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/HeadsUpper/HeadsUpper/Base.lproj/LaunchScreen.storyboard b/HeadsUpper/HeadsUpper/Base.lproj/LaunchScreen.storyboard index 2e721e1..92311c0 100644 --- a/HeadsUpper/HeadsUpper/Base.lproj/LaunchScreen.storyboard +++ b/HeadsUpper/HeadsUpper/Base.lproj/LaunchScreen.storyboard @@ -1,7 +1,8 @@ - + - + + @@ -15,8 +16,20 @@ + + + - + + + + + diff --git a/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard b/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard index f56d2f3..4353bcf 100644 --- a/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard +++ b/HeadsUpper/HeadsUpper/Base.lproj/Main.storyboard @@ -1,25 +1,111 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - + + - + - + - + + diff --git a/HeadsUpper/HeadsUpper/HUCategory.h b/HeadsUpper/HeadsUpper/HUCategory.h new file mode 100644 index 0000000..2ef20e2 --- /dev/null +++ b/HeadsUpper/HeadsUpper/HUCategory.h @@ -0,0 +1,25 @@ +// +// HUCategory.h +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#ifndef HUCategory_h +#define HUCategory_h + +typedef enum { + SuperStars= 0, + ThatsSo90s = 1, + HeyMrDJ, + Icons, + AnimalsGoneWild +}HUCategory; + +typedef enum { + OrangeColor = 0, + GreenColor = 1 +}ColorFade; + +#endif /* HUCategory_h */ diff --git a/HeadsUpper/HeadsUpper/HUCategoryGenerator.h b/HeadsUpper/HeadsUpper/HUCategoryGenerator.h new file mode 100644 index 0000000..d2d815c --- /dev/null +++ b/HeadsUpper/HeadsUpper/HUCategoryGenerator.h @@ -0,0 +1,15 @@ +// +// HUCategoryGenerator.h +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import + +@interface HUCategoryGenerator : NSObject + ++ (HUCategory)categoryForIndex:(NSUInteger)index; ++ (NSString *)getTitleForCategory:(HUCategory)category; +@end diff --git a/HeadsUpper/HeadsUpper/HUCategoryGenerator.m b/HeadsUpper/HeadsUpper/HUCategoryGenerator.m new file mode 100644 index 0000000..455b8e3 --- /dev/null +++ b/HeadsUpper/HeadsUpper/HUCategoryGenerator.m @@ -0,0 +1,59 @@ +// +// HUCategoryGenerator.m +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import "HUCategoryGenerator.h" + +@implementation HUCategoryGenerator + ++ (HUCategory)categoryForIndex:(NSUInteger)index { + switch (index) { + case 0: + return SuperStars; + break; + case 1: + return ThatsSo90s; + break; + case 2: + return HeyMrDJ; + break; + case 3: + return Icons; + break; + case 4: + return AnimalsGoneWild; + break; + default: + return SuperStars; + break; + } + +} + ++ (NSString *)getTitleForCategory:(HUCategory)category{ + + switch (category) { + case SuperStars: + return @"Superstars"; + break; + case ThatsSo90s: + return @"That's So 90s"; + break; + case HeyMrDJ: + return @"Hey Mr.DJ"; + break; + case Icons: + return @"Icons"; + break; + case AnimalsGoneWild: + return @"Animals Gone Wild"; + break; + default: + break; + } +} +@end diff --git a/HeadsUpper/HeadsUpper/HUData.h b/HeadsUpper/HeadsUpper/HUData.h new file mode 100644 index 0000000..20e2c13 --- /dev/null +++ b/HeadsUpper/HeadsUpper/HUData.h @@ -0,0 +1,19 @@ +// +// HUData.h +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import + +@interface HUData : NSObject + +@property (nonatomic) NSDictionary *data; + ++ (instancetype)sharedData; + +- (NSArray *)dataForCategory:(HUCategory)category; + +@end diff --git a/HeadsUpper/HeadsUpper/HUData.m b/HeadsUpper/HeadsUpper/HUData.m new file mode 100644 index 0000000..4a2486f --- /dev/null +++ b/HeadsUpper/HeadsUpper/HUData.m @@ -0,0 +1,65 @@ +// +// HUData.m +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import "HUData.h" + +@implementation HUData + ++ (instancetype)sharedData{ + static HUData *sharedData = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedData = [[self alloc] init]; + [sharedData setupData]; + }); + return sharedData; +} + + +- (NSArray *)dataForCategory:(HUCategory)category{ + + switch (category) { + case SuperStars: + return self.data[@"Superstars"]; + break; + case ThatsSo90s: + return self.data[@"ThatsSo90s"]; + break; + case HeyMrDJ: + return self.data[@"HeyMrDJ"]; + break; + case Icons: + return self.data[@"Icons"]; + break; + case AnimalsGoneWild: + return self.data[@"AnimalsGoneWild"]; + break; + default: + break; + } +} + + +- (void)setupData { + + self.data = @{ + @"Superstars" : @[@"Janet Jackson", @"Leighton Meester", @"Willow Smith", @"Matt Lauer", @"Josh Duhamel", @"Sharon Osbourne", @"Spencer Pratt", @"Demi Moore", @"Whitney Houston", @"Nicole Kidman", @"Miley Cyrus", @"Victoria Beckham", @"LeAnn Rimes", @"Dakota Fanning", @"Dr. Seuss", @"Ryan Phillippe", @"Steve Carell", @"Chris Rock", @"Collin Ferell", @"Drake", @"Rachel McAdams", @"Maya Rudolph"], + + @"ThatsSo90s" : @[@"El Niño", @"Viagra", @"Animaniacs", @"League of their Own", @"Happy Gilmore", @"Nick Carter", @"My Heart Will Go On", @"I Know What You Did Last Summer", @"Can You Feel The Love Tonight", @"The Macarana", @"Light-up Sneakers", @"Boy Meets World", @"Baby Got Back", @"Smells Like Teen Spirit", @"Super Soakers", @"7th Heaven", @"Garth Brooks", @"Floppy Discs", @"Kramer", @"Blink 182", @"Surge"], + + @"HeyMrDJ" : @[@"\"Girl On Fire\" Alicia Keys", @"\"U Can't Touch This\" MC Hammer", @"\"Hello\" Lionel Richie", @"\"Dark Horse\" Katy Perry", @"\"Someboyd To Love\" Queen", @"\"No Scrubs\" TLC", @"\"Happy\" Pharrell Williams", @"\"Piano Man\" Billy Joel", @"\"Blurred Lines\" Robin Thicke", @"\"Fantasy\" Mariah Carey", @"\"I Will Survive\" Gloria Gaynor", @"\"Come and Get it\" Selena Gomez", @"\"Halo\" Beyonce", @"\"I Believe I Can Fly\" R.Kelly", @"\"The Sign\" Ace of Base", @"\"Diamonds\" Rihanna", @"\"A Thousand Miles\" Vanessa Carlton", @"\"What a Wonderful World\" Louis Armstrong", @"\"We Belong Together\" Mariah Carey", @"\"(I Can't Get No) Satisfaction\""], + + @"Icons" : @[@"Colin Farrell", @"Mozart", @"Billy Joel", @"Judy Garland", @"Napoleon Bonaparte", @"Queen Elizabeth II", @"Fred Armisen", @"Henry Ford", @"Jon Lovitz", @"Julia Child", @"Catherine the Great", @"Magic Johnson", @"Uma Thurman", @"Orson Welles", @"Kathy Bates", @"George Orwell", @"Billy Crystal", @"Farrah Fawcett", @"Gary Busey", @"Chris Farley", @"Tom Selleck", @"Alexander the Great"], + + @"AnimalsGoneWild" : @[@"Chipmunk", @"Dragon", @"Wasp", @"Snake", @"Jellyfish", @"Emu", @"Boar", @"Crocodile", @"Shrimp", @"Lemur", @"Caterpillar", @"Sea Urchain", @"Dolphin ", @"Camel", @"Viper", @"Fox", @"Tuna", @"Baboon", @"Chinchilla", @"Human", @"Crawfish", @"Cricket", @"Frog", @"Tiger", @"Guinea Pig", @"Gnat", @"Killer Whale", @"Coral", @"T-Rex", @"Oyster"] + + }; + +} + +@end diff --git a/HeadsUpper/HeadsUpper/HUGameViewController.h b/HeadsUpper/HeadsUpper/HUGameViewController.h new file mode 100644 index 0000000..1b8481b --- /dev/null +++ b/HeadsUpper/HeadsUpper/HUGameViewController.h @@ -0,0 +1,15 @@ +// +// HUGameViewController.h +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import + +@interface HUGameViewController : UIViewController + +@property (nonatomic) HUCategory category; + +@end diff --git a/HeadsUpper/HeadsUpper/HUGameViewController.m b/HeadsUpper/HeadsUpper/HUGameViewController.m new file mode 100644 index 0000000..527411e --- /dev/null +++ b/HeadsUpper/HeadsUpper/HUGameViewController.m @@ -0,0 +1,220 @@ +// +// HUGameViewController.m +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import "HUGameViewController.h" +#import "HUInstructionsView.h" +#import "HUData.h" +#import "UIColor+FadeColor.h" +#import "NSArray+Shuffle.h" +#import + +@interface HUGameViewController () + +@property (weak, nonatomic) IBOutlet UILabel *questionLabel; +@property (weak, nonatomic) IBOutlet UILabel *timerLabel; + +@property (nonatomic) BOOL inAnswerState; +@property (nonatomic) HUInstructionsView *instructionView; +@property (nonatomic) NSArray *questionsArray; +@property (nonatomic) NSTimer *gameTimer; +@property (nonatomic) NSInteger currentIndex; +@property (nonatomic) NSMutableDictionary *correctQuestion; +@property (nonatomic) NSInteger timerLoopCount; +@property (nonatomic) CMMotionManager *motionManager; + +@end + +@implementation HUGameViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + self.questionsArray = [[HUData sharedData] dataForCategory:self.category]; + + if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { + self.navigationController.interactivePopGestureRecognizer.enabled = NO; + } + + self.currentIndex = 0; + self.correctQuestion = [NSMutableDictionary new]; + self.timerLoopCount = 15; + [self shuffle]; + [self trackAccelerometer]; +} + +- (void)viewWillAppear:(BOOL)animated{ + [super viewWillAppear:animated]; + if (!self.gameTimer) { + [self setupInstructionView]; + } + +} + +- (void)viewWillDisappear:(BOOL)animated{ + [super viewWillDisappear:animated]; + self.instructionView = nil; + if (self.gameTimer) { + [self formatTimer]; + } +} +#pragma mark - In Game Methods + +- (void)startGame { + [self displayQuestionForIndex:self.currentIndex]; + [self formatTimer]; +} + +- (void)displayQuestionForIndex:(NSInteger)index { + self.questionLabel.text = self.questionsArray[index]; +} + +- (void)nextQuestion { + self.currentIndex++; + if (self.currentIndex < self.questionsArray.count) { + [self displayQuestionForIndex:self.currentIndex]; + }else{ + [self endGame]; + } + +} + +- (void)skipQuestion{ + [self animateToColorFade:OrangeColor]; +} + +- (void)correctlyAnswered{ + self.correctQuestion[@(self.currentIndex)] = @(self.currentIndex); + [self animateToColorFade:GreenColor]; + +} + +- (void)formatTimer{ + if (!self.gameTimer) { + self.gameTimer = [NSTimer timerWithTimeInterval:1.0f target:self selector:@selector(updateTimerLabel) userInfo:nil repeats:YES]; + [[NSRunLoop currentRunLoop]addTimer:self.gameTimer forMode:NSRunLoopCommonModes]; + } else{ + [self.gameTimer invalidate]; + self.gameTimer = nil; + } +} + +- (void)updateTimerLabel { + self.timerLoopCount--; + self.timerLabel.text = [NSString stringWithFormat:@"%ld",self.timerLoopCount]; + + if (self.timerLoopCount <= 5){ + self.timerLabel.textColor = [UIColor redColor]; + }else{ + self.timerLabel.textColor = [UIColor blackColor]; + } + + if (self.timerLoopCount == 0) { + [self endGame]; + } +} + +- (void)endGame { + [self formatTimer]; + [self launchAlert]; + +} +#pragma mark - Fade Animation + +- (void)animateToColorFade:(ColorFade)fade { + + __weak typeof(self) weakSelf = self; + + [UIView animateWithDuration:.35 animations:^{ + weakSelf.view.backgroundColor = [UIColor colorForFadeType:fade]; + } completion:^(BOOL finished) { + + [UIView animateWithDuration:.25 animations:^{ + weakSelf.view.backgroundColor = [UIColor whiteColor]; + } + completion:^(BOOL finished) { + [weakSelf nextQuestion]; + + }]; + }]; +} + +- (void)shuffle { + self.questionsArray = [NSArray shuffle:self.questionsArray]; +} + +#pragma mark - Instruction View Setup/Delegate + +- (void)didTapStartButton{ + + __weak typeof(self) weakSelf = self; + [UIView animateWithDuration:.2 animations:^{ + + weakSelf.instructionView.frame = CGRectMake(weakSelf.view.center.x,weakSelf.view.center.y,0,0); + }completion:^(BOOL finished) { + [weakSelf.instructionView removeFromSuperview]; + weakSelf.instructionView = nil; + [weakSelf startGame]; + }]; + +} + +- (void)setupInstructionView { + self.instructionView = [[[NSBundle mainBundle] loadNibNamed:@"HUInstructionsView" owner:self options:nil] firstObject]; + self.instructionView.frame = CGRectMake(0, 74, self.view.bounds.size.width-70, self.view.bounds.size.height - 150); + self.instructionView.center = self.view.center; + self.instructionView.layer.cornerRadius = 20; + + [self.view addSubview:self.instructionView]; + + self.instructionView.delegate = self; +} + +- (void)trackAccelerometer { + self.motionManager = [[CMMotionManager alloc]init]; + self.motionManager.accelerometerUpdateInterval = 1.0f/60.0f; + + [self.motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue currentQueue] + withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) { + [self handleAccelerometer:accelerometerData.acceleration]; + if(error){ + NSLog(@"No Data for accel"); + } + }]; +} + +- (void)handleAccelerometer:(CMAcceleration)acceleration { + if (self.gameTimer) { + if (!self.inAnswerState) { + if (acceleration.z > 0.85f) { + self.inAnswerState = YES; + [self correctlyAnswered]; + } + else if(acceleration.z < -0.85f){ + self.inAnswerState = YES; + [self skipQuestion]; + } + } + else{ + if (acceleration.z < .2f && acceleration.z > -.2f) { + self.inAnswerState = NO; + } + } + } +} + +#pragma mark - Alert +- (void)launchAlert { + UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Stats!" message:[NSString stringWithFormat:@"You scored %ld out of %ld",self.correctQuestion.allKeys.count, self.questionsArray.count] preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OMG YES!" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [self dismissViewControllerAnimated:YES completion:nil]; + }]; + + [alert addAction:ok]; + [self presentViewController:alert animated:YES completion:nil]; +} +@end \ No newline at end of file diff --git a/HeadsUpper/HeadsUpper/HUInstructionsView.h b/HeadsUpper/HeadsUpper/HUInstructionsView.h new file mode 100644 index 0000000..1974613 --- /dev/null +++ b/HeadsUpper/HeadsUpper/HUInstructionsView.h @@ -0,0 +1,21 @@ +// +// HUInstructionsView.h +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import + +@protocol HUInstructionsProtocol + +- (void)didTapStartButton; + +@end + +@interface HUInstructionsView : UIView +@property (nonatomic) IBOutletCollection(UILabel) NSArray *labels; +@property (nonatomic) id delegate; + +@end diff --git a/HeadsUpper/HeadsUpper/HUInstructionsView.m b/HeadsUpper/HeadsUpper/HUInstructionsView.m new file mode 100644 index 0000000..d7c3ee8 --- /dev/null +++ b/HeadsUpper/HeadsUpper/HUInstructionsView.m @@ -0,0 +1,25 @@ +// +// HUInstructionsView.m +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import "HUInstructionsView.h" + +@implementation HUInstructionsView + +- (IBAction)startButtonTapped:(UIButton *)sender { + sender.hidden = YES; + [self clearAllLabels]; + [self.delegate didTapStartButton]; +} + +- (void)clearAllLabels { + for (UILabel *label in self.labels) { + label.text = @""; + } +} + +@end diff --git a/HeadsUpper/HeadsUpper/HUInstructionsView.xib b/HeadsUpper/HeadsUpper/HUInstructionsView.xib new file mode 100644 index 0000000..3fca749 --- /dev/null +++ b/HeadsUpper/HeadsUpper/HUInstructionsView.xib @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HeadsUpper/HeadsUpper/HUTableViewController.h b/HeadsUpper/HeadsUpper/HUTableViewController.h new file mode 100644 index 0000000..f3ba4ee --- /dev/null +++ b/HeadsUpper/HeadsUpper/HUTableViewController.h @@ -0,0 +1,13 @@ +// +// HUTableViewController.h +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import + +@interface HUTableViewController : UITableViewController + +@end diff --git a/HeadsUpper/HeadsUpper/HUTableViewController.m b/HeadsUpper/HeadsUpper/HUTableViewController.m new file mode 100644 index 0000000..a78e3a6 --- /dev/null +++ b/HeadsUpper/HeadsUpper/HUTableViewController.m @@ -0,0 +1,61 @@ +// +// HUTableViewController.m +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import "HUTableViewController.h" +#import "HUTableViewCell.h" +#import "HUCategoryGenerator.h" +#import "HUGameViewController.h" + +@interface HUTableViewController () + +@end + +@implementation HUTableViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + [self.tableView registerNib:[UINib nibWithNibName:@"HUTableViewCell" bundle:nil] forCellReuseIdentifier:@"HUCell"]; + self.tableView.estimatedRowHeight = 20.0f; +} + + +#pragma mark - Table view data source + +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return 5; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ + return self.view.bounds.size.height/(3.5); +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + HUTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HUCell" forIndexPath:indexPath]; + + cell.category = [HUCategoryGenerator categoryForIndex:indexPath.row]; + cell.title = [HUCategoryGenerator getTitleForCategory:cell.category]; + cell.titleLabel.text = cell.title; + + return cell; +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ + + HUGameViewController *gameVC = [self.storyboard instantiateViewControllerWithIdentifier:@"GameViewController"]; + + gameVC.category = [HUCategoryGenerator categoryForIndex:indexPath.row]; + + [self.navigationController pushViewController:gameVC animated:YES]; +} + +@end diff --git a/HeadsUpper/HeadsUpper/HeadsUp-Prefix.pch b/HeadsUpper/HeadsUpper/HeadsUp-Prefix.pch new file mode 100644 index 0000000..6c4c77a --- /dev/null +++ b/HeadsUpper/HeadsUpper/HeadsUp-Prefix.pch @@ -0,0 +1,16 @@ +// +// HeadsUp-Prefix.pch +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#ifndef HeadsUp_Prefix_pch +#define HeadsUp_Prefix_pch + +// Include any system framework and library headers here that should be included in all compilation units. +// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file. +#import "HUCategory.h" + +#endif /* HeadsUp_Prefix_pch */ diff --git a/HeadsUpper/HeadsUpper/NSArray+Shuffle.h b/HeadsUpper/HeadsUpper/NSArray+Shuffle.h new file mode 100644 index 0000000..65c6343 --- /dev/null +++ b/HeadsUpper/HeadsUpper/NSArray+Shuffle.h @@ -0,0 +1,15 @@ +// +// NSArray+Shuffle.h +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import + +@interface NSArray (Shuffle) + ++ (instancetype)shuffle:(NSArray *)original; + +@end diff --git a/HeadsUpper/HeadsUpper/NSArray+Shuffle.m b/HeadsUpper/HeadsUpper/NSArray+Shuffle.m new file mode 100644 index 0000000..ca516d7 --- /dev/null +++ b/HeadsUpper/HeadsUpper/NSArray+Shuffle.m @@ -0,0 +1,26 @@ +// +// NSArray+Shuffle.m +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import "NSArray+Shuffle.h" + +@implementation NSArray (Shuffle) + ++ (instancetype)shuffle:(NSArray *)original{ + NSMutableArray *shuffled = [NSMutableArray arrayWithArray:original]; + + for (int i = 0; i < shuffled.count; i++) { + int j = arc4random_uniform((int)shuffled.count); + id temp = shuffled[j]; + [shuffled replaceObjectAtIndex:j withObject:shuffled[i]]; + [shuffled replaceObjectAtIndex:i withObject:temp]; + } + + return (NSArray *)shuffled; +} + +@end diff --git a/HeadsUpper/HeadsUpper/ViewController.h b/HeadsUpper/HeadsUpper/ViewController.h deleted file mode 100644 index 65d6cf5..0000000 --- a/HeadsUpper/HeadsUpper/ViewController.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// ViewController.h -// HeadsUpper -// -// Created by Michael Kavouras on 2/17/16. -// Copyright © 2016 Michael Kavouras. All rights reserved. -// - -#import - -@interface ViewController : UIViewController - - -@end - diff --git a/HeadsUpper/HeadsUpper/ViewController.m b/HeadsUpper/HeadsUpper/ViewController.m deleted file mode 100644 index 14ce57a..0000000 --- a/HeadsUpper/HeadsUpper/ViewController.m +++ /dev/null @@ -1,27 +0,0 @@ -// -// ViewController.m -// HeadsUpper -// -// Created by Michael Kavouras on 2/17/16. -// Copyright © 2016 Michael Kavouras. All rights reserved. -// - -#import "ViewController.h" - -@interface ViewController () - -@end - -@implementation ViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -@end diff --git a/HeadsUpper/UIColor+FadeColor.h b/HeadsUpper/UIColor+FadeColor.h new file mode 100644 index 0000000..9d480ce --- /dev/null +++ b/HeadsUpper/UIColor+FadeColor.h @@ -0,0 +1,15 @@ +// +// UIColor+FadeColor.h +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import + +@interface UIColor (FadeColor) + ++ (instancetype)colorForFadeType:(ColorFade)fade; + +@end diff --git a/HeadsUpper/UIColor+FadeColor.m b/HeadsUpper/UIColor+FadeColor.m new file mode 100644 index 0000000..bb67bc0 --- /dev/null +++ b/HeadsUpper/UIColor+FadeColor.m @@ -0,0 +1,25 @@ +// +// UIColor+FadeColor.m +// HeadsUpper +// +// Created by Varindra Hart on 2/21/16. +// Copyright © 2016 Michael Kavouras. All rights reserved. +// + +#import "UIColor+FadeColor.h" + +@implementation UIColor (FadeColor) + ++ (instancetype)colorForFadeType:(ColorFade)fade{ + + switch (fade) { + case OrangeColor: + return [UIColor orangeColor]; + break; + default: + return [UIColor greenColor]; + break; + } +} + +@end