diff --git a/board_widget.cpp b/board_widget.cpp index c7f35a12261ace33511bf2f57dcb6b5647c6c96c..258fc0ebba450e59f9fa71a41edafaff2452c8a9 100644 --- a/board_widget.cpp +++ b/board_widget.cpp @@ -2,39 +2,44 @@ #include "graphics.hpp" #include <iostream> +///betu �s vonalszin: 252, 232, 252 +///hatterszin: 250, 75, 241 +///helytelen: 61, 0, 58 + + using namespace genv; BoardWidget::BoardWidget(Application* parent, JatekMester* mester, int& selected_row, int& selected_col, int x, int y, int sx, int sy) : Widget(parent, x, y, sx, sy), mester(mester), selected_row(selected_row), selected_col(selected_col), BOARD_SIZE(9), CELL_SIZE(sx / BOARD_SIZE) {} void BoardWidget::draw() const { - // Draw cells and numbers + for (int i = 0; i < BOARD_SIZE; ++i) { for (int j = 0; j < BOARD_SIZE; ++j) { int x = _x + j * CELL_SIZE; int y = _y + i * CELL_SIZE; - gout << move_to(x, y) << color(255, 255, 255) << box(CELL_SIZE, CELL_SIZE); + gout << move_to(x, y) << color(250, 75, 241) << box(CELL_SIZE, CELL_SIZE); int value = mester->get_value(i, j); if (value != 0) { if (!mester->is_cell_valid(i, j)) { - gout << color(255, 0, 0); // Piros ha helytelen + gout << color(61, 0, 58); } else { - gout << color(0, 0, 0); // Fekete ha helyes + gout << color(252, 232, 252); } gout << move_to(x + CELL_SIZE / 3, y + CELL_SIZE / 1.5) << text(std::to_string(value)); } } } - // Draw grid lines + for (int i = 0; i <= BOARD_SIZE; ++i) { - int line_thickness = (i % 3 == 0) ? 3 : 1; // Thicker lines for block boundaries - gout << move_to(_x + i * CELL_SIZE, _y) << color(0, 0, 0); + int line_thickness = (i % 3 == 0) ? 3 : 1; + gout << move_to(_x + i * CELL_SIZE, _y) << color(252, 232, 252); for (int t = 0; t < line_thickness; ++t) { gout << move_to(_x + i * CELL_SIZE + t, _y) << line(0, _size_y); } - gout << move_to(_x, _y + i * CELL_SIZE) << color(0, 0, 0); + gout << move_to(_x, _y + i * CELL_SIZE) << color(252, 232, 252); for (int t = 0; t < line_thickness; ++t) { gout << move_to(_x, _y + i * CELL_SIZE + t) << line(_size_x, 0); } diff --git a/jatek_mester.cpp b/jatek_mester.cpp index 8bde9538b089ef91aefe2c71712b7a2a43ae708b..f8b52a9eb372b285be3cb2b0b6f08c5114f0c967 100644 --- a/jatek_mester.cpp +++ b/jatek_mester.cpp @@ -7,21 +7,21 @@ JatekMester::JatekMester() : board(9, std::vector<int>(9, 0)), original_board(9, std::vector<int>(9, 0)) {} bool JatekMester::is_valid_move(int number, int row, int col) const { - // Ellenőrizze a sorban + for (int j = 0; j < 9; ++j) { if (j != col && board[row][j] == number) { return false; } } - // Ellenőrizze az oszlopban + for (int i = 0; i < 9; ++i) { if (i != row && board[i][col] == number) { return false; } } - // Ellenőrizze a 3x3-as blokkban + int block_start_row = row - row % 3; int block_start_col = col - col % 3; for (int i = block_start_row; i < block_start_row + 3; ++i) { diff --git a/jatek_mester.hpp b/jatek_mester.hpp index 684db5b7a7559b63919c29246a319d126bc9f2dd..fcda66c526085a15dade787592450ebede7d8eba 100644 --- a/jatek_mester.hpp +++ b/jatek_mester.hpp @@ -16,7 +16,7 @@ public: void update_value(int row, int col, int value); int get_value(int row, int col) const; bool load_from_file(const std::string& filename); - bool is_cell_valid(int row, int col) const; // �j f�ggv�ny + bool is_cell_valid(int row, int col) const; }; #endif // JATEK_MESTER_HPP diff --git a/main.cpp b/main.cpp index 15562afa4253b60281b61cd871f5977e755d0a53..b563b75c7c65a69ae120250e361098a844a4404e 100644 --- a/main.cpp +++ b/main.cpp @@ -5,12 +5,11 @@ #include "jatek_mester.hpp" - int main() { Application app(600, 600); JatekMester mester; - if (!mester.load_from_file("sudoku_easy.txt")) { - std::cerr << "Failed to load Sudoku board from file.\n"; + if (!mester.load_from_file("sudoku_medium.txt")) { + std::cerr << "Nem sikerult a file olvasasa.\n"; return 1; } diff --git a/widgets.hpp b/widgets.hpp index ca81c1624b2ed9c4325433af55ff3d56584a6149..b399fc9e166daa359ff4bb800b044f90ec040c57 100644 --- a/widgets.hpp +++ b/widgets.hpp @@ -5,7 +5,7 @@ #include "application.hpp" #include <functional> -class Application; // Forward declaration +class Application; class Widget { protected: