diff options
author | Starla Insigna <starla4444@gmail.com> | 2011-08-18 15:51:48 -0400 |
---|---|---|
committer | Starla Insigna <starla4444@gmail.com> | 2011-08-18 15:51:48 -0400 |
commit | 3750d7aa4e307d1f2099eceaa21014151e78d364 (patch) | |
tree | 77487a1cc5fd055d2d8096a158d4908a5e4094fa /Classes/GameModeSelectionLayer.m | |
parent | 6906cf0ce4f8266173d67a7b9fccc56747d5d618 (diff) | |
download | cartcollect-3750d7aa4e307d1f2099eceaa21014151e78d364.tar.gz cartcollect-3750d7aa4e307d1f2099eceaa21014151e78d364.tar.bz2 cartcollect-3750d7aa4e307d1f2099eceaa21014151e78d364.zip |
Started game mode selection screen
So far, tapping "New Game" shows a screen with two game modes: the tutorial and the classic collect. They both have pictures and Collect's is grayscale if it hasn't been unlocked yet (a.k.a. the tutorial hasn't been completed yet). Also, Collect's title is replaced with question marks and the text "Beat the tutorial!" is shown if it isn't unlocked--if it is unlocked, the player's highscore, if they have one, is shown. A "Back to Main Menu" button is also present. Neither selection is as of yet tappable, and neither picture yet has a border. You cannot scroll through modes yet either. Refs #207
Diffstat (limited to 'Classes/GameModeSelectionLayer.m')
-rw-r--r-- | Classes/GameModeSelectionLayer.m | 82 |
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 | ||