Fehlerbehebung klein und großbuchstaben behoben!
This commit is contained in:
parent
91ab73663a
commit
f77c450c0f
8
.idea/Informatik_2_Praktikum.iml
generated
8
.idea/Informatik_2_Praktikum.iml
generated
@ -1,8 +1,2 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module type="CPP_MODULE" version="4">
|
<module classpath="CIDR" type="CPP_MODULE" version="4" />
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<content url="file://$MODULE_DIR$" />
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
2
.idea/vcs.xml
generated
2
.idea/vcs.xml
generated
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -12,22 +12,23 @@
|
|||||||
|
|
||||||
// Creates the word salad by placing words randomly and filling empty spaces
|
// 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)
|
int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount)
|
||||||
{
|
{// Länge der searchFieldLen wird in Main unter Salad size festgelegt (20)
|
||||||
|
|
||||||
srand((unsigned int)time(NULL)); // Seed für Zufallsgenerator
|
srand((unsigned int)time(NULL)); // Seed für Zufallsgenerator
|
||||||
|
|
||||||
|
|
||||||
// Initialisiere das Spielfeld mit EMPTY_CHAR
|
// Initialisiere das Spielfeld mit EMPTY_CHAR
|
||||||
for (unsigned int i = 0; i < searchFieldLen; ++i)
|
for (unsigned int i = 0; i < searchFieldLen; ++i)
|
||||||
{
|
{
|
||||||
for (unsigned int j = 0; j < searchFieldLen; ++j)
|
for (unsigned int j = 0; j < searchFieldLen; ++j)
|
||||||
{
|
{
|
||||||
salad[i][j] = EMPTY_CHAR;
|
salad[i][j] = ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int placedWords = 0;
|
unsigned int placedWords = 0;
|
||||||
|
|
||||||
for (unsigned int w = 0; w < wordCount; ++w)
|
for (unsigned int word = 0; word < wordCount; ++word)
|
||||||
{
|
{
|
||||||
int placed = 0;
|
int placed = 0;
|
||||||
for (int tries = 0; tries < MAX_RAND_TRIES_PER_WORD && !placed; ++tries)
|
for (int tries = 0; tries < MAX_RAND_TRIES_PER_WORD && !placed; ++tries)
|
||||||
@ -35,15 +36,15 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
int direction = rand() % 2; // 1 = horizontal, 0 = vertical
|
int direction = rand() % 2; // 1 = horizontal, 0 = vertical
|
||||||
int row = rand() % searchFieldLen;
|
int row = rand() % searchFieldLen;
|
||||||
int col = rand() % searchFieldLen;
|
int col = rand() % searchFieldLen;
|
||||||
int len = (int)strlen(words[w]);
|
int len = (int)strlen(words[word]);
|
||||||
|
|
||||||
if (direction == 1 && col + len <= searchFieldLen) // horizontal
|
if (direction == 1 && col + len <= searchFieldLen) // prüft ob das Wort horizontal in die Tabelle passt
|
||||||
{
|
{
|
||||||
int canPlace = 1;
|
int canPlace = 1;
|
||||||
for (int i = 0; i < len; ++i)
|
for (int i = 0; i < len; ++i)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (salad[row][col + i] != EMPTY_CHAR && salad[row][col + i] != words[w][i])
|
if (salad[row][col + i] != EMPTY_CHAR && salad[row][col + i] != words[word][i])
|
||||||
{
|
{
|
||||||
canPlace = 0;
|
canPlace = 0;
|
||||||
break;
|
break;
|
||||||
@ -52,7 +53,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
if (canPlace)
|
if (canPlace)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < len; ++i)
|
for (int i = 0; i < len; ++i)
|
||||||
salad[row][col + i] = words[w][i];
|
salad[row][col + i] = words[word][i];
|
||||||
placed = 1;
|
placed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,7 +62,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
int canPlace = 1;
|
int canPlace = 1;
|
||||||
for (int i = 0; i < len; ++i)
|
for (int i = 0; i < len; ++i)
|
||||||
{
|
{
|
||||||
if (salad[row + i][col] != EMPTY_CHAR && salad[row + i][col] != words[w][i])
|
if (salad[row + i][col] != EMPTY_CHAR && salad[row + i][col] != words[word][i])
|
||||||
{
|
{
|
||||||
canPlace = 0;
|
canPlace = 0;
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
if (canPlace)
|
if (canPlace)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < len; ++i)
|
for (int i = 0; i < len; ++i)
|
||||||
salad[row + i][col] = words[w][i];
|
salad[row + i][col] = words[word][i];
|
||||||
placed = 1;
|
placed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,24 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
|
||||||
|
void capitalletters(char *str){
|
||||||
|
while (*str) {
|
||||||
|
*str = toupper((unsigned char) *str);
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
// Liest Wörter aus Datei und speichert sie sicher im Array
|
// Liest Wörter aus Datei und speichert sie sicher im Array
|
||||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
||||||
{
|
{
|
||||||
char buffer[MAX_WORD_LEN];
|
char buffer[MAX_WORD_LEN];
|
||||||
unsigned int count_word = 0;
|
unsigned int count_word = 0;
|
||||||
|
|
||||||
|
|
||||||
while (count_word < maxWordCount && fgets(buffer, sizeof(buffer), file) != NULL)
|
while (count_word < maxWordCount && fgets(buffer, sizeof(buffer), file) != NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Zeilenumbruch manuell entfernen
|
// Zeilenumbruch manuell entfernen
|
||||||
for (int i = 0; i < MAX_WORD_LEN; i++)
|
for (int i = 0; i < MAX_WORD_LEN; i++)
|
||||||
{
|
{
|
||||||
@ -20,6 +30,8 @@ int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
capitalletters(buffer);
|
||||||
|
|
||||||
// Sicheres Kopieren in das Zielarray
|
// Sicheres Kopieren in das Zielarray
|
||||||
strncpy(words[count_word], buffer, MAX_WORD_LEN - 1);
|
strncpy(words[count_word], buffer, MAX_WORD_LEN - 1);
|
||||||
words[count_word][MAX_WORD_LEN - 1] = '\0'; // Nullterminierung sicherstellen
|
words[count_word][MAX_WORD_LEN - 1] = '\0'; // Nullterminierung sicherstellen
|
||||||
|
@ -57,8 +57,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
|
raylib_folder = ./raylib
|
||||||
|
unityfolder = ./unity
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -g -Wall -I$(raylibfolder)
|
CFLAGS = -g -Wall -I$(raylib_folder)
|
||||||
LDFLAGS = -lopengl32 -lgdi32 -lwinmm
|
LDFLAGS = -lopengl32 -lgdi32 -lwinmm
|
||||||
BINARIES = ./windows
|
BINARIES = ./windows
|
||||||
|
|
||||||
raylib_folder = ./raylib
|
|
||||||
unityfolder = ./unity
|
|
||||||
|
|
||||||
# --------------------------
|
# --------------------------
|
||||||
# initiales Spiel bauen
|
# initiales Spiel bauen
|
||||||
@ -23,7 +25,7 @@ main.o: main.c
|
|||||||
$(CC) -c $(CFLAGS) main.c
|
$(CC) -c $(CFLAGS) main.c
|
||||||
|
|
||||||
input.o: input.c
|
input.o: input.c
|
||||||
$(CC) -c $(CFLAGS)input.c
|
$(CC) -c $(CFLAGS) input.c
|
||||||
|
|
||||||
game.o: game.c
|
game.o: game.c
|
||||||
$(CC) -c $(CFLAGS) game.c
|
$(CC) -c $(CFLAGS) game.c
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user