From 42c84143784cac825a8cbe8bab3e67fdc20b9d02 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Sat, 5 Mar 2022 11:37:49 -0800 Subject: [PATCH] Switch from lists to vectors, clean up includes --- src/Main.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/Main.cpp b/src/Main.cpp index 8596311..879fe3c 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1,19 +1,16 @@ + +#include +#include +#include +#include #include + #define WINDOW_WIDTH 400 #define WINDOW_HEIGHT 400 #define GRID_WIDTH 20 #define GRID_HEIGHT 20 -#include -#include -#include -#include -#include -#include -#include -#include - class TileType { public: static TileType white, red, green, blue, yellow, magenta, cyan; @@ -39,8 +36,8 @@ class BlockType { return list[rand() % 7]; } TileType* tile_type; - std::array, 2> grid; - BlockType(TileType* _tile_type, const std::array, 2>& _grid) { + std::vector> grid; + BlockType(TileType* _tile_type, const std::vector> _grid) { tile_type = _tile_type; grid = _grid; } @@ -73,8 +70,8 @@ class Block { position = sf::Vector2i(GRID_WIDTH / 2 - 2, 0); rotation_state = 0; } - std::list get_tiles() { - std::listlist = {}; + std::vector get_tiles() { + std::vectortiles = {}; for (int y = 0; y < 2; y++) { for (int x = 0; x < 4; x++) { if (!type->grid[y][x]) { @@ -97,10 +94,10 @@ class Block { } int global_x = rotated_x + position.x; int global_y = rotated_y + position.y; - list.push_front(sf::Vector2i(global_x, global_y)); + tiles.push_back(sf::Vector2i(global_x, global_y)); } } - return list; + return tiles; } };