deleted testing lines -- tried to build main but had issues with graphicalGame.c
This commit is contained in:
parent
26efe137cb
commit
c6664be88c
9
Start_Windows/.vscode/launch.json
vendored
9
Start_Windows/.vscode/launch.json
vendored
@ -2,17 +2,18 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Debug current C file",
|
"name": "Debug Word Salad",
|
||||||
"type": "cppdbg",
|
"type": "cppdbg",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
|
"program": "${fileDirname}\\word-salad.exe",
|
||||||
"args": [],
|
"args": ["${fileDirname}/words.txt"],
|
||||||
|
"cwd": "${fileDirname}",
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"cwd": "${fileDirname}",
|
"cwd": "${fileDirname}",
|
||||||
"externalConsole": false,
|
"externalConsole": false,
|
||||||
"MIMode": "gdb",
|
"MIMode": "gdb",
|
||||||
"miDebuggerPath": "C:/msys64/mingw64/bin/gdb.exe",
|
"miDebuggerPath": "C:/msys64/mingw64/bin/gdb.exe",
|
||||||
"preLaunchTask": "C/C++: gcc.exe build active file"
|
"preLaunchTask": "make"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
3
Start_Windows/.vscode/settings.json
vendored
3
Start_Windows/.vscode/settings.json
vendored
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"ctype.h": "c"
|
"ctype.h": "c",
|
||||||
|
"input.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
18
Start_Windows/.vscode/tasks.json
vendored
18
Start_Windows/.vscode/tasks.json
vendored
@ -2,6 +2,22 @@
|
|||||||
{
|
{
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "make",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "C:/msys64/usr/bin/make.exe",
|
||||||
|
"options": {
|
||||||
|
"cwd": "${fileDirname}",
|
||||||
|
"env": { "PATH": "C:/msys64/mingw64/bin;${env:PATH}" },
|
||||||
|
},
|
||||||
|
"problemMatcher": ["$gcc"],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
"label": "build C file",
|
"label": "build C file",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
@ -42,7 +58,7 @@
|
|||||||
],
|
],
|
||||||
"group": {
|
"group": {
|
||||||
"kind": "build",
|
"kind": "build",
|
||||||
"isDefault": true
|
"isDefault": false
|
||||||
},
|
},
|
||||||
"detail": "Task generated by Debugger."
|
"detail": "Task generated by Debugger."
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,5 +6,51 @@
|
|||||||
// Read words from file and store in 'words' array
|
// Read words from file and store in 'words' 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)
|
||||||
{
|
{
|
||||||
//TODO: Implement function to read words from file words.txt and store them in the words array. See, that in the file words are not seperated only by , ; or space but also by new lines.
|
int zeilen = 0;
|
||||||
|
|
||||||
|
if(file == 0)
|
||||||
|
{
|
||||||
|
printf("Fehler beim oeffnen der Woerter \n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
while(fgets(words[zeilen], MAX_WORD_LEN, file) != 0) //auslesen der Zeilen
|
||||||
|
{
|
||||||
|
size_t laenge = strlen(words[zeilen]); // Datentyp size_t wird verwendet bei strlen
|
||||||
|
if(laenge > 0 && words[zeilen][laenge - 1] == '\n') //austauschen des Leerzeichens mit einem Nullzeichen falls nötig
|
||||||
|
{
|
||||||
|
words[zeilen][laenge - 1] = '\0';
|
||||||
|
laenge--; // Länge nach austauschen 1 kleiner weil nullzeichen nicht mitzählt
|
||||||
|
}
|
||||||
|
zeilen++;
|
||||||
|
}
|
||||||
|
|
||||||
|
int alt_zeilen = zeilen;
|
||||||
|
zeilen = 0;
|
||||||
|
char *teiler = " .,;\n\t\r";
|
||||||
|
char *woerter;
|
||||||
|
char aufgeteilt[MAX_NUMBER_OF_WORDS][MAX_LINE_LEN]; //zwischenspeicher fürs aufteilen der Wörter
|
||||||
|
for(int i = 0; i < alt_zeilen; i++) // Jede Zeile einzeln betrachten
|
||||||
|
{
|
||||||
|
woerter = strtok(words[i], teiler);
|
||||||
|
while(woerter != 0)
|
||||||
|
{
|
||||||
|
strncpy(aufgeteilt[zeilen], woerter, MAX_WORD_LEN); // Kopieren der aufgeteilten Wörter in den Zwischenspeicher
|
||||||
|
zeilen++;
|
||||||
|
woerter = strtok(NULL, teiler); // NULL sagt das man weiterhin in der selben Zeile bleibt und dort aufteilt
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < zeilen; i++)
|
||||||
|
{
|
||||||
|
strncpy(words[i], aufgeteilt[i], MAX_WORD_LEN); // überschreiben der Wörter zurück ins alte Array
|
||||||
|
size_t len = strlen(words[i]);
|
||||||
|
for(int j = 0; j < len; j++)
|
||||||
|
{
|
||||||
|
words[i][j] = toupper(words[i][j]); // groß schreiben
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return zeilen;
|
||||||
}
|
}
|
||||||
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#define MAX_WORD_LEN 100
|
#define MAX_WORD_LEN 100
|
||||||
#define MAX_LINE_LEN 1024
|
#define MAX_LINE_LEN 1024
|
||||||
|
#define MAX_NUMBER_OF_WORDS 100
|
||||||
|
|
||||||
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount);
|
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount);
|
||||||
|
|
||||||
|
|||||||
@ -33,14 +33,14 @@ int main(int argc, char *argv[])
|
|||||||
wordCount = readWords(file, words, MAX_NUMBER_OF_WORDS);
|
wordCount = readWords(file, words, MAX_NUMBER_OF_WORDS);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
// Create the word salad by placing words into grid
|
// Create the word salad by placing words into grid
|
||||||
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
|
||||||
|
|
||||||
// Start game if all valid words were placed
|
// Start game if all valid words were placed
|
||||||
if (placedWords == wordCount) {
|
if (placedWords == wordCount) {
|
||||||
startGame(wordSalad, SALAD_SIZE, words, wordCount);
|
startGame(wordSalad, SALAD_SIZE, words, wordCount, MAX_SEARCH_FIELD_LEN);
|
||||||
} else {
|
} else {
|
||||||
printf("Could not place all valid words. Placed %d out of %d words.\n", placedWords, wordCount);
|
printf("Could not place all valid words. Placed %d out of %d words.\n", placedWords, wordCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,20 @@
|
|||||||
CC = gcc
|
CC = C:/msys64/mingw64/bin/gcc.exe
|
||||||
CFLAGS = -g -Wall
|
CFLAGS = -g -Wall -I. -IC:/msys64/mingw64/include
|
||||||
LDFLAGS = -lopengl32 -lgdi32 -lwinmm
|
LDFLAGS = -LC:/msys64/mingw64/lib -lraylib -lopengl32 -lgdi32 -lwinmm
|
||||||
BINARIES = ./windows
|
|
||||||
|
|
||||||
raylibfolder = ./raylib
|
SRC = main.c input.c game.c graphicalGame.c
|
||||||
unityfolder = ./unity
|
OBJ = $(SRC:.c=.o)
|
||||||
|
EXE = word-salad.exe
|
||||||
|
|
||||||
|
all: $(EXE)
|
||||||
|
$(EXE): $(OBJ)
|
||||||
|
$(CC) -o $@ $(OBJ) $(LDFLAGS)
|
||||||
|
|
||||||
|
%.o: %.c
|
||||||
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *.exe
|
||||||
|
|
||||||
# --------------------------
|
# --------------------------
|
||||||
# initiales Spiel bauen
|
# initiales Spiel bauen
|
||||||
@ -41,5 +51,4 @@ test: input.o game.o unit_tests.c
|
|||||||
# --------------------------
|
# --------------------------
|
||||||
# Clean
|
# Clean
|
||||||
# --------------------------
|
# --------------------------
|
||||||
clean:
|
|
||||||
del /f *.o *.exe
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user