summary refs log tree commit diff stats
path: root/Classes/GameModeSelectionLayer.m
diff options
context:
space:
mode:
Diffstat (limited to 'Classes/GameModeSelectionLayer.m')
-rw-r--r--Classes/GameModeSelectionLayer.m82
1 files changed, 82 insertions, 0 deletions
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