next queue lezgo
This commit is contained in:
@@ -27,6 +27,12 @@ GamePlayingAppMenu::GamePlayingAppMenu(std::shared_ptr<MenuStack> menuStack, std
|
||||
this->boardPosition = sf::Rect<float>(sf::Vector2f((this->settings->getWindowSizeMultiplier() * 40) - (boardWidth / 2),
|
||||
(this->settings->getWindowSizeMultiplier() * 25) - (boardHeight / 2)),
|
||||
sf::Vector2f(boardWidth, boardHeight));
|
||||
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
this->nextQueuePosition[i] = sf::Rect<float>(sf::Vector2f(this->boardPosition.position.x + boardWidth + (5.f * this->settings->getWindowSizeMultiplier()), (1.f + (10.f * i)) * this->settings->getWindowSizeMultiplier()),
|
||||
sf::Vector2f(8 * this->settings->getWindowSizeMultiplier(), 8 * this->settings->getWindowSizeMultiplier()));
|
||||
}
|
||||
}
|
||||
|
||||
void GamePlayingAppMenu::computeFrame() {
|
||||
@@ -85,7 +91,7 @@ void GamePlayingAppMenu::drawFrame() const {
|
||||
|
||||
sf::RectangleShape cell(cellSize);
|
||||
cell.setFillColor(this->getColorOfBlock(block, (block == NOTHING) ? 0 : -30));
|
||||
cell.setPosition(this->getBlockPosition(x, y));
|
||||
cell.setPosition(this->getBoardBlockPosition(x, y));
|
||||
this->renderWindow->draw(cell);
|
||||
}
|
||||
}
|
||||
@@ -98,7 +104,7 @@ void GamePlayingAppMenu::drawFrame() const {
|
||||
|
||||
sf::RectangleShape cell(cellSize);
|
||||
cell.setFillColor(ghostColor);
|
||||
cell.setPosition(this->getBlockPosition(cellPosition.x, cellPosition.y));
|
||||
cell.setPosition(this->getBoardBlockPosition(cellPosition.x, cellPosition.y));
|
||||
this->renderWindow->draw(cell);
|
||||
}
|
||||
|
||||
@@ -111,14 +117,14 @@ void GamePlayingAppMenu::drawFrame() const {
|
||||
sf::RectangleShape cell(cellSize);
|
||||
cell.setOutlineThickness(pieceOutlineSize);
|
||||
cell.setOutlineColor(pieceOultlineColor);
|
||||
cell.setPosition(this->getBlockPosition(cellPosition.x, cellPosition.y));
|
||||
cell.setPosition(this->getBoardBlockPosition(cellPosition.x, cellPosition.y));
|
||||
this->renderWindow->draw(cell);
|
||||
}
|
||||
}
|
||||
|
||||
// top out line
|
||||
sf::RectangleShape topOutLine(sf::Vector2f(this->cellSizeZoom * this->game.getBoard().getWidth(), std::roundf(this->cellSizeZoom / 4)));
|
||||
topOutLine.setPosition(this->getBlockPosition(0, this->game.getBoard().getBaseHeight() - 1));
|
||||
topOutLine.setPosition(this->getBoardBlockPosition(0, this->game.getBoard().getBaseHeight() - 1));
|
||||
topOutLine.setFillColor(sf::Color(255, 0, 0));
|
||||
this->renderWindow->draw(topOutLine);
|
||||
|
||||
@@ -131,11 +137,33 @@ void GamePlayingAppMenu::drawFrame() const {
|
||||
|
||||
sf::RectangleShape cell(cellSize);
|
||||
cell.setFillColor(pieceColor);
|
||||
cell.setPosition(this->getBlockPosition(cellPosition.x, cellPosition.y));
|
||||
cell.setPosition(this->getBoardBlockPosition(cellPosition.x, cellPosition.y));
|
||||
this->renderWindow->draw(cell);
|
||||
}
|
||||
}
|
||||
|
||||
// next queue
|
||||
for (int i = 0; i < std::min((int) this->game.getNextPieces().size(), 5); i++) {
|
||||
float nextCellZoom = 2 * this->settings->getWindowSizeMultiplier();
|
||||
for (int s = this->game.getNextPieces().at(i).getLength(); s > 4; s /= 2) {
|
||||
nextCellZoom /= 2;
|
||||
}
|
||||
sf::Vector2f nextCellSize(nextCellZoom, nextCellZoom);
|
||||
sf::Color color = this->getColorOfBlock(this->game.getNextPieces().at(i).getBlockType(), 0);
|
||||
|
||||
for (int y = this->game.getNextPieces().at(i).getLength() - 1; y >= 0; y--) {
|
||||
for (int x = 0; x < this->game.getNextPieces().at(i).getLength(); x++) {
|
||||
if (this->game.getNextPieces().at(i).getPositions().contains(Position{x, y})) {
|
||||
sf::RectangleShape cell(nextCellSize);
|
||||
cell.setFillColor(color);
|
||||
cell.setPosition(sf::Vector2f(this->nextQueuePosition[i].position.x + (x * nextCellZoom),
|
||||
this->nextQueuePosition[i].position.y + ((this->game.getNextPieces().size() - y - 1) * nextCellZoom)));
|
||||
this->renderWindow->draw(cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->renderWindow->display();
|
||||
}
|
||||
|
||||
@@ -146,7 +174,7 @@ sf::Color GamePlayingAppMenu::getColorOfBlock(Block block, int luminosityShift)
|
||||
std::clamp(rgbColor.blue + luminosityShift, 0, 255));
|
||||
}
|
||||
|
||||
sf::Vector2f GamePlayingAppMenu::getBlockPosition(int x, int y) const {
|
||||
sf::Vector2f GamePlayingAppMenu::getBoardBlockPosition(int x, int y) const {
|
||||
return sf::Vector2f(this->boardPosition.position.x + (x * this->cellSizeZoom),
|
||||
this->boardPosition.position.y + ((this->game.getBoard().getBaseHeight() + 9 - y) * this->cellSizeZoom));
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ class GamePlayingAppMenu : public AppMenu {
|
||||
bool retryPressed;
|
||||
float cellSizeZoom;
|
||||
sf::Rect<float> boardPosition;
|
||||
sf::Rect<float> nextQueuePosition[5];
|
||||
|
||||
public:
|
||||
GamePlayingAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow);
|
||||
@@ -25,5 +26,5 @@ class GamePlayingAppMenu : public AppMenu {
|
||||
|
||||
sf::Color getColorOfBlock(Block block, int luminosityShift) const;
|
||||
|
||||
sf::Vector2f getBlockPosition(int x, int y) const;
|
||||
sf::Vector2f getBoardBlockPosition(int x, int y) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user