camino-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Camino-devel] camino/src/common Board.h Board.cpp


From: Philippe Fremy
Subject: [Camino-devel] camino/src/common Board.h Board.cpp
Date: Sun, 02 Mar 2003 18:30:12 -0500

CVSROOT:        /cvsroot/camino
Module name:    camino
Changes by:     Philippe Fremy <address@hidden> 03/03/02 18:30:12

Modified files:
        src/common     : Board.h Board.cpp 

Log message:
        use constants instead of numbers

Patches:
Index: camino/src/common/Board.cpp
diff -u camino/src/common/Board.cpp:1.5 camino/src/common/Board.cpp:1.6
--- camino/src/common/Board.cpp:1.5     Tue Feb 18 17:15:12 2003
+++ camino/src/common/Board.cpp Sun Mar  2 18:30:12 2003
@@ -2,7 +2,7 @@
 **
 ** Camino
 **
-** Version : $Id: Board.cpp,v 1.5 2003/02/18 22:15:12 Audoux Exp $
+** Version : $Id: Board.cpp,v 1.6 2003/03/02 23:30:12 pfremy Exp $
 **
 ** Author(s) : Philippe Fremy, Pascal Audoux
 ** Creation : 16/01/2003
@@ -44,8 +44,8 @@
 
 void Board::clear()
 {
-       for( uint i = 0; i < 10; i++ ) {
-               for( uint j = 0; j < 14; j++ ) {
+       for( uint i = 0; i < nbHorTiles; i++ ) {
+               for( uint j = 0; j < nbVerTiles; j++ ) {
                        delete _tiles[i][j];
                        _tiles[i][j] = 0;
                }
@@ -54,8 +54,8 @@
 
 void Board::init()
 {
-       for( uint i = 0; i < 10; i++ ) {
-               for( uint j = 0; j < 14; j++ ) {
+       for( uint i = 0; i < nbHorTiles; i++ ) {
+               for( uint j = 0; j < nbVerTiles; j++ ) {
                        Tile * tile = new Tile();
                        tile->setPosition( i, j );
                        _tiles[i][j] = tile;
@@ -73,7 +73,8 @@
 {
        Tile * ret = 0;
 
-       if( ( row >= 0 ) && ( col >= 0 ) && ( row < 10 ) && ( col < 14 ) ) {
+       if( ( row >= 0 ) && ( col >= 0 ) && 
+               ( row < nbHorTiles ) && ( col < nbVerTiles ) ) {
                ret = _tiles[row][col];
        }
 
@@ -99,7 +100,8 @@
 {
        bool ret = true;
 
-       if( ( row >= 0 ) && ( col >= 0 ) && ( row < 10 ) && ( col < 14 ) ) {
+       if( ( row >= 0 ) && ( col >= 0 ) 
+               && ( row < nbHorTiles ) && ( col < nbVerTiles ) ) {
                ret = hasNeighbour( row, col );
        } else {
                ret = false;
@@ -117,22 +119,22 @@
                        ret = ret || ( _tiles[row-1][col-1]->getType() != 
Tile::TILE_UNKNOWN );
                }
                ret = ret || ( _tiles[row-1][col]->getType() != 
Tile::TILE_UNKNOWN );
-               if( col < 13 ) {
+               if( col < nbVerTiles-1 ) {
                        ret = ret || ( _tiles[row-1][col+1]->getType() != 
Tile::TILE_UNKNOWN );
                }
        }
        if( col > 0 ) {
                ret = ret || ( _tiles[row][col-1]->getType() != 
Tile::TILE_UNKNOWN );
        }
-       if( col < 13 ) {
+       if( col < nbVerTiles-1 ) {
                ret = ret || ( _tiles[row][col+1]->getType() != 
Tile::TILE_UNKNOWN );
        }
-       if( row < 9 ) {
+       if( row < nbHorTiles-1 ) {
                if( col > 0 ) {
                        ret = ret || ( _tiles[row+1][col-1]->getType() != 
Tile::TILE_UNKNOWN );
                }
                ret = ret || ( _tiles[row+1][col]->getType() != 
Tile::TILE_UNKNOWN );
-               if( col < 13 ) {
+               if( col < nbVerTiles-1 ) {
                        ret = ret || ( _tiles[row+1][col+1]->getType() != 
Tile::TILE_UNKNOWN );
                }
        }
Index: camino/src/common/Board.h
diff -u camino/src/common/Board.h:1.4 camino/src/common/Board.h:1.5
--- camino/src/common/Board.h:1.4       Tue Feb 18 17:15:12 2003
+++ camino/src/common/Board.h   Sun Mar  2 18:30:12 2003
@@ -5,7 +5,7 @@
 ** Board.h
 ** Handles the game's board
 **
-** Version : $Id: Board.h,v 1.4 2003/02/18 22:15:12 Audoux Exp $
+** Version : $Id: Board.h,v 1.5 2003/03/02 23:30:12 pfremy Exp $
 ** Author(s) : Philippe Fremy, Pascal Audoux
 ** Creation : 16/01/2003
 ** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -32,6 +32,9 @@
 // include files for QT
 #include <qptrstack.h>
 // application specific include files
+#include "common/const.h"
+
+using namespace Camino;
 
 class Tile;
 
@@ -72,7 +75,7 @@
 protected:
        bool hasNeighbour( int row, int col );
 
-       Tile * _tiles[10][14];
+       Tile * _tiles[ nbHorTiles ][ nbVerTiles ];
        QPtrStack<Tile> _moves;
 };
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]