57 lines
1.4 KiB
C
57 lines
1.4 KiB
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include "input.h"
|
|
#include "game.h"
|
|
#include "graphicalGame.h"
|
|
|
|
#define MAX_NUMBER_OF_WORDS 100
|
|
#define SALAD_SIZE 20
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int exitCode = EXIT_SUCCESS;
|
|
|
|
if (argc != 2)
|
|
{
|
|
fprintf(stderr, "Benutzung: %s <Pfad zur Wörterdatei>\n", argv[0]);
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
char words[MAX_NUMBER_OF_WORDS][MAX_WORD_LEN];
|
|
unsigned int wordCount = 0;
|
|
|
|
FILE *file = fopen(argv[1], "r");
|
|
if (!file)
|
|
{
|
|
fprintf(stderr, "Konnte Datei %s nicht öffnen.\n", argv[1]);
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
unsigned int placedWords = 0;
|
|
char wordSalad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN];
|
|
|
|
wordCount = readWords(file, words, MAX_NUMBER_OF_WORDS);
|
|
fclose(file);
|
|
|
|
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
|
|
|
printf("\nWortsalat-Initialisierung\n");
|
|
printf("-------------------------\n");
|
|
printf("Gelesene Woerter: %u\n", wordCount);
|
|
printf("Platzierte Woerter: %u\n", placedWords);
|
|
|
|
if (placedWords < wordCount)
|
|
printf("Hinweis: %u Woerter konnten nicht platziert werden.\n", wordCount - placedWords);
|
|
|
|
printf("\nSpielfeld (%dx%d):\n\n", SALAD_SIZE, SALAD_SIZE);
|
|
showWordSalad(wordSalad, SALAD_SIZE);
|
|
|
|
|
|
printf("\nInitialisierung abgeschlossen.\n");
|
|
|
|
// Später evtl.:
|
|
// startGraphicalGame(wordSalad, SALAD_SIZE, words, wordCount);
|
|
|
|
return exitCode;
|
|
}
|