Compare commits

...
3 Commits
Author SHA1 Message Date
glockeel104125 5e7e5cabc7 newProgress 29.10 2026-10-29 11:08:56 +01:00
glockeel104125 ffae8329be paar gedanken dazu geschrieben 2026-10-22 11:13:53 +02:00
glockeel104125 ebc3d20d4e 1Test 2026-10-22 11:06:56 +02:00
+56
View File
@@ -1,5 +1,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "input.h" #include "input.h"
#include "game.h" #include "game.h"
#include "graphicalGame.h" #include "graphicalGame.h"
@@ -36,8 +37,63 @@ int main(int argc, char *argv[])
// Create the word salad by placing words into grid // Create the word salad by placing words into grid
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount); placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
// – Platzieren Sie die Wörter aus der Wörterliste zufällig horizontal oder vertikal im
// Spielfeld.
for(unsigned int index = 0; index <= wordCount -1; index++)
{
int coordx = 0;
int coordy = 0;
int dir = 0; //0 = horizontal 1 = vertikal
coordx = rand() % SALAD_SIZE;
coordy = rand() % SALAD_SIZE;
dir = rand() % 2;
if (wordSalad[coordx][coordy] == 0){
//checken wie lang index wort ist
unsigned int wordLength = strlen(words[index]);
//checken ob von coord aus in dir richtung genügend platz ist
switch (dir){
case 0: // Horizontal
if(coordx + wordLength < SALAD_SIZE){
}else {break};
// 1. Prüfen, ob das Wort horizontal ins Spielfeld passt
// 2. Prüfen, ob alle benötigten Zellen frei sind
// 3. Wenn ja: Wort platzieren
// 4. Wenn nein: neue Position versuchen
break;
case 1: // Vertikal
// 1. Prüfen, ob das Wort vertikal ins Spielfeld passt
// 2. Prüfen, ob alle benötigten Zellen frei sind
// 3. Wenn ja: Wort platzieren
// 4. Wenn nein: neue Position versuchen
break;
}
} else {
--index;
}
anschauen ob position leer ist
falls ja, länge des wortes anschauen, in die dir die länge gehen und checken ob alles leer ist, falls ja plazieren, falls nein neue coordinate
falls nein, neue coordinate ohne index zu erhöhen
}
// irgendwie array an pos 1 0 laden und dann von 1 0 bis 1 X bis das wort leer ist, also bis ein 0 char eingeladen wird und dann länge checken, dann mit der länge checken welche pos legit sind und dann random auswählen
// spielfeld ist 20x20 array, also zufällige koordinate auswählen, richtung auswählen
// – Füllen Sie die übrigen Felder mit zufälligen Buchstaben.
// – Definieren Sie ggf. geeignete Datentypen (z.B. enum für Platzierungsrichtung
// etc.).test sieht man das hier??
// TODO: // TODO:
// Check if all words were successfully placed // Check if all words were successfully placed
// Start the game if successful // Start the game if successful
// error message if some words couldn't be placed // error message if some words couldn't be placed