Template
Compare commits
15
Commits
main
...
cd48b739c1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd48b739c1 | ||
|
|
5232636f79 | ||
|
|
81e477b893 | ||
|
|
6654f3340a | ||
|
|
df39903293 | ||
|
|
89ac27f8d3 | ||
|
|
405ffbd805 | ||
|
|
a413f8fe7f | ||
|
|
18197c1a25 | ||
|
|
444b5e1c65 | ||
|
|
2ae29be357 | ||
|
|
b8f38f4025 | ||
|
|
0011a478b9 | ||
|
|
33cd3b23db | ||
|
|
3174859064 |
@@ -0,0 +1,40 @@
|
||||
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
|
||||
Start_Windows/unit_tests.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()
|
||||
+37
-2
@@ -6,7 +6,42 @@
|
||||
// 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
|
||||
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;
|
||||
}
|
||||
char line[MAX_LINE_LEN];
|
||||
while (fgets(line, sizeof(line), file) != NULL && count < maxWordCount)
|
||||
{
|
||||
char *token = strtok(line, 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 "graphicalGame.h"
|
||||
|
||||
//halloooo
|
||||
|
||||
#define MAX_NUMBER_OF_WORDS 100
|
||||
#define SALAD_SIZE 20
|
||||
|
||||
@@ -14,8 +16,9 @@ int main(int argc, char *argv[])
|
||||
// Check if the correct number of arguments is provided
|
||||
if(argc != 2)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s <path to file with search words>\n", argv[0]);
|
||||
exitCode = EXIT_FAILURE;
|
||||
printf("Keine Datei angegeben – versuche Standarddatei 'words.txt'...\n");
|
||||
argv[1] = "words.txt";
|
||||
argc = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
CC = gcc
|
||||
CFLAGS = -g -Wall -I$(raylibfolder)
|
||||
CFLAGS = -g -Wall
|
||||
LDFLAGS = -lopengl32 -lgdi32 -lwinmm
|
||||
BINARIES = ./windows
|
||||
|
||||
raylib_folder = ./raylib
|
||||
raylibfolder = ./raylib
|
||||
unityfolder = ./unity
|
||||
|
||||
# --------------------------
|
||||
@@ -12,7 +12,6 @@ unityfolder = ./unity
|
||||
wordsalad_initial:
|
||||
$(CC) -o wordsalad_initial $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
|
||||
|
||||
|
||||
# --------------------------
|
||||
# Normales Spiel bauen
|
||||
# --------------------------
|
||||
@@ -23,13 +22,13 @@ main.o: main.c
|
||||
$(CC) -c $(CFLAGS) main.c
|
||||
|
||||
input.o: input.c
|
||||
$(CC) -c $(CFLAGS)input.c
|
||||
$(CC) -c $(CFLAGS) input.c
|
||||
|
||||
game.o: game.c
|
||||
$(CC) -c $(CFLAGS) game.c
|
||||
|
||||
graphicalGame.o: graphicalGame.c
|
||||
$(CC) -I$(raylib_folder) -c $(CFLAGS) graphicalGame.c
|
||||
$(CC) -I$(raylibfolder) -c $(CFLAGS) graphicalGame.c
|
||||
|
||||
# --------------------------
|
||||
# Unit Tests
|
||||
|
||||
Reference in New Issue
Block a user