Template
Compare commits
13
Commits
main
...
81e477b893
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81e477b893 | ||
|
|
6654f3340a | ||
|
|
df39903293 | ||
|
|
89ac27f8d3 | ||
|
|
405ffbd805 | ||
|
|
a413f8fe7f | ||
|
|
18197c1a25 | ||
|
|
444b5e1c65 | ||
|
|
2ae29be357 | ||
|
|
b8f38f4025 | ||
|
|
0011a478b9 | ||
|
|
33cd3b23db | ||
|
|
3174859064 |
@@ -0,0 +1,39 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
project(info2Praktikum_Wortsalat C)
|
||||||
|
|
||||||
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
|
||||||
|
# Include paths
|
||||||
|
include_directories(
|
||||||
|
Start_Windows
|
||||||
|
Start_Windows/raylib
|
||||||
|
Start_Windows/unity
|
||||||
|
)
|
||||||
|
|
||||||
|
# Executable target
|
||||||
|
add_executable(info2Praktikum_Wortsalat
|
||||||
|
Start_Windows/game.c
|
||||||
|
Start_Windows/graphicalGame.c
|
||||||
|
Start_Windows/input.c
|
||||||
|
Start_Windows/main.c
|
||||||
|
# Start_Windows/unity/unity.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# Link static libraries
|
||||||
|
target_link_libraries(info2Praktikum_Wortsalat
|
||||||
|
${CMAKE_SOURCE_DIR}/Start_Windows/windows/libraylib_mingw.a
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# words.txt beim Bauen automatisch ins Ausgabeverzeichnis kopieren
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_SOURCE_DIR}/Start_Windows/words.txt
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/words.txt
|
||||||
|
COPYONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Optional: falls du auf Windows bist und -lopengl32 o.ä. brauchst:
|
||||||
|
if (WIN32)
|
||||||
|
target_link_libraries(info2Praktikum_Wortsalat opengl32 gdi32 winmm)
|
||||||
|
endif()
|
||||||
+36
-3
@@ -6,7 +6,40 @@
|
|||||||
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
|
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
|
||||||
|
|
||||||
// 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)
|
||||||
|
{
|
||||||
|
char delimiter[] = ", ; \n";
|
||||||
|
unsigned int count = 0;
|
||||||
|
int shouldClose = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if (file == NULL)
|
||||||
|
{
|
||||||
|
file = fopen("words.txt", "r");
|
||||||
|
if (file == NULL)
|
||||||
|
{
|
||||||
|
printf("Fehler: Datei konnte nicht geöffnet werden!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
shouldClose = 1;
|
||||||
|
}
|
||||||
|
while (fgets(words[count], MAX_WORD_LEN, file) != NULL && count < maxWordCount)
|
||||||
|
{
|
||||||
|
char* token = strtok(words[count], delimiter);
|
||||||
|
while (token != NULL && count < maxWordCount)
|
||||||
|
{
|
||||||
|
for (char* p = token; *p; ++p)
|
||||||
|
p* = (char)toupper((unsigned char)*p);
|
||||||
|
strncpy(words[count], token, MAX_WORD_LEN - 1);
|
||||||
|
words[count][MAX_WORD_LEN - 1] = '\0';
|
||||||
|
count++;
|
||||||
|
|
||||||
|
token = strtok(NULL, delimiter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (shouldClose)fclose(file);
|
||||||
|
return(int)count;
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "graphicalGame.h"
|
#include "graphicalGame.h"
|
||||||
|
|
||||||
|
//halloooo
|
||||||
|
|
||||||
#define MAX_NUMBER_OF_WORDS 100
|
#define MAX_NUMBER_OF_WORDS 100
|
||||||
#define SALAD_SIZE 20
|
#define SALAD_SIZE 20
|
||||||
|
|
||||||
@@ -14,8 +16,9 @@ int main(int argc, char *argv[])
|
|||||||
// Check if the correct number of arguments is provided
|
// Check if the correct number of arguments is provided
|
||||||
if(argc != 2)
|
if(argc != 2)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: %s <path to file with search words>\n", argv[0]);
|
printf("Keine Datei angegeben – versuche Standarddatei 'words.txt'...\n");
|
||||||
exitCode = EXIT_FAILURE;
|
argv[1] = "words.txt";
|
||||||
|
argc = 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -g -Wall -I$(raylibfolder)
|
CFLAGS = -g -Wall
|
||||||
LDFLAGS = -lopengl32 -lgdi32 -lwinmm
|
LDFLAGS = -lopengl32 -lgdi32 -lwinmm
|
||||||
BINARIES = ./windows
|
BINARIES = ./windows
|
||||||
|
|
||||||
raylib_folder = ./raylib
|
raylibfolder = ./raylib
|
||||||
unityfolder = ./unity
|
unityfolder = ./unity
|
||||||
|
|
||||||
# --------------------------
|
# --------------------------
|
||||||
@@ -12,7 +12,6 @@ unityfolder = ./unity
|
|||||||
wordsalad_initial:
|
wordsalad_initial:
|
||||||
$(CC) -o wordsalad_initial $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
|
$(CC) -o wordsalad_initial $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
# --------------------------
|
# --------------------------
|
||||||
# Normales Spiel bauen
|
# Normales Spiel bauen
|
||||||
# --------------------------
|
# --------------------------
|
||||||
@@ -23,13 +22,13 @@ 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
|
||||||
|
|
||||||
graphicalGame.o: graphicalGame.c
|
graphicalGame.o: graphicalGame.c
|
||||||
$(CC) -I$(raylib_folder) -c $(CFLAGS) graphicalGame.c
|
$(CC) -I$(raylibfolder) -c $(CFLAGS) graphicalGame.c
|
||||||
|
|
||||||
# --------------------------
|
# --------------------------
|
||||||
# Unit Tests
|
# Unit Tests
|
||||||
@@ -43,4 +42,4 @@ test: input.o game.o unit_tests.c
|
|||||||
# Clean
|
# Clean
|
||||||
# --------------------------
|
# --------------------------
|
||||||
clean:
|
clean:
|
||||||
del /f *.o *.exe
|
del /f *.o *.exe
|
||||||
Reference in New Issue
Block a user