Compare commits

...
13 Commits
Author SHA1 Message Date
kueblerni98916 81e477b893 input.c fix 2025-11-04 10:48:53 +01:00
gessnitzerlu98886 6654f3340a input . c erster test 2025-11-04 10:48:06 +01:00
kueblerni98916 df39903293 input.c fix 2025-11-04 10:40:34 +01:00
gessnitzerlu98886 89ac27f8d3 input . c erster test 2025-11-04 10:29:48 +01:00
gessnitzerlu98886 405ffbd805 input . c unvollständig 2025-11-04 09:12:06 +01:00
gessnitzerlu98886 a413f8fe7f neue makefile aus e mail kopiert 2025-10-28 14:52:29 +01:00
m_kol 18197c1a25 test 2025-10-28 14:52:01 +01:00
gessnitzerlu98886 444b5e1c65 neue makefile aus e mail kopiert 2025-10-21 14:37:57 +02:00
gessnitzerlu98886 2ae29be357 makelist test 2025-10-16 11:36:10 +02:00
kueblerni98916 b8f38f4025 Wario 2025-10-14 15:23:27 +02:00
kueblerni98916 0011a478b9 Wario 2025-10-14 15:22:53 +02:00
kueblerni98916 33cd3b23db Wario 2025-10-14 15:20:40 +02:00
gessnitzerlu98886 3174859064 sd 2025-10-14 15:18:02 +02:00
4 changed files with 85 additions and 11 deletions
+39
View File
@@ -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
View File
@@ -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;
}
+5 -2
View File
@@ -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
{ {
+5 -6
View File
@@ -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