From 1d6a0914d5fc5e3b451d039b53af2f338d438ed9 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Fri, 4 Mar 2022 12:23:51 -0800 Subject: [PATCH] Make blocks fall in center --- src/Main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Main.cpp b/src/Main.cpp index 23cd57b..fa2a412 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -49,11 +49,12 @@ int main() BlockType z(&cyan, {{{{1, 1, 0, 0}}, {{0, 1, 1, 0}}}}); BlockType block_types[] = {i, j, l, o, s, t, z}; - auto current_block = &block_types[rand() % 7];; - auto current_block_position = sf::Vector2i(0, 0); - #define GRID_WIDTH 20 #define GRID_HEIGHT 20 + + auto current_block = &block_types[rand() % 7];; + auto current_block_position = sf::Vector2i(GRID_WIDTH / 2 - 2, 0); + TileType* grid[GRID_HEIGHT][GRID_WIDTH] = { nullptr }; int shape_width = WINDOW_WIDTH / GRID_WIDTH; @@ -107,7 +108,7 @@ int main() } landed = false; current_block = &block_types[rand() % 7]; - current_block_position = sf::Vector2i(0, 0); + current_block_position = sf::Vector2i(GRID_WIDTH / 2 - 2, 0); } else { current_block_position.y++; }