From 8d9b7adfc591067172bdc01aa4a20c3b36c4703f Mon Sep 17 00:00:00 2001 From: Anton Lewedei Date: Tue, 4 Nov 2025 15:37:37 +0100 Subject: [PATCH] Anfang game.c --- Start_Windows/game.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Start_Windows/game.c b/Start_Windows/game.c index d8cc133..6e67461 100644 --- a/Start_Windows/game.c +++ b/Start_Windows/game.c @@ -2,14 +2,36 @@ #include #include #include +#include +#include "game.h" #define MAX_RAND_TRIES_PER_WORD 10 -#define EMPTY_CHAR 0 +#define EMPTY_CHAR '.' //TODO: Spiellogik implementieren: /* * Wörter aus der Wortliste zufällig horizontal oder vertikal platzieren * restliche Felder mit zufälligen Buchstaben füllen */ +static void initializeArray(char salad [MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], + unsigned int SearchFieldLen) //Array initialisieren & mit Filler füllen +{ + for (int i = 0; i < SearchFieldLen; i++) + { + for (int j = 0; j < MAX_SEARCH_FIELD_LEN; j++) + { + salad[i][j] = EMPTY_CHAR; + } + } +} + +static void col_roq (unsigned int searchFieldLen, int *x, int *y) //Zufällige x/y Koordinate für Wortanfang +{ + *x = rand() % searchFieldLen; + + *y = rand() % searchFieldLen; +} + + // Creates the word salad by placing words randomly and filling empty spaces int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount) {