diff --git a/C++ProjectTemplate b/C++ProjectTemplate deleted file mode 100755 index c1aa29d..0000000 Binary files a/C++ProjectTemplate and /dev/null differ diff --git a/input b/input new file mode 100644 index 0000000..d9d1367 --- /dev/null +++ b/input @@ -0,0 +1 @@ +>>><><<>>><<><<>>>><<<<>>><<<<><>>><>>>><<>>>><<<>>>><<>>><>>><<>>><>>><>>>><<>>>><<<>><>>><<<><<><>><<><>><<>>>><<>>><>>>><<<<>><<<>><<>>><<>><<<>>>><>>>><<<<><<<<>>><<<<>>><<<><<<>><<<<>>>><<<<>>><<<<>><>>><<<<>>><><<<>>>><><<<<>>><<<>><<<<>><<<>>>><<>><<<<>>>><<<><<>>><<>>>><>>><<>>><<>>><>>>><<<>>><<>>><<>>><>>>><<<<><<><<<><<><<<>>><<<>>>><>><<<>>><<<>><<<><<<<>>>><<<<>>><<<>><>>><>>>><<<>>>><>>>><<<<>>>><<<<><<<<><<<<>>><>>>><<<>><<<<>>><<<><<<>>>><<>>>><<<<>>><<<>><<<<><<<><<>>>><<<>>><>>><><<<>>><>><<<>><<>><<<>><<<>>>><<<<><<<<>>>><<>>><><<<>><<>><<>>>><<<><>><<<>><<<<>>>><<>><<<><<<<>><<>>><<<>><<><<<<>>>><<<<><<<<><<<><<<><<<<>><<<>><<<<>>>><><>>>><<<<><>><<>>><<>><>>><<>><<>>>><>><<<><>>><<<<>>><<>>><>><>>><<>><<<><<<<>>>><>>>><>>><<<>>><<<<>>><<<<>>><<<>>>><<<>><<<><>>>><<<<>><<<<><<<>>><<>>>><<><><<<><<<>><<<>>>><<<><<<<>>>><<<<>>>><><>>><>>>><<><<><<>><<><<<><<<<>>><>>>><<>>><>>>><<<>>>><<>>>><<<>><<<<><<><<<>>>><<<<>><<<>>>><>>><><<<<>>><<<><<>><<>>>><<>>>><>><<<>>>><>><<<<>>><<<>><>>>><<>><><<>>><<>><<>><<<><>>><<<>>>><>>>><<><<<<><<<<>>>><<<<>><<<>><<<>><<<>><<><<<<>>><<>>>><><>><<<<>>>><<>>>><>>>><<>>><<<<>><<><<<><<<<><<><<<<><<>>>><<<<>>>><>>>><<>>><<><<><>>>><>><<<<>><<>>>><<>>>><<<<>>>><<<<>><<<<>>>><<<>>><<>>><<><<<<>><>><<<>>><<<>>><>>>><>><>>>><<<<>><<<>>>><<>>><>><<<<>>><>><<<>>><<><<><<<<>>><<<<>>><<<<>>><<>><<>>><<>><<>><><<<<><<<>><><<<<>>>><<<><<<<>>>><<<>>><>><<<><<<>>><<<<>>><<<<>>><<>>><<<>>>><<<>>><<><<<>>><<>>><<>>><<>>>><<<>>><>><<>><<<>>><<<<>>>><>><<><<>>><<<>>><<<>><<<<>>>><<<<><<>>><<<>>><<>>>><<<>>>><>><<<<>>>><>>><<<<><<<>>>><>>><<>>><<><<>><<<><<<>>>><>>>><>>>><<<<>>><<<>>><<<>>>><<>>>><>><<<><>><<<>><<<>>>><<<>>><>>>><<<<><<<<>><>>>><<><<<>>><<><<<>>>><<<<>>>><<<<>>><<<<><>>>><<><>>><<>>><<>>><>><<<>><<<<>><<<<>><<>>><<><<>><<<>><<><<><>>><<<<><<<<>>>><>><<>>><<><<<<>>>><<<>><<<>>>><<<<>>><<<<>>><>>><<>><<<<>>>><<<>>><<><<<<>>>><<<<>>>><><<<>>><<<><<<>>><<<<><<<>>><<<>><<><>>>><><<>><<><<><<<>><>>>><>>>><>>>><<<<>>>><<>><<<><<<<><<>><><<<>><<<<>><<<<>>><<<>>>><<<<>><<<<>>>><<<<><>><<>>><<<<><>>>><<>>>><<<<>><>>>><><<<>><>>><<><><><<<>>>><<<>>><<><<<<>>>><>><<>>>><>>>><<<<>>>><<<<>>>><<<>>>><<<>><>><<<<><<<<>>>><>><<<><<>><<>>>><>><<><<<>>><<<><>>>><<>><<<<>>>><<<><<<><<<<>>><<>>>><>><<<<>>><<<>>><<<<><>>><>>><>>><>>><<>><<<>><<<>>><<<>><><<<<>><<<<><<>><>><<<>><<><>>><><<>>><<<<>>>><<<<>>>><>><<>>>><<<<>>><<>>>><<<<>>><<<<>>>><<>>>><><>><><<>><<<<>><>><<<<>>><>>><<<>>><<<<>>>><<>><<<>><<<<>>><<<<>>><<<<>>><<<<><<><><>>>><<<>>>><<<<>><<>>>><>><<><<<<><<<>><<<<><<>>><<<>>><><<<<>><<>>>><<<>><<<>>><<<>>><<<<><>>>><<<><<<><<<<>>><<<<><>>><>>><<>>>><<<>>>><<><<><<>><<>><<><>>><<<>>><<><<><<<<>><<<<>><<<>>>><>>>><<<<>>><>>><<<<>><<><<>>>><<<<>>>><>><>>><<<<>>><<<><<>><<><<>><>>><>><<>>><<<<>>>><<<>><<<>>><<>>>><<>><<<<>>>><<<>>>><<>><<<>>><<<><<<>><<<<>>>><<<>><<<<><<<<>>>><><>>><<><<>>><><<>>>><<<>>><<>>>><<<<><>>><<<<>>>><<<<>>>><>>><<>><<<>>>><<>>><<<><>>><<>>><<>>><<>>>><>>>><<>><>><<>>><<<>>>><<<>>><<<>><<<<><<<>>>><<>>><<<<><<<>>><><<<<><<>>><<<<>>><<>>><><<<<>>><>>>><>>>><<>>><<<>>>><>>>><<<>>><<<><<<><<<<><<>>>><<<<>><<>>>><<<>>><><<><<<<><<<><<<>><<<<>>>><<>><<>><<<>><<>><<<>>><<<<>><<<<>><<<>><<<<>>>><<>>>><><<<<>><>>>><<>>>><<<><<><>><<<>>>><<<>>><<><>>>><<<<><<<><<<<>>>><<>><<<<><<<<>>>><<>>>><<>>><<><>>>><><<<>>><<>><>><<<<>>>><<<>>>><<<>>><<<<>>><<<<>>>><<<>><<<<><<<<>>><>><<<>><<><<>><><<<>>>><>>>><<><<<<>>>><<<><<<<>>><<><>>>><>>><><<<<>>><><<<>>><<>>>><>>>><>>>><<<<><<>><>><<<><<<<><<>><>>>><>><<<>>><>>><<>>><<>><<<>>>><<<<>>>><<<>><<>><<>><>>>><<<<>><<>><<>><<<>><<>><<>>>><>>>><<>><<<<>>><<<<><<<>>><<><>>>><<<>><<<>>>><<<>><><>>><<<>><><>>>><<>><<<>>>><><>>><<>>><>>>><>>><<<>><<>>>><<>>>><<><<<>>><<><<<<>><<>><>>>><><<<>>>><<<<>><<<>><<<<>><<>><><<<<>>>><<><<<>><><<<<>>>><>>>><<<<>><>>><<<<>>>><>>>><>>>><><<<>><<<>>>><<<><<<>>><<<<>>>><<>>><<><<<<>>>><<<>><<<<><<<>>><<<>><<>>><<>><<>><<>>>><<<>><<>>><<<<>><>><<<>><<<<>>>><<<>>><>><<>>>><<<<>>>><<<><<>>><<>>><<<><<<<><<>>><<<<><<>>>><<<>>><<<>>>><<>>><<<>>><<>>><<<>><<<<>>>><><<<>>><>>>><<>><<<<>>>><<<>>>><>><<<>><<<><<><<<<>><<<<>>><<<<><<<<>>><<<<><<>><<>>><<<>><<<<>>><<<>><>>><<<<>><<<<><<><>>><<<<><<<>>>><<<<>><<<<>>>><<>>>><<>>>><<><<>>>><<<>>><<<<>><<>>>><<<<><<>>><<>><<><>>>><<>>>><<<>><<<>>><<><><<<<><<>>>><>>>><<<>>><><<<<>>>><<>>>><<<<><>><<>>>><>>>><<<<>>><>><<>><<<>>><<<><<<<>>>><<<<><<<>>>><<><>>><<<>>>><<><>>>><<<>><<>>>><<<<>><<<><<>>>><<>>><>>><>>>><<>>>><<<><>>>><<>>><<<<>>>><<>>><<<<>><<<<><>>><<>><>>><<><<<>><>>><<<<>><<>>><<><<<>><<<>>><<<<>>>><<>>><>><<><>>>><><><>>>><<>>>><<<>><<<<>>>><<>>>><<>>>><>>>><<>>>><<<<>><<>>>><<>><<<<>>><<<><>>>><<<>>><<<>><><>>>><>><<<<>>>><<><>>><<>>>><<>>>><<<>><<<>><><>><<>>>><<<>><<<>>><<>><<<<>>><<<<>>><>>>><<<><>><<<>><<><>>>><<<<>>><>>>><>>>><>>><>><>>><<<<>>>><>>>><>><<<<>><<<>><<<>>><>>><>>><<<><<<><<<<>>><<<<><<>><><>>><>>>><>>><><>>>><><<<><>>><<<<>>>><<>>>><><>>>><<>>>><>>>><<<>>><<><>><>>><>>><<<<><<<<>>><<<<><<<>>>><<<>><<>>><<<<>>><<><<<<>>>><>><<<<><><><<<><>>><<<>>>><<<>>><<<<>><<>>><<>><<<<>><>>>><<<><<>>><<>>>><>>><<<>>><<<>>>><<<<>>>><>>><<<><>>>><<<>>>><<>><<<>>><>>>><<<>>><<<><<<><<<<>><<<>>><<<>>><<<<>>>><<<<>>>><<<<>>>><<<<>><<<>><<>><<>>>><<><<>>>><><<<>><><<<><>>><<<<>>>><<>>><<>>>><<<<><>>><><<<>><<<><<>>>><<<>>><<<<>>>><<<<>>>><<<>>>><<<>><<<>>>><>><<<>>><<<>>>><<>>>><<<>>><<<<>>>><>><><<<<>>><<<>><<>><<>>>><<>><><<<<>>><<<>>>><><<>>>><<<>><<><<>><>>>><<<<>>><<<<><<>>>><<<>>><<<<>>>><>>><><<<>>><<<<>>>><<<>><<<<>>>><>>>><<<>>>><>>><<<<>>>><<>>>><><>><>><<<>><<>>>><<<>>><<>>>><<<><<<<>><<<<>><<<<>>>><<<><>><<<>>>><<>>><<<<>>><>>>><<<<>><>>><>>><<<>>>><<>>>><<<<><><<<>><><<><><><<<><<><<<<><<<<>>>><<<>>>><<<>>>><<<<><<>>>><<<><<>>>><<<>><<<<><<<>>><>>><>>><<<<>>><><<>><>>><<<<>>>><<>>><<<>>><<<>><<<<>>>><>><<>>>><<<>>>><<<><><<<>><<<>><<>><>>>><<>><<<>>>><<>>><<<>>><<><>><<>><>>><<>>><><<<>>>><<>>>><<>><>><>>><<<<><<<<>>><<<>>>><>>>><<<<>><>><<<>>>><<<<><<<<>><<>>>><<<<><<<<>>><<<><<>>><<><>><>>>><>>><<<<>>>><<>><>>>><<<>>><>>>><>>>><<<>><<>>><<<<>><<<<>>><>>><<<<>>>><>><<<<>>>><<<<>>><<<>><<>>><<<<>>>><>>><>><<>>><<<>>><><>><<<>><><>><<<><<<>><<<>>><<>>><<<>><<><<<<>>>><<<<>>><<<>><<>><<<<>><<<>>>><>>><<<>>><<<<>>><><<>><>><>><<<>>><<<<>><<<><<><<<<>>>><<>>><<<<>>><<<><<<>><<<>>>><<<<>><<><>><<<><<<>>>><<<<>><<<>>>><><<<<>>><<<>><>><>>><<><<<<><>><<>>>><>>>><>><<<<>>>><<<>>><<<<>>>><>><<><<>><<<<>>>><<<><>>>><<<<>>>><><<<><<<<>>>><<<<>>><<<>>><<>><<>>>><><>>>><<<>><<<<>>>><<<>><<<>><<<>><<<>>><><<<<><>>><<<<>>>><<<>><><<<>>><<><<>>>><<><<>>><<<>><<<<>>>><>>><><<<<>>>><<<>>>><<<<>>><>><<>>>><><<<<>>><<<>>><<>>><<<><<<>>>><>>>><<<<><<<<>><<<<>><<<<>>><<><>>><<<>><>><<<>>><><>>><>><<><<><<><<<<><<<><<><>>>><<>>><<<<>><<<>><<>>><<<<>><<<>>><<>>>><<>><<<<><<<<>><<<<>><<>><>>>><<<<>>>><<<<><<<><<<<>>>><<<<>>>><<<>>><<<>>>><<>>>><<>>>><<<>>>><<<>>>><<<>><>><<<<>>><<<><>><<<><<<<>>>><<<>><>>><<<>>>><<<<>><<<>>>><>>><<<>>>><<>>><<<<>><<<<>>>><<<>><<>><>>><>>>><<<<>>><<<<>>><<<><<>>><<<>>>><<<<>>><><<><<<<><>>>><>>><<<<>>>><>>>><<<<><<>><<>>><><>>><<<>>><<<><<<<>>>><<>>>><>>>><<>>><<>>>><<<><><<<><<<>><<<>>><<<<>><<<<><<<>><<<>><<<>><<<>>>><>>><<>><<<<>><<<<><<>>>><<>><<><<<><<<<>>><>>><<<>>>><<<<>>><<<<>>>><><<<>>>><>><<<><<><<<<>>>><><<>>>><<<>><<<<>>>><<>>><<>>>><<<>><<<<><<<<>><<<<>>>><<<>><<<<>>><><<><>>>><><<<<>>>><<<><<>>>><<<<>>><>><<<<>>>><<>><<<><<<>>>><<>>><<>>>><<<<>>>><<<><<><<<<>><<<>>>><><<><<<<>>>><<>>>><<<<>>><>>>><><<<>>>><<>><>>><<>>><<<<><<<>>><>>><<><>><<<<>>>><<<<>><<<>>><<<<><<<>>><<<><>>>><<>>>><<<<>>>><<<<>><<<><<>><>>><<<>>>><<<<>>>><<<<><<>>>><>><<<<>>><<><<>>>><><<<<>>><<<<>><<<><<<<>><<<<>>>><<><<<><<>>>><><<><<<>><<<<>><<<><<<>>><<<<>>><<><>><<<>>>><<>><<>>>><<><<>><<<<>><<<<>><><>>>><<<<>>>><<>>><<<>><<<<><<><>>>><<<>>><<>>>><<<<>>><<<><<>><<<>>>><<>>><>>>><<<<><<<>>>><<<>><>>>><<<<>><><<<><<<>>>><<<>>><<>>><<><>>>><<<><<<<>>><<<><<>><<<>>><><<><<><<>><<<>>><<<<><<>><<<>><>>><<<>><<<<>><><<><><<<<><<<>>>><<>><>>>><<<><<>><<<<>>><<<>>><<>><>>>><<<>><<>><><<<<>>>><<<>>>><>><<<><><>><<<<><<<>>>><<<>>><<<<>>>><><>>>><><<<<>><<<><<>>>><<<>>>><<>>>><>>>><<><>>>><>><<<<>>><<><<<<>>>><<>>>><<>>><<<<>><<<><>>><<>>><>><<><<><<<<><<<<><<><<<<><>>><>>>><<<>><<<<>><<<<>><<<>>><>>>><<<>>>><>>><<<<>>><>>>><<<><<<>>>><>>>><<<<>>><>>><<>>>><>>><<>>>><<<<>>>><<<<>>>><<<>><>>>><<>>>><>><><<>>>><>><<><<<<>>><<<<>>><<<<>>>><<>><<<<>>>><<<<>><<>><>><<<>><>><<>>>><<<<><<<<><<>>><<<<>><<>>><<<>>><<<<>>>><<><<<>>>><<<<>>><<<>><>>>><<<>>><<<<>>>><<<<>><<<<>>>><<<>>>><<>><<<<>>>><>>><<<<>><<<<><>>>><<<>>><>>>><<>><>>><<<>>><>>>><<<>><<><>><<>>>><>><<<<><<><<<<>>>><>><<>>>><<>><<<<>><<<<>>><<<<>>><<>>><>><<><>><<>>>><<<<>><<>>>><<<<>>>><>>><<<>>>><>>><>>><<><<<<>>>><>><<><<>>><>>>><<>>>><<>><>>>><<><<>>>><<>><<>>>><<<>><<><>>><<<<><<<><>><<><><<<>><<<<>>>><<<<>><<<>>>><<<<>>><<<<><<<<>>><<<<><<<><<<>>><<>>>><<>><><<>>><<<<>>>><<<<><<>>>><>><<>>>><<>><>>>><<<>>>><<<<>><<>><>>><<<<>>>><<<<>>><<>><<<>>>><<<><><<>>>><>>><<<>>>><<<>><<<<>>>><<>>><<>>><><<<<>>><<<>>><<<<>><>><<<><<<<>>>><>><<<<>>><<><<<>>><<<<>><>>><><<>>>><<>>>><<>><<><<<>><<<<>><><><>><<<>>><<><<<<>>><<>>>><<<>>>><>>>><>>>><<<<>>><<<<>>>><<<<>><>>><<>><<>><<>><<<>>><>>><><<<>>><<<<><<<><><<><<<>><<<<>>>><<<>>><>>>><<<>>><<<<>>>><<<<>><<<<>>><>>><>>><<>>><<>>>><>>><<<<>>><<><<<>>><<<<><<<>>><<<<>>><<><<<>>>><<<>><<<<>>><<<<>>>><<<><<<<><<<>>><<<>>>><<<<>>><>>>><<<<>>><<>>><<<>>>><<<<>>><<><<>>><<>>><><<><<<>>>><>>>><<<<>>><<<<>>><>>><<>>><<>>>><><<<<>>><<<><<<<>>>><<<><<<><<>>>><<<>>><<<<>>><<<>>>><<<><<<<>>>><<<>><<>>><<<<>><<>>>><<<<>>><>><<<<>>>><<>>>><>><<><<<>><>>>><<>>><<<><<>><>>><<<<><<<>><<<<>>><<>>><<<>>>><<<>><<<><<><<><<>>>><>>><<>>><<<<>><<<<>>><<<>>><<><>><>>><<><<<>>>><<<><>><<<><<<<>><<<>>>><<>>><>>><<<>>>><<>>><<<><<<<>>><>><<>>><><<><<<<>>><<<>>>><<<<>><<<>>>><><>>>><>><<>>><><><<>>>><<<>>>><<<<><<<>>><<<<><>>>><<><><<>>>><><<<<>>>><><<<<>>>><>>>><<<<>>><<<><<<>><<<><<<>>>><<<<><<<>>><<<>>><>>><>>>><<><>>>><<>>><<>>><<>><<<<><<>>>><<>>><<<><<<>><<<<>>>><>>>><<<>>><<>>>><<>>>><<<>>><<><<<>>><<<<>>><<<><>>><<<>>><>>>><<>><<<<>>>><<<<>>><<<>><<<<>< \ No newline at end of file diff --git a/main.cpp b/main.cpp index 8ab7e53..53279ae 100644 --- a/main.cpp +++ b/main.cpp @@ -1,89 +1,171 @@ #define OLC_PGE_APPLICATION #include "pixelGameEngine.h" #include "olcutils.h" +#include using namespace olc; -class Example : public olc::PixelGameEngine -{ -public: - Example() - { - sAppName = "Example"; - } - -public: - bool RayVsRect(const vf2d ray_origin, const vf2d ray_dir, const olc::utils::geom2d::rect target, vf2d&contact_point, vf2d&contact_normal, float&t_hit_near){ - - contact_normal = { 0, 0 }; - contact_point = { 0, 0 }; - - vf2d t_near = {(target.pos.x - ray_origin.x) / ray_dir.x, (target.pos.y - ray_origin.y) / ray_dir.y}; - vf2d t_far = {(target.pos.x + target.size.x - ray_origin.x) / ray_dir.x, (target.pos.y + target.size.y - ray_origin.y) / ray_dir.y}; - - if (t_near.x > t_far.x) {float b; b = t_near.x; t_near.x = t_far.x; t_far.x = b;}; - if (t_near.y > t_far.y) {float b; b = t_near.y; t_near.y = t_far.y; t_far.y = b;}; - - if (t_near.x > t_far.y || t_near.y > t_far.x) return false; - - t_hit_near = fmax(t_near.x, t_near.y); - float t_hit_far = fmin(t_far.x, t_far.y); - - if (t_hit_far < 0) return false; - - contact_point.x = ray_origin.x + t_hit_near * ray_dir.x; - contact_point.y = ray_origin.y + t_hit_near * ray_dir.y; - - if (t_near.x > t_near.y) - if ( 1.0f / ray_dir.x < 0) - contact_normal = { 1, 0 }; - else - contact_normal = { -1, 0}; - else - if ( t_near.x < t_near.y) - if ( 1.0f / ray_dir.y < 0) - contact_normal = { 0, 1 }; - else - contact_normal = { 0, -1 }; - - return true; - - - } - vf2d originPoint={16,16}; - bool OnUserCreate() override - { - // Called once at the start, so create things here - return true; - } - - bool OnUserUpdate(float fElapsedTime) override - { - vf2d velocity={(GetKey(D).bHeld-GetKey(A).bHeld)*20*fElapsedTime,(GetKey(S).bHeld-GetKey(W).bHeld)*20*fElapsedTime}; - vf2d contact_point; - vf2d contact_normal; - float t_hit_near; - - Clear(Pixel(64,64,255)); - if (!olc::utils::geom2d::overlaps(olc::utils::geom2d::circle{originPoint+velocity,5},olc::utils::geom2d::rect{{32,32},{64,32}})) { - originPoint+=velocity; - DrawCircle(originPoint,5); - } else { - DrawCircle(originPoint,5,RED); - } - DrawLine(originPoint,GetMousePos()); - - DrawRect({32,32},{64,32},RayVsRect(originPoint, GetMousePos()-originPoint, olc::utils::geom2d::rect{{32,32},{64,32}},contact_point,contact_normal,t_hit_near)&&t_hit_near<1?YELLOW:WHITE); - return true; - } -}; - - int main() { - Example demo; - if (demo.Construct(128, 120, 8, 8)) - demo.Start(); + std::ifstream file("input"); + std::vector>playfieldRows; + std::array,4>piece{{ + {' ',' ',' ',' '}, + {' ',' ',' ',' '}, + {' ',' ',' ',' '}, + {' ',' ',' ',' '}}}; + vi2d piecePos={0,0}; + std::array,4>,vi2d>,5>pieces{{ + {{{{'#','#','#','#'}, + {' ',' ',' ',' '}, + {' ',' ',' ',' '}, + {' ',' ',' ',' '}}},{4,1}}, + {{{{' ','#',' ',' '}, + {'#','#','#',' '}, + {' ','#',' ',' '}, + {' ',' ',' ',' '}}},{3,3}}, + {{{{' ',' ','#',' '}, + {' ',' ','#',' '}, + {'#','#','#',' '}, + {' ',' ',' ',' '}}},{3,3}}, + {{{{'#',' ',' ',' '}, + {'#',' ',' ',' '}, + {'#',' ',' ',' '}, + {'#',' ',' ',' '}}},{1,4}}, + {{{{'#','#',' ',' '}, + {'#','#',' ',' '}, + {' ',' ',' ',' '}, + {' ',' ',' ',' '}}},{2,2}},}}; + int currentPiece=0; + int topRow=0; + int jetMarker=0; + while (file.good()){ + std::string line; + std::getline(file,line); + if (line.length()>0){ + std::cout<,4>,vi2d>piece=pieces[currentPiece]; + currentPiece=(currentPiece+1)%5; + int newRows=3-topRow+piece.second.y; + //std::cout<<"Adding "<0){ + for (int j=0;jnewRow={' ',' ',' ',' ',' ',' ',' '}; + playfieldRows.insert(playfieldRows.begin(),newRow); + topRow++; + } + piecePos={2,0}; + } else { + piecePos={2,topRow-3-piece.second.y}; + } + while (!pieceLanded) { + char direction=line[jetMarker]; + //std::cout<0){ + for (int yy=0;yy':{ + if (piecePos.x+piece.second.x<7){ + for (int yy=0;yy=piecePos.x&&y>=piecePos.y&&x-1 + +using namespace olc; + +int main() +{ + std::ifstream file("input"); + std::vector>playfieldRows; + std::array,4>piece{{ + {' ',' ',' ',' '}, + {' ',' ',' ',' '}, + {' ',' ',' ',' '}, + {' ',' ',' ',' '}}}; + vi2d piecePos={0,0}; + std::array,4>,vi2d>,5>pieces{{ + {{{{'#','#','#','#'}, + {' ',' ',' ',' '}, + {' ',' ',' ',' '}, + {' ',' ',' ',' '}}},{4,1}}, + {{{{' ','#',' ',' '}, + {'#','#','#',' '}, + {' ','#',' ',' '}, + {' ',' ',' ',' '}}},{3,3}}, + {{{{' ',' ','#',' '}, + {' ',' ','#',' '}, + {'#','#','#',' '}, + {' ',' ',' ',' '}}},{3,3}}, + {{{{'#',' ',' ',' '}, + {'#',' ',' ',' '}, + {'#',' ',' ',' '}, + {'#',' ',' ',' '}}},{1,4}}, + {{{{'#','#',' ',' '}, + {'#','#',' ',' '}, + {' ',' ',' ',' '}, + {' ',' ',' ',' '}}},{2,2}},}}; + int currentPiece=0; + int topRow=0; + int jetMarker=0; + while (file.good()){ + std::string line; + std::getline(file,line); + if (line.length()>0){ + std::cout<,4>,vi2d>piece=pieces[currentPiece]; + currentPiece=(currentPiece+1)%5; + int newRows=3-topRow+piece.second.y; + //std::cout<<"Adding "<0){ + for (int j=0;jnewRow={' ',' ',' ',' ',' ',' ',' '}; + playfieldRows.insert(playfieldRows.begin(),newRow); + topRow++; + } + piecePos={2,0}; + } else { + piecePos={2,topRow-3-piece.second.y}; + } + while (!pieceLanded) { + char direction=line[jetMarker]; + //std::cout<0){ + for (int yy=0;yy':{ + if (piecePos.x+piece.second.x<7){ + for (int yy=0;yy=piecePos.x&&y>=piecePos.y&&x-1>><<><>><<<>><>>><<<>>><<<><<<>><>><<>> \ No newline at end of file