Source/TicTacToeGame.m
changeset 1 3eb7be1dd7b6
parent 0 e9f7ba4718e1
child 3 40d225cf9c43
     1.1 --- a/Source/TicTacToeGame.m	Fri Mar 07 11:43:02 2008 -0800
     1.2 +++ b/Source/TicTacToeGame.m	Mon Mar 10 17:30:57 2008 -0700
     1.3 @@ -29,16 +29,24 @@
     1.4  
     1.5  @implementation TicTacToeGame
     1.6  
     1.7 -- (void) x_createDispenser: (NSString*)imageName forPlayer: (int)playerNumber x: (int)x
     1.8 +- (void) x_createDispenser: (NSString*)imageName forPlayer: (int)playerNumber
     1.9  {
    1.10      Piece *p = [[Piece alloc] initWithImageNamed: imageName scale: 80];
    1.11      p.owner = [self.players objectAtIndex: playerNumber];
    1.12 +    CGFloat x = floor(CGRectGetMidX(_board.bounds));
    1.13 +#if TARGET_OS_ASPEN
    1.14 +    x = x - 80 + 160*playerNumber;
    1.15 +    CGFloat y = 360;
    1.16 +#else
    1.17 +    x += (playerNumber==0 ?-230 :230);
    1.18 +    CGFloat y = 175;
    1.19 +#endif
    1.20      _dispenser[playerNumber] = [[Dispenser alloc] initWithPrototype: p quantity: 0
    1.21 -                                                        frame: CGRectMake(x,16, 120,120)];
    1.22 +                                                        frame: CGRectMake(x-45,y-45, 90,90)];
    1.23      [_board addSublayer: _dispenser[playerNumber]];
    1.24  }
    1.25  
    1.26 -- (id) initWithBoard: (CALayer*)board
    1.27 +- (id) initWithBoard: (GGBLayer*)board
    1.28  {
    1.29      self = [super initWithBoard: board];
    1.30      if (self != nil) {
    1.31 @@ -46,18 +54,16 @@
    1.32          
    1.33          // Create a 3x3 grid:
    1.34          CGFloat center = floor(CGRectGetMidX(board.bounds));
    1.35 -        _grid = [[RectGrid alloc] initWithRows: 3 columns: 3 frame: CGRectMake(center-150,16, 300,300)];
    1.36 +        _grid = [[RectGrid alloc] initWithRows: 3 columns: 3 frame: CGRectMake(center-150,0, 300,300)];
    1.37          [_grid addAllCells];
    1.38          _grid.allowsMoves = _grid.allowsCaptures = NO;
    1.39 -        _grid.cellColor = CGColorCreateGenericGray(1.0, 0.25);
    1.40 +        _grid.cellColor = CreateGray(1.0, 0.25);
    1.41          _grid.lineColor = kTranslucentLightGrayColor;
    1.42          [board addSublayer: _grid];
    1.43          
    1.44          // Create piece dispensers for the two players:
    1.45 -        [self x_createDispenser: @"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarUtilitiesFolderIcon.icns"
    1.46 -                     forPlayer: 0 x: center-290];
    1.47 -        [self x_createDispenser: @"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ToolbarAdvanced.icns"
    1.48 -                     forPlayer: 1 x: center+170];
    1.49 +        [self x_createDispenser: @"X.tiff" forPlayer: 0];
    1.50 +        [self x_createDispenser: @"O.tiff" forPlayer: 1];
    1.51          
    1.52          // And they're off!
    1.53          [self nextPlayer];