diff options
Diffstat (limited to 'puzzle.cpp')
-rw-r--r-- | puzzle.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -7,6 +7,8 @@ #include <utility> #include <memory> +GameParams* GameParams::instance = nullptr; + void GameParams::CalculateStandardPuzzlePos() { coordinates tmp; @@ -14,8 +16,6 @@ void GameParams::CalculateStandardPuzzlePos() int i, j, k = 0; for(i = 0; i < puzzles_per_side; ++i) for(j = 0; j < puzzles_per_side; ++j, ++k) { - if(i == puzzles_per_side-1 && j == puzzles_per_side-1) - break; tmp.x = i * (puzzle_size + spacing) + spacing; tmp.y = j * (puzzle_size + spacing) + spacing + 30; standard_puzzle_coordinates[k] = tmp; @@ -49,15 +49,22 @@ void GameParams::NextUntestedPuzzles() */ win->begin(); for(int i = 0; i < puzzle_pieces; ++i) { - tmp_puzzle = - std::unique_ptr<Puzzle>(new Puzzle(standard_puzzle_coordinates[i].x, - standard_puzzle_coordinates[i].y)); idx_random_puzzle = 0 + (int)((double)puzzle_pieces * rand()/(RAND_MAX + 1.0)); while(!free_puzzles[idx_random_puzzle]) idx_random_puzzle = 0 + (int)((double)puzzle_pieces * rand()/(RAND_MAX + 1.0)); free_puzzles[idx_random_puzzle] = 0; + /* empty puzzle */ + if(idx_random_puzzle == puzzle_pieces-1) { + SetXYEmptyBox(standard_puzzle_coordinates[i].x, + standard_puzzle_coordinates[i].y); + continue; + } + /* common puzzle */ + tmp_puzzle = + std::unique_ptr<Puzzle>(new Puzzle(standard_puzzle_coordinates[i].x, + standard_puzzle_coordinates[i].y)); tmp_puzzle->sequence_number = idx_random_puzzle; find_path_to_picture(tmp_puzzle->path, tmp_puzzle->sequence_number); Fl_JPEG_Image *img = new Fl_JPEG_Image(tmp_puzzle->path.c_str()); |