void GameEngineMap::draw() { LoaderParameters* tile = nullptr; int startX = map->getCharacterPosition().x - 10; int startY = map->getCharacterPosition().y - 7; for (int i = 0; i < 15; i++) { for (int j = 0; j < 21; j++) { tile = new LoaderParameters(16 + j*32 , 16 + i*32 , CELL_SIZE, CELL_SIZE, 0, 0, "tile_empty"); if ((startX > -1 && startX < map->getWidth() && startY > -1 && startY < map->getHeight())) { //drawTile(tile); switch (map->getType(Position(startX, startY))) { case EMPTY: tile->setId("tile_empty"); drawTile(tile); break; case GRASS: tile->setId("tile_grass"); drawTile(tile); break; case DARKGRASS: tile->setId("tile_darkgrass"); drawTile(tile); break; case STONEWALL: tile->setId("tile_stonewall"); drawTile(tile); break; } // start or end if (map->getEndPosition().x == startX && map->getEndPosition().y == startY) { tile->setId("misc_end"); drawTile(tile); } else if (map->getBeginPosition().x == startX && map->getBeginPosition().y == startY) { tile->setId("misc_start"); drawTile(tile); } // draw character if (i == 7 && j == 10) { tile->setId("char_default"); drawTile(tile); } } startX++; } startY++; startX = map->getCharacterPosition().x - 10; } delete tile; }
void MapView::draw() { LoaderParameters* tile = nullptr; for (int i = 0; i < map->getBreadth(); i++) { for (int j = 0; j < map->getWidth(); j++) { tile = new LoaderParameters(parameters->getXPos() + (j * CELL_SIZE), parameters->getYPos() + (i * CELL_SIZE), CELL_SIZE, CELL_SIZE, 0, 0, "emptyTile"); drawTile(tile); if (map->getEndPosition().x == j && map->getEndPosition().y == i) { tile->setId("endTile"); drawTile(tile); } if (map->getBeginPosition().x == j && map->getBeginPosition().y == i) { tile->setId("beginTile"); drawTile(tile); } switch (map->getCellState(Position(j, i))) { case CHARACTER: tile->setId("characterTile"); drawTile(tile); break; case CHEST: tile->setId("chestTile"); drawTile(tile); break; case OPPONENT: tile->setId("opponentTile"); drawTile(tile); break; case WALL: tile->setId("wallTile"); drawTile(tile); break; } } } delete tile; }