summary refs log tree commit diff stats
path: root/Classes
diff options
context:
space:
mode:
Diffstat (limited to 'Classes')
-rw-r--r--Classes/GameModeSelection.h30
-rw-r--r--Classes/GameModeSelection.m88
-rw-r--r--Classes/GameModeSelectionLayer.h17
-rw-r--r--Classes/GameModeSelectionLayer.m82
-rwxr-xr-xClasses/MainMenuLayer.h1
-rwxr-xr-xClasses/MainMenuLayer.m13
-rw-r--r--Classes/TutorialMode.m3
7 files changed, 223 insertions, 11 deletions
diff --git a/Classes/GameModeSelection.h b/Classes/GameModeSelection.h new file mode 100644 index 0000000..aadbf36 --- /dev/null +++ b/Classes/GameModeSelection.h
@@ -0,0 +1,30 @@
1//
2// GameModeSelection.h
3// Cartographic
4//
5// Created by Starla Insigna on 8/18/11.
6// Copyright 2011 Four Island. All rights reserved.
7//
8
9#import "cocos2d.h"
10
11@interface GameModeSelection : CCNode {
12 NSString* name;
13 NSString* location;
14 BOOL unlocked;
15 int highscore;
16 NSString* unlockCondition;
17
18 CCLabelBMFont* nameLabel;
19 CCSprite* picture;
20 CCLabelBMFont* otherLabel;
21}
22
23@property (readonly) NSString* name;
24@property (readonly) NSString* location;
25@property (readonly) BOOL unlocked;
26@property (nonatomic,assign) int highscore;
27@property (nonatomic,retain) NSString* unlockCondition;
28- (id)initWithName:(NSString*)name location:(NSString*)location filename:(NSString*)filename unlocked:(BOOL)unlocked;
29
30@end
diff --git a/Classes/GameModeSelection.m b/Classes/GameModeSelection.m new file mode 100644 index 0000000..56e65d9 --- /dev/null +++ b/Classes/GameModeSelection.m
@@ -0,0 +1,88 @@
1//
2// GameModeSelection.m
3// Cartographic
4//
5// Created by Starla Insigna on 8/18/11.
6// Copyright 2011 Four Island. All rights reserved.
7//
8
9#import "GameModeSelection.h"
10
11@implementation GameModeSelection
12
13@synthesize name, location, unlocked, highscore, unlockCondition;
14
15- (id)initWithName:(NSString*)m_name location:(NSString*)m_location filename:(NSString*)filename unlocked:(BOOL)m_unlocked;
16{
17 self = [super init];
18
19 if (nil != self)
20 {
21 self.anchorPoint = CGPointMake(0.5f, 0.5f);
22
23 name = m_name;
24 location = m_location;
25 unlocked = m_unlocked;
26
27 if (!unlocked)
28 {
29 name = [@"" stringByPaddingToLength:name.length withString:@"?" startingAtIndex:0];
30 location = [@"" stringByPaddingToLength:location.length withString:@"?" startingAtIndex:0];
31 }
32
33 nameLabel = [CCLabelBMFont labelWithString:[NSString stringWithFormat:@"%@ (%@)", location, name] fntFile:@"levelnames.fnt"];
34
35 [self addChild:nameLabel];
36 nameLabel.position = ccp(0, -32-nameLabel.contentSize.height);
37
38 UIImage* innerPicture = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:filename ofType:@"png"]];
39 UIGraphicsBeginImageContext(CGSizeMake(128, 128));
40 CGContextRef context = UIGraphicsGetCurrentContext();
41 UIGraphicsPushContext(context);
42
43 if (unlocked)
44 {
45 [innerPicture drawInRect:CGRectMake(0, 0, 128, 128)];
46 } else {
47 CGContextSetFillColorWithColor(context, [[UIColor whiteColor] CGColor]);
48 CGContextFillRect(context, CGRectMake(0, 0, 128, 128));
49 [innerPicture drawInRect:CGRectMake(0, 0, 128, 128) blendMode:kCGBlendModeLuminosity alpha:1.0];
50 }
51
52 UIGraphicsPopContext();
53 CGImageRef innerPictureRef = [UIGraphicsGetImageFromCurrentImageContext() CGImage];
54 UIGraphicsEndImageContext();
55
56 picture = [CCSprite spriteWithCGImage:innerPictureRef key:filename];
57 picture.position = ccp(0, 32);
58 [self addChild:picture];
59 }
60
61 return self;
62}
63
64- (void)setHighscore:(int)m_highscore
65{
66 if (unlocked)
67 {
68 highscore = m_highscore;
69
70 otherLabel = [CCLabelBMFont labelWithString:[NSString stringWithFormat:@"Highscore: %d", highscore] fntFile:@"leveldescriptions.fnt"];
71 otherLabel.position = ccp(0, -32-nameLabel.contentSize.height-otherLabel.contentSize.height);
72 [self addChild:otherLabel];
73 }
74}
75
76- (void)setUnlockCondition:(NSString *)m_unlockCondition
77{
78 if (!unlocked)
79 {
80 unlockCondition = m_unlockCondition;
81
82 otherLabel = [CCLabelBMFont labelWithString:unlockCondition fntFile:@"leveldescriptions.fnt"];
83 otherLabel.position = ccp(0, -32-nameLabel.contentSize.height-otherLabel.contentSize.height);
84 [self addChild:otherLabel];
85 }
86}
87
88@end
diff --git a/Classes/GameModeSelectionLayer.h b/Classes/GameModeSelectionLayer.h new file mode 100644 index 0000000..2f57bfb --- /dev/null +++ b/Classes/GameModeSelectionLayer.h
@@ -0,0 +1,17 @@
1//
2// GameModeSelectionLayer.h
3// Cartographic
4//
5// Created by Starla Insigna on 8/18/11.
6// Copyright 2011 Four Island. All rights reserved.
7//
8
9#import "cocos2d.h"
10
11@interface GameModeSelectionLayer : CCLayer
12
13+ (CCScene*)scene;
14- (id)init;
15- (void)mainmenu;
16
17@end
diff --git a/Classes/GameModeSelectionLayer.m b/Classes/GameModeSelectionLayer.m new file mode 100644 index 0000000..3e1995e --- /dev/null +++ b/Classes/GameModeSelectionLayer.m
@@ -0,0 +1,82 @@
1//
2// GameModeSelectionLayer.m
3// Cartographic
4//
5// Created by Starla Insigna on 8/18/11.
6// Copyright 2011 Four Island. All rights reserved.
7//
8
9#import "GameModeSelectionLayer.h"
10#import "GameModeSelection.h"
11#import <sqlite3.h>
12#import "Cart_CollectAppDelegate.h"
13#import "MainMenuLayer.h"
14
15@implementation GameModeSelectionLayer
16
17+ (CCScene*)scene
18{
19 CCScene* scene = [CCScene node];
20
21 CCLayer* backgroundLayer = [[[CCLayer alloc] init] autorelease];
22 CCSprite* backgroundImage = [CCSprite spriteWithFile:@"paintdaubs.png"];
23 backgroundImage.position = ccp(240,160);
24 [backgroundLayer addChild:backgroundImage];
25 [scene addChild:backgroundLayer];
26
27 GameModeSelectionLayer* layer = [GameModeSelectionLayer node];
28 [scene addChild:layer];
29
30 return scene;
31}
32
33- (id)init
34{
35 self = [super init];
36
37 if (nil != self)
38 {
39 // Initialization code here.
40 GameModeSelection* tutorialSelection = [[[GameModeSelection alloc] initWithName:@"Tutorial" location:@"Florence" filename:@"florence" unlocked:YES] autorelease];
41 tutorialSelection.position = ccp(160-32,160);
42 [self addChild:tutorialSelection];
43
44 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
45 GameModeSelection* collectSelection = [[[GameModeSelection alloc] initWithName:@"Collect" location:@"Paris" filename:@"paris" unlocked:[defaults boolForKey:@"hasDoneTutorial"]] autorelease];
46 collectSelection.position = ccp(400-32, 160);
47
48 if (collectSelection.unlocked)
49 {
50 const char* sqlQuery = "SELECT * FROM highscores ORDER BY score DESC LIMIT 1";
51 sqlite3_stmt* compiled_statement;
52
53 if (sqlite3_prepare_v2([Cart_CollectAppDelegate database], sqlQuery, -1, &compiled_statement, NULL) == SQLITE_OK)
54 {
55 if (sqlite3_step(compiled_statement) == SQLITE_ROW)
56 {
57 int score = sqlite3_column_int(compiled_statement, 2);
58
59 [collectSelection setHighscore:score];
60 }
61 }
62 } else {
63 [collectSelection setUnlockCondition:@"Beat the tutorial!"];
64 }
65
66 [self addChild:collectSelection];
67
68 CCMenuItemImage* newgameMenuItem = [CCMenuItemImage itemFromNormalImage:@"back.png" selectedImage:@"back2.png" target:self selector:@selector(mainmenu)];
69 CCMenu* myMenu = [CCMenu menuWithItems:newgameMenuItem, nil];
70 myMenu.position = ccp(240, 30);
71 [self addChild:myMenu];
72 }
73
74 return self;
75}
76
77- (void)mainmenu
78{
79 [[CCDirector sharedDirector] replaceScene:[MainMenuLayer scene]];
80}
81
82@end
diff --git a/Classes/MainMenuLayer.h b/Classes/MainMenuLayer.h index e43c5e1..d8483b3 100755 --- a/Classes/MainMenuLayer.h +++ b/Classes/MainMenuLayer.h
@@ -16,7 +16,6 @@
16+ (CCScene*)scene; 16+ (CCScene*)scene;
17- (id)init; 17- (id)init;
18- (void)newgame; 18- (void)newgame;
19- (void)tutorial;
20- (void)highscores; 19- (void)highscores;
21 20
22@end 21@end
diff --git a/Classes/MainMenuLayer.m b/Classes/MainMenuLayer.m index 8b21fab..06a528c 100755 --- a/Classes/MainMenuLayer.m +++ b/Classes/MainMenuLayer.m
@@ -8,8 +8,7 @@
8 8
9#import "MainMenuLayer.h" 9#import "MainMenuLayer.h"
10#import "HighscoreListController.h" 10#import "HighscoreListController.h"
11#import "ClassicGameMode.h" 11#import "GameModeSelectionLayer.h"
12#import "TutorialMode.h"
13#import "Cart_CollectAppDelegate.h" 12#import "Cart_CollectAppDelegate.h"
14 13
15@implementation MainMenuLayer 14@implementation MainMenuLayer
@@ -45,10 +44,9 @@
45 //CCMenuItemLabel* menuItem2 = [CCMenuItemLabel itemWithLabel:menuItemLabel2 target:self selector:@selector(highscores)]; 44 //CCMenuItemLabel* menuItem2 = [CCMenuItemLabel itemWithLabel:menuItemLabel2 target:self selector:@selector(highscores)];
46 45
47 CCMenuItemImage* newgameMenuItem = [CCMenuItemImage itemFromNormalImage:@"newgame.png" selectedImage:@"newgame2.png" target:self selector:@selector(newgame)]; 46 CCMenuItemImage* newgameMenuItem = [CCMenuItemImage itemFromNormalImage:@"newgame.png" selectedImage:@"newgame2.png" target:self selector:@selector(newgame)];
48 CCMenuItemImage* tutorialMenuItem = [CCMenuItemImage itemFromNormalImage:@"tutorial.png" selectedImage:@"tutorial2.png" target:self selector:@selector(tutorial)];
49 CCMenuItemImage* highscoresMenuItem = [CCMenuItemImage itemFromNormalImage:@"highscores.png" selectedImage:@"highscores2.png" target:self selector:@selector(highscores)]; 47 CCMenuItemImage* highscoresMenuItem = [CCMenuItemImage itemFromNormalImage:@"highscores.png" selectedImage:@"highscores2.png" target:self selector:@selector(highscores)];
50 48
51 CCMenu* menu = [CCMenu menuWithItems:newgameMenuItem, tutorialMenuItem, highscoresMenuItem, nil]; 49 CCMenu* menu = [CCMenu menuWithItems:newgameMenuItem, highscoresMenuItem, nil];
52 [menu alignItemsVertically]; 50 [menu alignItemsVertically];
53 menu.position = ccp(240, 100); 51 menu.position = ccp(240, 100);
54 [self addChild:menu]; 52 [self addChild:menu];
@@ -59,12 +57,7 @@
59 57
60- (void)newgame 58- (void)newgame
61{ 59{
62 [[CCDirector sharedDirector] replaceScene:[ClassicGameMode scene]]; 60 [[CCDirector sharedDirector] replaceScene:[GameModeSelectionLayer scene]];
63}
64
65- (void)tutorial
66{
67 [[CCDirector sharedDirector] replaceScene:[TutorialMode scene]];
68} 61}
69 62
70- (void)highscores 63- (void)highscores
diff --git a/Classes/TutorialMode.m b/Classes/TutorialMode.m index 1ada34a..c28bd08 100644 --- a/Classes/TutorialMode.m +++ b/Classes/TutorialMode.m
@@ -331,6 +331,9 @@
331 331
332 [self unschedule:@selector(randomlyAddObject:)]; 332 [self unschedule:@selector(randomlyAddObject:)];
333 333
334 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
335 [defaults setBool:YES forKey:@"hasDoneTutorial"];
336
334 return; 337 return;
335 } else { 338 } else {
336 NSLog(@"randomItemsDropped in TutorialMode is greater than 15--this should never happen."); 339 NSLog(@"randomItemsDropped in TutorialMode is greater than 15--this should never happen.");