-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
386 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+4.28 KB
(120%)
...xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
#import <UIKit/UIKit.h> | |||
#import "TileGrid.h" | |||
|
|||
@interface AnswerGrid : TileGrid | |||
{ | |||
NSString *answer; | |||
NSArray *answerWords; | |||
} | |||
|
|||
- (Tile *) getNextTile; | |||
- (void) setNextTileUsingTile:(Tile *)srcTile; | |||
- (BOOL) atWordBoundry; | |||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,172 @@ | |||
#import "Tile.h" | |||
#import "AnswerGrid.h" | |||
|
|||
@implementation AnswerGrid | |||
|
|||
int answerLength; | |||
int answerIndex; | |||
NSMutableArray *wordBoundries; | |||
|
|||
- (void) setup | |||
{ | |||
answer = @"THE BIGGER THEY COME THE HARDER THEY FALL"; | |||
answerWords = [answer componentsSeparatedByString: @" "]; | |||
gw = 15; | |||
gh = 3; | |||
margin = 2; | |||
answerIndex = 0; | |||
[self createGrid]; | |||
} | |||
|
|||
- (void) createLetters | |||
{ | |||
wordBoundries = [[NSMutableArray alloc] init]; | |||
int wordIndex = 0; | |||
int charIndex = 0; | |||
NSString *curWord = [answerWords objectAtIndex:wordIndex]; | |||
NSString *curLetter; | |||
BOOL complete = NO; | |||
answerLength = 0; | |||
|
|||
for (Tile* t in tiles) | |||
{ | |||
[t setIsSelectable:NO]; | |||
|
|||
if(complete) | |||
{ | |||
[t setHidden:YES]; | |||
} | |||
else | |||
{ | |||
[t setHidden:NO]; | |||
|
|||
answerLength++; | |||
curLetter = [curWord substringWithRange:[curWord rangeOfComposedCharacterSequenceAtIndex:charIndex]]; | |||
//[t setLetter:curLetter]; | |||
[t setCorrectLetter:curLetter]; | |||
[t setLetter:@""]; | |||
|
|||
charIndex++; | |||
|
|||
if(charIndex >= [curWord length]) | |||
{ | |||
[wordBoundries addObject:[NSNumber numberWithInt:answerLength]]; | |||
wordIndex++; | |||
charIndex = 0; | |||
if(wordIndex < [answerWords count]) | |||
{ | |||
curWord = [answerWords objectAtIndex:wordIndex]; | |||
} | |||
else | |||
{ | |||
complete = YES; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
|
|||
- (void) layoutGrid:(Boolean)useAnimation | |||
{ | |||
Tile *tile = [tiles objectAtIndex:0]; | |||
|
|||
float spcH = tile.bounds.size.width + margin; | |||
float spcV = tile.bounds.size.height + margin; | |||
|
|||
float l = 0; | |||
float t = 0; | |||
|
|||
CGRect fr = CGRectMake(l, t, tile.bounds.size.width, tile.bounds.size.height); | |||
|
|||
int wordIndex = 0; | |||
int charIndex = 0; | |||
NSString *curWord = [answerWords objectAtIndex:wordIndex]; | |||
BOOL complete = NO; | |||
|
|||
for (tile in tiles) | |||
{ | |||
if(!complete) | |||
{ | |||
tile.frame = fr; | |||
fr.origin.x += spcH; | |||
charIndex++; | |||
|
|||
if(charIndex >= [curWord length]) | |||
{ | |||
wordIndex++; | |||
charIndex = 0; | |||
fr.origin.x += spcH / 2; | |||
|
|||
if(wordIndex < [answerWords count]) | |||
{ | |||
curWord = [answerWords objectAtIndex:wordIndex]; | |||
if(fr.origin.x + [curWord length] * spcH > gw * spcH) | |||
{ | |||
fr.origin.x = l; | |||
fr.origin.y += spcV; | |||
} | |||
} | |||
else | |||
{ | |||
complete = YES; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
|
|||
- (Tile *) getNextTile | |||
{ | |||
Tile * result = nil; | |||
if(answerIndex < answerLength) | |||
{ | |||
result = [tiles objectAtIndex:answerIndex]; | |||
} | |||
return result; | |||
} | |||
|
|||
- (void) setNextTileUsingTile:(Tile *)srcTile | |||
{ | |||
if(answerIndex < answerLength) | |||
{ | |||
Tile *newTile = [tiles objectAtIndex:answerIndex]; | |||
[newTile setLetter:[srcTile letter]]; | |||
[newTile setOriginalIndex:srcTile.gridIndex]; | |||
//[newTile setIsSelectable:YES]; | |||
[newTile setSelected:YES]; | |||
|
|||
answerIndex++; | |||
} | |||
} | |||
|
|||
- (Tile *) removeCurrentTile | |||
{ | |||
Tile *result = nil; | |||
if(answerIndex > 0) | |||
{ | |||
result = [tiles objectAtIndex:answerIndex]; | |||
[result setLetter:@""]; | |||
[result setIsSelectable:NO]; | |||
answerIndex--; | |||
[[tiles objectAtIndex:answerIndex] setIsSelectable:YES]; | |||
} | |||
return result; | |||
} | |||
|
|||
- (BOOL) atWordBoundry | |||
{ | |||
BOOL result = false; | |||
|
|||
for (NSNumber *n in wordBoundries) | |||
{ | |||
|
|||
if ([n integerValue] == answerIndex) | |||
{ | |||
result = YES; | |||
break; | |||
} | |||
} | |||
return result; | |||
} | |||
|
|||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,28 +1,32 @@ | |||
#import <UIKit/UIKit.h> | #import <UIKit/UIKit.h> | ||
#import "Tile.h" | #import "Tile.h" | ||
#import "TileGrid.h" | #import "TileGrid.h" | ||
#import "AnswerGrid.h" | |||
|
|
||
@interface GameVC : UIViewController | @interface GameVC : UIViewController | ||
{ | { | ||
UIButton IBOutlet *btDone; | IBOutlet UIButton *btDone; | ||
UIView IBOutlet *bkgH; | IBOutlet UIView *bkgH; | ||
UIView IBOutlet *bkgV; | IBOutlet UIView *bkgV; | ||
TileGrid IBOutlet *tileGrid; | IBOutlet AnswerGrid *answerGrid; | ||
Tile IBOutlet *letter0; | IBOutlet TileGrid *tileGrid; | ||
Tile IBOutlet *letter1; |
|
||
Tile IBOutlet *letter2; | //Tile IBOutlet *letter0; | ||
Tile IBOutlet *letter3; | //Tile IBOutlet *letter1; | ||
//Tile IBOutlet *letter2; | |||
//Tile IBOutlet *letter3; | |||
//NSArray* answerTiles; | |||
//NSArray* answerFrames; | |||
|
|
||
NSArray* answerTiles; | |||
NSArray* answerFrames; | |||
NSMutableArray* answerRefs; | NSMutableArray* answerRefs; | ||
int answerIndex; | //int answerIndex; | ||
int lastSelectedTileIndex; | int lastSelectedTileIndex; | ||
} | } | ||
|
|
||
- (void) tileSelected:(Tile *) t; | - (void) tileSelected:(Tile *) t; | ||
- (void) setOrientation; | - (void) setOrientation; | ||
- (void) testWordComplete; | - (void) testWordComplete; | ||
- (IBAction)onDone:(id)sender; | - (IBAction)onDone:(id)sender; | ||
- (IBAction)onAnswerTileClick:(id)sender; | |||
|
|
||
@end | @end |
Oops, something went wrong.