Compare commits

...
18 Commits
Author SHA1 Message Date
deschnerja104273 117d041da2 Vervollständigung weniger Kommentare in game und input 2026-10-23 10:44:49 +02:00
dehmfl103364 38864ec511 Finale Aenderungen 2026-10-16 20:49:28 +02:00
dehmfl103364 da674a4ef6 Merge branch 'InputImplementierung' 2026-10-16 20:35:42 +02:00
dehmfl103364 00913fe318 Makefile für Input und Game 2026-10-16 20:25:37 +02:00
dehmfl103364 5b6eae4c18 Merge remote-tracking branch 'origin/main' into InputImplementierung
Muss machen wegen Branchmerge
2026-10-16 20:16:09 +02:00
dehmfl103364 fe390a6f5f Input fertig mit Makefile für Input 2026-10-16 20:11:55 +02:00
deschnerja104273 eb161c9b2a Merge remote-tracking branch 'origin/main' 2026-10-16 10:59:37 +02:00
deschnerja104273 58b94eb417 Implementierung der Gamelogic in Main und Test für Game im Makefile 2026-10-16 10:54:41 +02:00
dehmfl103364 0ad0165c1a README First Change 2026-10-14 14:32:06 +02:00
dehmfl103364 8f0b159412 Merge branch 'main' of https://git.efi.th-nuernberg.de/gitea/dehmfl103364/JaminUndFlo_I2_Pr_Wordsalad 2026-10-14 14:27:57 +02:00
dehmfl103364 c54efdbf43 README Aufgabenteilung 2026-10-14 14:27:46 +02:00
deschnerja104273 1cb59edc7a Test um die Verbindung mit Clion von Jamin zu testen. 2026-10-13 23:38:50 +02:00
deschnerja104273 ccf6bde0fa Merge remote-tracking branch 'origin/main' 2026-10-13 23:34:56 +02:00
deschnerja104273 405b6d03eb Test um die Verbindung mit Clion von Jamin zu testen. 2026-10-13 23:25:04 +02:00
dehmfl103364 ce89b21fe1 README.md aktualisiert 2026-10-13 20:22:57 +02:00
dehmfl103364 93856a7197 README hinzugefügt 2026-10-13 20:19:13 +02:00
dehmfl103364 a243117127 BranchTestFlo 2026-10-13 19:50:35 +02:00
deschnerja104273 98944672a1 Test: Verbindung zum Gruppenrepository 2026-10-09 11:11:33 +02:00
5 changed files with 167 additions and 4 deletions

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
# Aufgabenteilung
Jamin:
Game
Flo:
Input
Main
Schwarzes Brett :shipit: :
+101
View File
@@ -6,6 +6,9 @@
#define MAX_RAND_TRIES_PER_WORD 10
#define EMPTY_CHAR 0
// Funktion die eine zufällige Zahl von 0-range zurückgibt
int randomNumberInRange(unsigned int range);
//TODO: Spiellogik implementieren:
/* * Wörter aus der Wortliste zufällig horizontal oder vertikal platzieren
* restliche Felder mit zufälligen Buchstaben füllen */
@@ -13,5 +16,103 @@
// 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)
{
//Rückgabewert ist die Anzahl an platzierten Wörtern
srand(time(NULL));
int placedWordsSuccess = 0;
//Array auf Spielfläche initialisieren mit leerem Char
for (int i = 0; i < searchFieldLen; i++) {
for (int u = 0; u < searchFieldLen; u++) {
salad[i][u] = EMPTY_CHAR;
}
}
// Schleife bis alle Wörter durchlaufen
for (int wordToBePlaced = 0; wordToBePlaced < wordCount; wordToBePlaced++) {
int triesPerWord = 1;
while (triesPerWord <= MAX_RAND_TRIES_PER_WORD) {
unsigned int xPosition = randomNumberInRange(searchFieldLen-1);
unsigned int yPosition = randomNumberInRange(searchFieldLen-1);
if (salad[yPosition][xPosition] != EMPTY_CHAR) {
triesPerWord++;
continue;
}
int putWordHorizontal = randomNumberInRange(1);
//Horizontal einsetzen
if (putWordHorizontal) {
int writePossible = 1;
//Schleife um alle Stellen auf EMPTY_SPACE zu prüfen
for (int t = 0; t < MAX_WORD_LEN; t++) {
if (words[wordToBePlaced][t] == EMPTY_CHAR) break;
if (xPosition + t >= searchFieldLen) {
triesPerWord++;
writePossible = 0;
break;
}
if (salad[yPosition][xPosition + t] != EMPTY_CHAR) {
triesPerWord++;
writePossible = 0;
break;
}
}
// Nach Prüfung Wort einsetzen
if (writePossible) {
for (int t = 0; t < MAX_WORD_LEN; t++) {
if (words[wordToBePlaced][t] == EMPTY_CHAR) break;
salad[yPosition][xPosition + t] = words[wordToBePlaced][t];
}
placedWordsSuccess++;
break;
}
}
// Sonst vertikal einsetzen
else {
int writePossible = 1;
//Auf EMPTY_SPACE prüfen
for (int t = 0; t < MAX_WORD_LEN; t++) {
if (words[wordToBePlaced][t] == EMPTY_CHAR) break;
if (yPosition + t >= searchFieldLen) {
triesPerWord++;
writePossible = 0;
break;
}
if (salad[yPosition + t][xPosition] != EMPTY_CHAR) {
triesPerWord++;
writePossible = 0;
break;
}
}
//Einsetzen, wenn Felder frei
if (writePossible) {
for (int t = 0; t < MAX_WORD_LEN; t++) {
if (words[wordToBePlaced][t] == EMPTY_CHAR) break;
salad[yPosition + t][xPosition] = words[wordToBePlaced][t];
}
placedWordsSuccess++;
break;
}
}
}
}
//Restliche Felder mit Random-Buchstaben füllen
for (int zeile = 0; zeile < searchFieldLen; zeile++) {
for (int spalte = 0; spalte < searchFieldLen; spalte++) {
if (salad[zeile][spalte] == EMPTY_CHAR) {
salad[zeile][spalte] = (char)(randomNumberInRange(25)+65); //Buchstabe (ASCII) 65 - 90
}
}
}
return placedWordsSuccess; //Anzahl eingeschriebener Wörter zurückgeben
}
int randomNumberInRange(unsigned int range) {
int number = (rand() % (range+1));
return number;
}
+33 -3
View File
@@ -6,7 +6,37 @@
// 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 lineRead[MAX_LINE_LEN] = {};
char *splitters = ",; \n";
int wordsRead = 0;
while(fgets(lineRead,MAX_LINE_LEN,file) != NULL && wordsRead < maxWordCount){
char *token = strtok(lineRead, splitters);
while(token != NULL && wordsRead < maxWordCount){
strcpy(words[wordsRead],token);
//Kleinbuchstaben -> Grossbuchstaben
int len = strlen(words[wordsRead]);
for(int i = 0; i < len; i++){
if(islower(words[wordsRead][i])){
words[wordsRead][i] = toupper(words[wordsRead][i]);
}
}
wordsRead++;
token = strtok(NULL, splitters);
}
}
return wordsRead;
}
}
+6 -1
View File
@@ -40,7 +40,12 @@ int main(int argc, char *argv[])
// Check if all words were successfully placed
// Start the game if successful
// error message if some words couldn't be placed
if(wordCount == placedWords){
startGame(wordSalad,SALAD_SIZE,words,wordCount,800);
}else{
printf("error. not enough words could be placed");
return 0;
}
}
else
{
+17
View File
@@ -22,6 +22,23 @@ codefolder = .
wordsalad_initial:
$(CC) -o wordsalad_initial -L. $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
#--------------
# Mein Test
#--------------
my_wordsalad_input: input.o $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a
$(CC) $(CFLAGS) -o my_wordsalad_input input.o $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
final_wordsalad: main.o game.o input.o $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a
$(CC) $(CFLAGS) -o final_wordsalad main.o game.o input.o $(BINARIES)/libraylib.a $(LDFLAGS) $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
# --------------------------
# NUR Game Test
# --------------------------
wordsalad_mein_game: game.o input.o $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a
$(CC) $(CFLAGS) -o wordsalad_mein_test game.o input.o $(BINARIES)/libraylib.a $(LDFLAGS) $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
# --------------------------
# Normales Spiel bauen
# --------------------------