| 1 | // This file is part of Dust Racing 2D. |
| 2 | // Copyright (C) 2011 Jussi Lind <[email protected]> |
| 3 | // |
| 4 | // Dust Racing 2D is free software: you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation, either version 3 of the License, or |
| 7 | // (at your option) any later version. |
| 8 | // Dust Racing 2D is distributed in the hope that it will be useful, |
| 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | // GNU General Public License for more details. |
| 12 | // |
| 13 | // You should have received a copy of the GNU General Public License |
| 14 | // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>. |
| 15 | |
| 16 | #include "map.hpp" |
| 17 | #include "tracktile.hpp" |
| 18 | |
| 19 | #include <QPoint> |
| 20 | #include <QPointF> |
| 21 | |
| 22 | Map::Map(size_t cols, size_t rows) |
| 23 | : MapBase(cols, rows) |
| 24 | { |
| 25 | // Create tiles and set coordinates. |
| 26 | for (size_t i = 0; i < cols; i++) |
| 27 | { |
| 28 | for (size_t j = 0; j < rows; j++) |
| 29 | { |
| 30 | const auto newTile = std::make_shared<TrackTile>( |
| 31 | QPointF(TrackTile::width() / 2 + i * TrackTile::width(), |
| 32 | TrackTile::height() / 2 + j * TrackTile::height()), |
| 33 | QPoint(static_cast<int>(i), static_cast<int>(j))); |
| 34 | setTile(i, j, newTile); |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | Map::~Map() = default; |