From 15c3fe76044b02e6b2dcd0307f960656577ba451 Mon Sep 17 00:00:00 2001 From: Sheldon Lee Date: Sun, 2 Apr 2023 00:41:16 +0100 Subject: [PATCH] Update level drawing --- level.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/level.cpp b/level.cpp index d85aa07..9ab3d2e 100644 --- a/level.cpp +++ b/level.cpp @@ -41,23 +41,22 @@ void level_end() static void drawGrid() { const sf::Vector2u windowSize = window->getSize(); - unsigned int padding = 5; unsigned int stepX = windowSize.x/WIDTH; unsigned int stepY = windowSize.y/HEIGHT; - drawGridLine(stepX, true); - drawGridLine(stepY, false); - for (unsigned int x = 0; x < WIDTH; x++) { for (unsigned int y = 0; y < HEIGHT; y++) { if (!level[y * HEIGHT + x]) continue; - sf::RectangleShape rectangle(sf::Vector2f(stepY - padding*2, stepY - padding*2)); - rectangle.setPosition(x * stepX + padding, y * stepY + padding); + sf::RectangleShape rectangle(sf::Vector2f(stepY, stepY)); + rectangle.setPosition(x * stepX, y * stepY); window->draw(rectangle); } } + + drawGridLine(stepX, true); + drawGridLine(stepY, false); } static void drawGridLine(unsigned int step, bool isHorizontal) @@ -92,5 +91,7 @@ static sf::Vertex getGridLineVertex(unsigned int offset, unsigned int maxDimensi end = sf::Vertex(sf::Vector2f(maxDimension, offset)); } + start.color = sf::Color(100, 100, 100); + end.color = sf::Color(100, 100, 100); return isStart? start : end; }