55 lines
1.4 KiB
C

#include "game.h"
#include <time.h>
#include <stdlib.h>
#include <string.h>
#define MAX_RAND_TRIES_PER_WORD 10
#define EMPTY_CHAR 0
//TODO: Spiellogik implementieren:
/* * Wörter aus der Wortliste zufällig horizontal oder vertikal platzieren
* restliche Felder mit zufälligen Buchstaben füllen */
void emptyArray();
int placeWord();
void fillEmptySpots();
// 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)
{
srand(time(NULL));
emptyArray(salad,MAX_SEARCH_FIELD_LEN * MAX_SEARCH_FIELD_LEN);
placeWord(salad,words);
fillEmptySpots(salad);
}
// Prints the word salad to console
void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
{
for(int i = 0; i <= MAX_SEARCH_FIELD_LEN; i++ )
{
for(int j = 0; j <= MAX_SEARCH_FIELD_LEN; j++)
{
printf("[%c]",salad[i][j]);
}
printf("\n");
}
}
void emptyArray(char array[][], int arrayLength)
{
char* element = (char*) &array;
for(int i = 0; i < arrayLength; i++ )
{
*element = EMPTY_CHAR;
element++;
}
}
int placeWord(char intoArray[][], char insertedWord[][])
{
}
void fillEmptySpots(char useArray[][])
{
}