Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //GameController.m
- #import "GameController.h"
- #import "config.h"
- #import "TileView.h"
- #import "TargetView.h"
- @implementation GameController
- {
- NSMutableArray* _tiles;
- NSMutableArray* _targetWords;
- }
- -(void)drawMainControlsForWord:(NSString*)word
- {
- int length = [word length];
- int tileSide = 30;
- int spacing = 5;
- int startingPoint = (kScreenWidth - (tileSide * length + spacing * (length - 1))) / 2 + 15;
- if(self.targets == nil){
- self.targets = [[NSMutableArray alloc] init];
- }
- NSLog(@"%p", self);
- for (int i = 0; i < length; i++) {
- TargetView* target = [[TargetView alloc] initWithLetter:nil andWord:nil andSideLength:tileSide];
- target.center = CGPointMake(startingPoint + i * (tileSide + spacing), kScreenHeight - 150);
- [self.gameView addSubview:target];
- [self.targets addObject: target];
- }
- NSLog(@"%i", [_targets count]);
- tileSide = 40;
- spacing = 8;
- startingPoint = (kScreenWidth - (tileSide * length + spacing * (length - 1))) / 2 + 20;
- for (int i = 0; i < length; i++) {
- NSString* letter = [word substringWithRange:NSMakeRange(i, 1)];
- TileView* tile = [[TileView alloc] initWithLetter:letter andSideLength:tileSide];
- tile.center = CGPointMake(startingPoint + i * (tileSide + spacing), kScreenHeight - 100);
- tile.controller = self;
- [self.gameView addSubview:tile];
- [_tiles addObject: tile];
- }
- }
- -(void)addPossibleLetter:(NSString *)letter
- {
- if(self.targets != nil){
- NSLog(@"%i", [self.targets count]);
- }
- for (TargetView* target in self.targets){
- if(target.letter != nil){
- [target addLetter:letter];
- }
- }
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement