fix seed generator for game

This commit is contained in:
hoangto105860 committed 2026-10-24 21:28:35 +02:00
1 parent ab558de8b3
commit cbf5f85caf
9 files changed
+27 -10

No files matched your search

+21 -4
View File
@@ -3,6 +3,9 @@
#include "input.h"
#include "game.h"
#include "graphicalGame.h"
#include <errno.h>
#include <time.h>
#define MAX_NUMBER_OF_WORDS 100
#define SALAD_SIZE 20
@@ -10,8 +13,9 @@
int main(int argc, char *argv[])
{
int exitCode = EXIT_SUCCESS;
printf("start main\n");
srand(time(NULL));
// Check if the correct number of arguments is provided
if(argc != 2)
{
@@ -35,13 +39,26 @@ int main(int argc, char *argv[])
fclose(file);
// Create the word salad by placing words into grid
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
//placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
// TODO:
// Check if all words were successfully placed
// Start the game if successful
// error message if some words couldn't be placed
for(int i = 0; i < 10000; i++)
{
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
if(placedWords == wordCount)
{
// Start the game if successful
return exitCode;
}
}
// error message if some words couldn't be placed
fprintf(stderr, "could not start wordsalad.\n");
exitCode = EXIT_FAILURE;
}
else
{