Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. //GameController.m
  2.  
  3. #import "GameController.h"
  4. #import "config.h"
  5. #import "TileView.h"
  6. #import "TargetView.h"
  7.  
  8. @implementation GameController
  9. {
  10. NSMutableArray* _tiles;
  11. NSMutableArray* _targetWords;
  12. }
  13.  
  14. -(void)drawMainControlsForWord:(NSString*)word
  15. {
  16. int length = [word length];
  17. int tileSide = 30;
  18. int spacing = 5;
  19. int startingPoint = (kScreenWidth - (tileSide * length + spacing * (length - 1))) / 2 + 15;
  20.  
  21. if(self.targets == nil){
  22. self.targets = [[NSMutableArray alloc] init];
  23. }
  24. NSLog(@"%p", self);
  25.  
  26. for (int i = 0; i < length; i++) {
  27. TargetView* target = [[TargetView alloc] initWithLetter:nil andWord:nil andSideLength:tileSide];
  28. target.center = CGPointMake(startingPoint + i * (tileSide + spacing), kScreenHeight - 150);
  29.  
  30. [self.gameView addSubview:target];
  31. [self.targets addObject: target];
  32. }
  33.  
  34. NSLog(@"%i", [_targets count]);
  35.  
  36. tileSide = 40;
  37. spacing = 8;
  38. startingPoint = (kScreenWidth - (tileSide * length + spacing * (length - 1))) / 2 + 20;
  39.  
  40. for (int i = 0; i < length; i++) {
  41. NSString* letter = [word substringWithRange:NSMakeRange(i, 1)];
  42.  
  43. TileView* tile = [[TileView alloc] initWithLetter:letter andSideLength:tileSide];
  44. tile.center = CGPointMake(startingPoint + i * (tileSide + spacing), kScreenHeight - 100);
  45. tile.controller = self;
  46.  
  47. [self.gameView addSubview:tile];
  48. [_tiles addObject: tile];
  49. }
  50.  
  51. }
  52.  
  53. -(void)addPossibleLetter:(NSString *)letter
  54. {
  55. if(self.targets != nil){
  56. NSLog(@"%i", [self.targets count]);
  57. }
  58. for (TargetView* target in self.targets){
  59. if(target.letter != nil){
  60. [target addLetter:letter];
  61. }
  62. }
  63. }
  64.  
  65. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement