finished Programm

This commit is contained in:
hruschkajo103995 committed 2026-10-28 17:10:44 +01:00
1 parent cbfd7d5071
commit f81b98bc1c
2 files changed
+19 -9

No files matched your search

+5 -5
View File
@@ -19,7 +19,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
//befüllen des Arrays mit '\0'
for(unsigned int i = 0; i < searchFieldLen; i++)
{
for(unsigned int j = 0; j < searchFieldLen; i++)
for(unsigned int j = 0; j < searchFieldLen; j++)
{
salad[i][j] = '\0';
}
@@ -48,8 +48,8 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
int zeile = rand() % searchFieldLen;
int spalte = rand() % searchFieldLen;
if(dir == 0 && (zeile + laenge > searchFieldLen))
if(dir == 1 && (spalte + laenge > searchFieldLen))
if ((dir == 0 && (zeile + laenge > searchFieldLen)) ||
(dir == 1 && (spalte + laenge > searchFieldLen)))
{
continue;
}
@@ -89,12 +89,12 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
{
for(unsigned int j = 0; j < searchFieldLen; j++)
{
if(salad[i][j] == '\n')
if(salad[i][j] == '\0')
{
salad[i][j] = 'A' + rand() % 26;
}
}
}
return ERFOLG;
return (int)wordCount;
}
+14 -4
View File
@@ -2,6 +2,7 @@
#include <stdio.h>
#include "input.h"
#include "game.h"
#include <time.h>
#include "graphicalGame.h"
#define MAX_NUMBER_OF_WORDS 100
@@ -38,10 +39,19 @@ int main(int argc, char *argv[])
// Create the word salad by placing words into grid
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
if (placedWords == (int)wordCount)
{
// Alle Wörter wurden erfolgreich platziert
startGame(wordSalad, SALAD_SIZE, words, wordCount, 800);
}
else
{
// Fehler beim Erstellen des Wortsalats
fprintf(stderr,
"Fehler beim Erstellen des Wortsalats. Rueckgabewert: %d\n",
(int)placedWords);
exitCode = EXIT_FAILURE;
}
}
else