| 272 | } |
| 273 | |
| 274 | void ShuffleTiles::startWithTarget(Node* target) |
| 275 | { |
| 276 | TiledGrid3DAction::startWithTarget(target); |
| 277 | |
| 278 | if (_seed != (unsigned int)-1) |
| 279 | { |
| 280 | std::srand(_seed); |
| 281 | } |
| 282 | |
| 283 | _tilesCount = (unsigned int)(_gridSize.width * _gridSize.height); |
| 284 | _tilesOrder = new unsigned int[_tilesCount]; |
| 285 | |
| 286 | /** |
| 287 | * Use k to loop. Because _tilesCount is unsigned int, |
| 288 | * and i is used later for int. |
| 289 | */ |
| 290 | for (unsigned int k = 0; k < _tilesCount; ++k) |
| 291 | { |
| 292 | _tilesOrder[k] = k; |
| 293 | } |
| 294 | |
| 295 | shuffle(_tilesOrder, _tilesCount); |
| 296 | |
| 297 | _tiles = (struct Tile*)new Tile[_tilesCount]; |
| 298 | Tile* tileArray = (Tile*)_tiles; |
| 299 | |
| 300 | for (int i = 0; i < _gridSize.width; ++i) |
| 301 | { |
| 302 | for (int j = 0; j < _gridSize.height; ++j) |
| 303 | { |
| 304 | tileArray->position.set((float)i, (float)j); |
| 305 | tileArray->startPosition.set((float)i, (float)j); |
| 306 | tileArray->delta = getDelta(Vec2((float)i, (float)j)); |
| 307 | ++tileArray; |
| 308 | } |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | void ShuffleTiles::update(float time) |
| 313 | { |
nothing calls this directly
no test coverage detected