Initialisierung Spiel

This commit is contained in:
LukVal54 2025-11-01 15:14:44 +01:00
parent 551d0738ee
commit dd257eac8f

View File

@ -5,7 +5,7 @@
#include "graphicalGame.h" #include "graphicalGame.h"
#define MAX_NUMBER_OF_WORDS 100 #define MAX_NUMBER_OF_WORDS 100
#define SALAD_SIZE 20 #define SALAD_SIZE 20 //20 Buchstaben breit und lang
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@ -22,7 +22,7 @@ int main(int argc, char *argv[])
char words[MAX_NUMBER_OF_WORDS][MAX_WORD_LEN]; // Array to hold the words to be used in the game char words[MAX_NUMBER_OF_WORDS][MAX_WORD_LEN]; // Array to hold the words to be used in the game
unsigned int wordCount = 0; unsigned int wordCount = 0;
FILE *file = fopen(argv[1], "r"); FILE *file = fopen(argv[1], "r"); //FILE ZEIGER, öffne cmd zweites Wort: Zweites Wort ist ja words.txt also Wort file
if(file != NULL) if(file != NULL)
{ {
@ -36,6 +36,16 @@ int main(int argc, char *argv[])
// Create the word salad by placing words into grid // Create the word salad by placing words into grid
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount); placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
if(placedWords == wordCount) //Checks if all words were placed
{
startGame(wordSalad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], SALAD_SIZE, words[MAX_NUMBER_OF_WORDS][MAX_WORD_LEN], placedWords, 800);
}
else
{
printf("Error. Out of %d words just %d words could be placed.\n", wordCount, placedWords);
}
// TODO: // TODO:
// Check if all words were successfully placed // Check if all words were successfully placed
// Start the game if successful // Start the game if successful