Compare commits

..
52 Commits
Author SHA1 Message Date
zidanmo99094 01d27db3fa test 2026-10-30 23:00:08 +01:00
zidanmo99094 b12784e0fe txt 2026-10-30 22:56:53 +01:00
zidanmo99094 8909443f50 txt 2026-10-30 22:56:04 +01:00
zidanmo99094 aa36943cb2 test 2026-10-30 22:51:20 +01:00
zidanmo99094 7f58ec3e92 test 2026-10-30 22:48:27 +01:00
zidanmo99094 a04771cf11 tttt 2026-10-30 22:45:42 +01:00
zidanmo99094 49132b1e47 testt 2026-10-30 22:43:27 +01:00
zidanmo99094 f732b3edf9 ttt 2026-10-30 15:25:53 +01:00
zidanmo99094 c859d76447 test 2026-10-30 15:24:24 +01:00
zidanmo99094 561fd213b6 test 2026-10-30 15:23:50 +01:00
zidanmo99094 3c43aca7b1 tt 2026-10-30 15:23:00 +01:00
zidanmo99094 49f1a06e02 test 2026-10-30 15:21:29 +01:00
zidanmo99094 2f0857c711 testt 2026-10-30 15:18:54 +01:00
zidanmo99094 b4ee9ae4e4 tt 2026-10-30 15:18:08 +01:00
zidanmo99094 29551521f0 test 2026-10-30 15:11:20 +01:00
zidanmo99094 b9c4545cc0 tst1 2026-10-30 15:08:56 +01:00
zidanmo99094 edf465fd79 tst 2026-10-30 15:07:49 +01:00
zidanmo99094 ae2024266a txt3 2026-10-30 15:02:56 +01:00
zidanmo99094 9c29e702e9 txt2 2026-10-30 15:01:05 +01:00
zidanmo99094 45a30468f7 txt1 2026-10-30 14:58:59 +01:00
zidanmo99094 cb0bbc68de txt 2026-10-30 14:58:09 +01:00
zidanmo99094 580e84491d test 2026-10-30 14:50:36 +01:00
zidanmo99094 b732b3d526 test 2026-10-30 14:46:33 +01:00
zidanmo99094 b6f873833d test 2026-10-30 14:38:27 +01:00
kleinleinta105608 852ae19472 Anpassung input.c nach Unit Tests 2026-10-30 13:58:13 +01:00
kleinleinta105608 9e53289322 Merge branch 'main' of https://git.efi.th-nuernberg.de/gitea/kleinleinta105608/Informatik2-Praktikum-Wortsalat 2026-10-30 13:00:03 +01:00
kleinleinta105608 361e5ddaca Hauptfunktion und Anpassung Hilfsfunktion in input.c 2026-10-30 12:59:47 +01:00
zidanmo99094 825aa17877 test 2026-10-30 01:13:17 +01:00
zidanmo99094 fd8b643197 test 2026-10-30 01:12:27 +01:00
zidanmo99094 ebd16cedec test 2026-10-30 01:09:40 +01:00
zidanmo99094 408e58205a test 2026-10-30 01:08:54 +01:00
zidanmo99094 464c7ff1ad test 2026-10-30 01:05:15 +01:00
zidanmo99094 b78f7ac560 test 2026-10-30 01:03:14 +01:00
zidanmo99094 2ef856d08a test 2026-10-30 01:00:30 +01:00
zidanmo99094 ad2984a808 test 2026-10-30 00:52:24 +01:00
zidanmo99094 0d0ab8ab7e Merge branch 'main' of https://git.efi.th-nuernberg.de/gitea/kleinleinta105608/Informatik2-Praktikum-Wortsalat 2026-10-30 00:47:09 +01:00
zidanmo99094 4c76932472 txt 2026-10-27 12:48:56 +01:00
zidanmo99094 ef95895501 txt 2026-10-27 12:48:19 +01:00
kleinleinta105608 6c5710f2f1 Merge branch 'main' of https://git.efi.th-nuernberg.de/gitea/kleinleinta105608/Informatik2-Praktikum-Wortsalat 2026-10-27 12:46:42 +01:00
kleinleinta105608 def3034ede Hilfsfunktion in input.c 2026-10-27 12:46:37 +01:00
zidanmo99094 fb4211872e text 2026-10-27 12:37:21 +01:00
zidanmo99094 70c6635991 text 2026-10-27 12:24:34 +01:00
zidanmo99094 213103dad0 text 2026-10-27 12:06:41 +01:00
kleinleinta105608 c3e875f493 Spielinitialisierung in main.c und Makefile Target wordsalad_myversion hinzugefügt 2026-10-26 00:49:47 +01:00
kleinleinta105608 fbd986c66f Wörter geändert 2026-10-25 00:40:54 +02:00
zidanmo99094 2100c8da2c Wolf hinzugefuegt 2026-10-22 16:02:48 +02:00
zidanmo99094 1ae5e39309 Merge-Konflikt gelöst 2026-10-22 15:56:10 +02:00
zidanmo99094 a297e25d94 test 2026-10-22 15:44:19 +02:00
zidanmo99094 df5c3e2ed0 test 2026-10-21 20:09:50 +02:00
zidanmo99094 49e4f22a22 test 2026-10-21 19:43:39 +02:00
zidanmo99094 f1fad264c8 test 2026-10-20 12:42:25 +02:00
Anja Freudenreich 450697aac9 updating repo 2026-10-20 12:12:50 +02:00
7 changed files with 148 additions and 11 deletions

No files matched your search

+53 -6
View File
@@ -6,12 +6,59 @@
#define MAX_RAND_TRIES_PER_WORD 10
#define EMPTY_CHAR 0
//TODO: Spiellogik implementieren:
/* * Wörter aus der Wortliste zufällig horizontal oder vertikal platzieren
* restliche Felder mit zufälligen Buchstaben füllen */
// 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 gridSize, char words[][100], unsigned int wordCount)
{
// 1. Spielfeld initialisieren
memset(salad, EMPTY_CHAR, MAX_SEARCH_FIELD_LEN * MAX_SEARCH_FIELD_LEN);
int placedWordsCount = 0;
// 2. Wörter im Spielfeld platzieren
for (unsigned int i = 0; i < wordCount; i++) {
int len = (int)strlen(words[i]);
// Wörter überspringen, die leer oder zu lang für das Suchfeld (gridSize) sind
if (len == 0 || (unsigned int)len > gridSize) continue;
for (int attempt = 0; attempt < MAX_RAND_TRIES_PER_WORD; attempt++) {
Direction dir = (rand() % 2 == 0) ? DIR_HORIZONTAL : DIR_VERTICAL;
int dr = (dir == DIR_VERTICAL) ? 1 : 0; // Zeilensprung
int dc = (dir == DIR_HORIZONTAL) ? 1 : 0; // Spaltensprung
// Startkoordinaten innerhalb der gridSize wählen
int row = rand() % (gridSize - (dir == DIR_VERTICAL ? len - 1 : 0));
int col = rand() % (gridSize - (dir == DIR_HORIZONTAL ? len - 1 : 0));
// Kollisionsprüfung
int canPlace = 1;
for (int k = 0; k < len; k++) {
char current = salad[row + k * dr][col + k * dc];
if (current != EMPTY_CHAR && current != words[i][k]) {
canPlace = 0;
break;
}
}
// Wort ins Spielfeld eintragen
if (canPlace) {
for (int k = 0; k < len; k++) {
salad[row + k * dr][col + k * dc] = words[i][k];
}
placedWordsCount++;
break;
}
}
}
// 3. Verbleibende leere Felder innerhalb der gridSize auffüllen
for (unsigned int r = 0; r < gridSize; r++) {
for (unsigned int c = 0; c < gridSize; c++) {
if (salad[r][c] == EMPTY_CHAR) {
salad[r][c] = 'A' + (rand() % 26);
}
}
}
return placedWordsCount;
}
+9 -1
View File
@@ -3,8 +3,16 @@
#include "input.h"
#ifndef MAX_SEARCH_FIELD_LEN
#define MAX_SEARCH_FIELD_LEN 100
#endif
int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen, const char words[][MAX_WORD_LEN], unsigned int wordCount);
typedef enum {
DIR_HORIZONTAL = 0,
DIR_VERTICAL = 1
} Direction;
// Reihenfolge: salad, gridSize, words, wordCount
int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int gridSize, char words[][100], unsigned int wordCount);
#endif
+68 -2
View File
@@ -2,11 +2,77 @@
#include <string.h>
#include <ctype.h>
// TODO:
// TODO: erledigt
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
char* readSingleWord(FILE *file, char *destination, int maxLen)
{
char buffer[256];
int ch;
int bufIndex = 0;
// Alle Trennzeichen überspringen, bis ein echter Buchstabe kommt
while ((ch = fgetc(file)) != EOF)
{
// Prüfen der Buchstaben
if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'))
{
// Wenn Kleinbuchstabe, in Großbuchstabe umwandeln
if (ch >= 'a' && ch <= 'z')
{
ch = ch - 32;
}
buffer[bufIndex] = ch;
bufIndex++;
break;
}
}
if (ch == EOF)
{
return NULL;
}
// Den Rest des Wortes einlesen (bricht bei Kommas, Leerzeichen etc. ab)
while ((ch = fgetc(file)) != EOF && ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')))
{
if (bufIndex < 255)
{
if (ch >= 'a' && ch <= 'z')
{
ch = ch - 32;
}
buffer[bufIndex] = ch;
bufIndex++;
}
}
// Zwischenspeicher abschließen
buffer[bufIndex] = '\0';
// Sicheres Kopieren in das Ziel-Array
strncpy(destination, buffer, maxLen - 1);
destination[maxLen - 1] = '\0';
return destination;
}
// Read words from file and store in 'words' array
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
{
unsigned int count = 0;
// Schleife läuft, solange noch Platz im Array ist
while (count < maxWordCount)
{
if (readSingleWord(file, words[count], MAX_WORD_LEN) != NULL)
{
if (strlen(words[count]) > 0) // Prüfen, ob das Wort nicht leer ist
{
count++; // nächstes Wort
}
}
else
{
break; // Bei Dateiende wird die Schleife abgebrochen
}
}
return count;
}
+10 -1
View File
@@ -6,6 +6,7 @@
#define MAX_NUMBER_OF_WORDS 100
#define SALAD_SIZE 20
#define WINDOW_WIDTH 800 //Breite Spielfenster 800 Pixel
int main(int argc, char *argv[])
{
@@ -36,10 +37,18 @@ int main(int argc, char *argv[])
// Create the word salad by placing words into grid
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
// TODO:
// TODO: erledigt
// Check if all words were successfully placed
// Start the game if successful
// error message if some words couldn't be placed
if (placedWords == wordCount) //wenn alle Wörter erfolgreicht plaziert sind
{
startGame(wordSalad, SALAD_SIZE, words, wordCount, WINDOW_WIDTH); //Startet das Spiel
}
else
{
printf("Fehler: Es konnten nicht alle Wörter plaziert werden\n"); //Gibt Fehlermeldung aus
}
}
else
+7
View File
@@ -22,6 +22,13 @@ codefolder = .
wordsalad_initial:
$(CC) -o wordsalad_initial -L. $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
# --------------------------
# meine Version
# --------------------------
wordsalad_myversion: main.o graphicalGame.o $(BINARIES)/libraylib.a
$(CC) $(CFLAGS) -o wordsalad_myversion main.o graphicalGame.o $(BINARIES)/libwordsalad.a $(BINARIES)/libraylib.a $(LDFLAGS)
# --------------------------
# Normales Spiel bauen
# --------------------------
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -2,4 +2,4 @@ Yeti,Nessie Werwolf; Vampir
Monster
Hydra;Frankenstein
Dracula;KingKong;Gremlin;Kobold,Hexe;Poltergeist
Gespenst, Oger, Maus
Gespenst, Oger