53 Commits
Author SHA1 Message Date
hofmannjo99187 7f0f3ceeb9 vorgeführt 2025-11-11 10:07:33 +01:00
hofmannjo99187 9ef55c581f added comments to input.c and tested the programm again 2025-11-11 07:58:07 +01:00
hofmannjo99187 d00feb8401 testing 2025-11-04 18:55:20 +01:00
hofmannjo99187 b26202cd9b testing 2025-11-04 18:27:56 +01:00
hofmannjo99187 25a13b1dca removed testing statement in input.c 2025-11-04 17:44:22 +01:00
hofmannjo99187 398936b789 removed testing statement in input.c 2025-11-04 17:43:48 +01:00
hofmannjo99187 cba52d17c5 testet if everything works (it does) 2025-11-04 17:39:23 +01:00
hofmannjo99187 42a5143e9a testing-statements entfernt 2025-11-04 17:03:59 +01:00
hofmannjo99187 acc14b49d8 Funktionaler Wortsalat mit Test-printf()-anweisungen 2025-11-04 16:48:22 +01:00
hofmannjo99187 6027c2a061 ausbesserungen aus stunde 2025-11-04 11:20:21 +01:00
hofmannjo99187 ed22736f68 debugging, placeWord noch fehlerhaft 2025-11-04 10:42:35 +01:00
hofmannjo99187 7146174e78 removed unused variable in input.c 2025-11-04 09:43:12 +01:00
hofmannjo99187 d097819ef9 durchführen Tests 2025-11-04 08:57:12 +01:00
hofmannjo99187 5e9132a48b test durchgeführt 2025-11-03 22:13:38 +01:00
hofmannjo99187 5d1c8ac8a5 überprüfungen in game.c angepasst so das ASCII zeichen zwischen Groß- und Kleinbuchstanben ausgeschlossen 2025-10-31 02:28:42 +01:00
hofmannjo99187 7414849901 input passes all tests 2025-10-31 02:10:20 +01:00
hofmannjo99187 46b6efbd69 began developing concept for readWords 2025-10-31 01:50:00 +01:00
hofmannjo99187 1affb13041 return 0 if file not found 2025-10-31 01:13:56 +01:00
hofmannjo99187 63cafdbc0c angefangen input neu zu schreiben 2025-10-31 01:09:29 +01:00
hofmannjo99187 543ba65b7e test durchgeführt 2025-10-31 00:53:26 +01:00
hofmannjo99187 9747bc4530 test druchgeführt 2025-10-30 17:25:39 +01:00
Florian Wetzel 30f601d4df Anpassung Darstellung 2025-10-30 17:05:38 +01:00
hofmannjo99187 f89019437f makefile korrektur in main übernommen 2025-10-30 15:43:58 +01:00
hofmannjo99187 eb77a4d1b8 leerzeichen vor input.c in line 33 im makefile 2025-10-30 15:42:36 +01:00
hofmannjo99187 4ee5fd7648 komentar geändert 2025-10-30 15:27:57 +01:00
Florian Wetzel 4892e33b76 Änderungen Flo für Mac Macefile 2025-10-30 15:06:44 +01:00
Florian Wetzel 5442ecb0bc Anpassungen main.c und input.c in Start_Mac 2025-10-30 14:36:49 +01:00
hofmannjo99187 a5c1510745 backup funktionaler stand 2025-10-30 14:29:50 +01:00
hofmannjo99187 d10fcd6db2 Merge branch 'main' of https://git.efi.th-nuernberg.de/gitea/hofmannjo99187/Wortsalat 2025-10-30 14:16:22 +01:00
hofmannjo99187 4fe7805c09 scheinbar funktionales spiel speicher 2025-10-30 14:16:01 +01:00
Florian Wetzel 654aebac4d Anpassungen game.c in Start_Mac 2025-10-30 14:00:08 +01:00
hofmannjo99187 10598b0f8e librarys outside of folder 2025-10-30 13:56:52 +01:00
hofmannjo99187 a0ff1937bd makefile geupdated 2025-10-28 11:19:27 +01:00
hofmannjo99187 ad8144ed08 auskommentieren des initialen makebefehls 2025-10-28 11:09:34 +01:00
hofmannjo99187 6b89426f7f sreensize adjustment 2025-10-28 11:08:55 +01:00
hofmannjo99187 194636e728 makefile zum laufen gebracht 2025-10-28 11:06:44 +01:00
hofmannjo99187 c0b779f7fa verändertes makefile speichern 2025-10-28 10:40:27 +01:00
hofmannjo99187 6b887b60c4 makefile um libraylib.a ergänzt 2025-10-28 10:27:48 +01:00
hofmannjo99187 7a1b9d6d24 Merge branch 'branch1_Jonas' 2025-10-28 09:40:20 +01:00
hofmannjo99187 7dc036df15 changed two comments 2025-10-28 09:30:39 +01:00
Jens Burger 771cc1706f input.c written 2025-10-28 09:29:44 +01:00
hofmannjo99187 d1fd9b38ea fixed logic error in 'checkIfPositionIsFree' in game.c and updated some comments in game.c and main.c 2025-10-28 08:46:26 +01:00
hofmannjo99187 2f625c98b9 funktion showWordSalad ergänzt, fehler in placeRandomLetters korrigiert 2025-10-25 21:45:56 +02:00
hofmannjo99187 f407d5a36f funktion placeRandomLetters für createWordSalad ergänzt 2025-10-25 21:37:36 +02:00
hofmannjo99187 ea373b6bad funktion createWordSalad in game.c fertiggestellt, noch ungetestet 2025-10-25 21:07:02 +02:00
hofmannjo99187 b15fb04b88 funktion createWordSalad in game.c begonnen 2025-10-25 17:47:28 +02:00
Jens Burger 7245877786 added readwords() 2025-10-25 16:50:57 +02:00
hofmannjo99187 f7a6e56257 Erstellen eigenes Makefile-Target wordsalad_myversion 2025-10-24 00:41:00 +02:00
hofmannjo99187 9e27997e44 In main.c die Initialisierung des Spiels ergänzt 2025-10-24 00:23:29 +02:00
hofmannjo99187 20c957cb73 comit um sicher zu gehen das alles da ist, keine veränderungen nur durchfühern des ersten tests 2025-10-21 23:23:52 +02:00
hofmannjo99187 39d08d8609 Entfernen aller git-testenden kommentare 2025-10-21 20:06:25 +02:00
Florian Wetzel 5fe65f3210 Aenderung Flo 2025-10-21 11:06:07 +02:00
hofmannjo99187 5fc41568ad kommentar in game.c abgeändert 2025-10-21 10:59:45 +02:00
26 changed files with 10491 additions and 20 deletions
+168
View File
@@ -10,14 +10,182 @@
/* * Wörter aus der Wortliste zufällig horizontal oder vertikal platzieren
* restliche Felder mit zufälligen Buchstaben füllen */
// enum to make it more clear what de current orientation is
typedef enum
{
HORIZONTAL,
VERTIKAL
} orientation;
// new struct for handing over the entire wordPosition
// alignment is HORIZONTAL or VERTICAL
// rowOrColumn is the int of the colum or row the word is suposed to be placed in
// startingCell is the int of where in the row/colum the first leter of the word suposed to be placed
typedef struct
{
orientation alignment;
unsigned int rowOrColumn;
unsigned int startingCell;
} wordPosition;
// Choses a random Position for the current Word
wordPosition choserandomPosition(unsigned int searchFieldLen, unsigned int wordLength)
{
wordPosition position = {0, 0, 0};
srand(time(NULL));
position.alignment = rand()%(VERTIKAL - HORIZONTAL + 1) + HORIZONTAL;
position.rowOrColumn = rand()%(searchFieldLen);
position.startingCell = rand()%(searchFieldLen - wordLength);
return position;
}
// Checks if the current Position is free
// returns 1 if the Position is free
// returns 0 if the Position is occupied
int checkIfPositionIsFree(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], wordPosition position,unsigned int wordLength, unsigned int serchFieldLen)
{
int i = 0;
int letterFound = 0;
int positionfree = 0;
if (position.alignment == HORIZONTAL)
{
// checking to see if position is free
// by scanning each column in the given row
for (i = position.startingCell; (i < serchFieldLen) && !(letterFound); i++)
{
if ((salad[position.rowOrColumn][i] >= 'A') && (salad[position.rowOrColumn][i] <= 'z'))
{
letterFound = 1;
}
}
}
else if (position.alignment == VERTIKAL)
{
// checking to see if position is free
// by scanning each row in the given column
for (i = position.startingCell; (i < serchFieldLen) && !(letterFound); i++)
{
if ((salad[i][position.rowOrColumn] >= 'A') && (salad[i][position.rowOrColumn] <= 'z'))
{
letterFound = 1;
}
}
}
positionfree = !letterFound;
return positionfree;
}
// Places the current word into the
// selected position
// returns 1 if sucessfull
int placeWord(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], wordPosition position, const char currentWord[], unsigned int currentWordLen, unsigned int serchFieldLen)
{
int i = 0;
if (position.alignment == HORIZONTAL)
{
for (i = position.startingCell; (i < serchFieldLen) && (i < currentWordLen); i++)
{
salad[position.rowOrColumn][i] = currentWord[i];
}
salad[position.rowOrColumn][i] = '\0';
}
else if (position.alignment == VERTIKAL)
{
for (i = position.startingCell; (i < serchFieldLen) && (i < currentWordLen); i++)
{
salad[i][position.rowOrColumn] = currentWord[i];
}
salad[i][position.rowOrColumn] = '\0';
}
return 1;
}
// Places random letters into the
// empty fields of the wordSalad
void placeRandomLetters(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
{
int i = 0;
int j = 0;
srand(time(NULL));
for (i = 0; i < searchFieldLen; i++)
{
for (j = 0; i < searchFieldLen; j++)
{
if ((salad[i][j] < 'A') && (salad[i][j] > 'z'))
{
salad[i][j] = rand()%('Z' - 'A' + 1) + 'A';
}
}
}
}
// Creates the word salad by placing words randomly and filling empty spaces
// returnes the number of sucessfully placed words
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 i = 0;
int j = 0;
int positionFound = 0;
int placedWords = 0;
char currentWord[MAX_WORD_LEN];
wordPosition currentWordPosition = {0,0,0};
for (i = 1; i <= wordCount; i++)
{
do
{
currentWordPosition = choserandomPosition(searchFieldLen, strlen(words[i]));
positionFound = checkIfPositionIsFree(salad, currentWordPosition, strlen(words[i]), searchFieldLen);
j++;
} while ((j < MAX_RAND_TRIES_PER_WORD) && !(positionFound));
if (positionFound)
{
strcpy(currentWord, words[i-1]);
placedWords += placeWord(salad, currentWordPosition, currentWord, strlen(currentWord), searchFieldLen);
}
}
placeRandomLetters(salad, searchFieldLen);
return placedWords;
}
// Prints the word salad to console
void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
{
int i = 0;
int j = 0;
for (i = 0; i < searchFieldLen; i++)
{
for (j = 0; i < searchFieldLen; j++)
{
printf("%c", salad[i][j]);
}
printf("\n");
}
}
+1
View File
@@ -403,6 +403,7 @@ static int allWordsFound(SearchWordPanel searchWordPanel)
// Main game loop where game is run and updated
static void gameLoop(const Vector2 screenSize, MouseSelection mouseSelection, CharSquarePanel squarePanel, SearchWordPanel searchWordPanel, const HelperMessage helperMsg, const WinMessage winMsg)
{
SetConfigFlags(FLAG_WINDOW_HIGHDPI);
InitWindow(screenSize.x, screenSize.y, "Word Salad"); // Initialize game window
SetTargetFPS(60);
+26
View File
@@ -2,11 +2,37 @@
#include <string.h>
#include <ctype.h>
#define MAX_BUFFER_LEN 256
// TODO:
// 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)
{
char buffer[MAX_BUFFER_LEN];
int count = 0;
char *teiler = ".,; !?\n";
if(file == NULL)
{
printf("Fehler beim Öffnen von words.txt!\n");
return -1;
}
while(fgets(buffer, MAX_LINE_LEN, file))
{
const char *wort = strtok(buffer, teiler);
while(wort != NULL && count < maxWordCount)
{
strncpy(words[count], wort, MAX_WORD_LEN-1);
words[count][MAX_WORD_LEN-1] = '\0';
count++;
wort = strtok(NULL, teiler);
}
}
return count;
}
+22 -1
View File
@@ -7,6 +7,13 @@
#define MAX_NUMBER_OF_WORDS 100
#define SALAD_SIZE 20
// selbstgeschriebene Definitionen:
// annahmen ist das windowWidth in pixeln gegeben
// werden muss, da auch andere funktionen wie
// createCharSquarePanel in Pixeln arbeiten
#define WINDOW_WIDTH 800
int main(int argc, char *argv[])
{
int exitCode = EXIT_SUCCESS;
@@ -36,10 +43,24 @@ int main(int argc, char *argv[])
// Create the word salad by placing words into grid
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
// TODO:
// DONE:
// Check if all words were successfully placed
// Start the game if successful
// error message if some words couldn't be placed
if (placedWords != wordCount)
{
// selbe error message wird auch von wordsalad_inital.exe ausgegeben,
// wenn diese einen fehler produziert
printf("Could only place %d of %d words.", placedWords, wordCount);
printf(" Possible solution is to choose a larger search field ...\n");
}
else
{
// annahme: windowWidth wird in Pixeln gesucht,
// da auch andere funktionen, wie createCharSquarePanel
// in Pixeln arbeiten
startGame(wordSalad, SALAD_SIZE, words, placedWords, WINDOW_WIDTH);
}
}
else
+18 -11
View File
@@ -1,22 +1,29 @@
CC = gcc
CFLAGS = -g -Wall
LDFLAGS = -framework OpenGL -framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Cocoa -framework CoreVideo
LDFLAGS = -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo
# Architektur automatisch erkennen (arm64 oder x86_64)
ARCH := $(shell uname -m)
BINARIES = ./macos-$(ARCH)
ifeq ($(ARCH),arm64)
BINARIES = ./macos-arm64
else
BINARIES = ./macos-x64
endif
raylib_folder = ./raylib
unityfolder = ./unity
# --------------------------
# initiales Spiel bauen
# eigenes Spiel bauen
# --------------------------
wordsalad_initial:
$(CC) -o wordsalad_initial $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
wordsalad_myversion: main.o graphicalGame.o $(BINARIES)/libwordsalad.a $(BINARIES)/libraylib.a
$(CC) $(CFLAGS) -o wordsalad_myversion main.c graphicalGame.c $(BINARIES)/libwordsalad.a $(BINARIES)/libraylib.a $(LDFLAGS)
# --------------------------
# Normales Spiel bauen
# --------------------------
wordsalad: main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a
all: main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a
$(CC) $(CFLAGS) -o wordsalad main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a $(LDFLAGS)
main.o: main.c
@@ -29,18 +36,18 @@ game.o: game.c
$(CC) -c $(CFLAGS) game.c
graphicalGame.o: graphicalGame.c
$(CC) -I$(raylibfolder) -c $(CFLAGS) graphicalGame.c
$(CC) -I$(raylib_folder) -c $(CFLAGS) graphicalGame.c
# --------------------------
# Unit Tests
# --------------------------
TEST_BIN = runTests
test: input.o game.o unit_tests.c $(BINARIES)/libunity.a
$(CC) -Wall -I$(unityfolder) -o $(TEST_BIN) input.o game.o unit_tests.c $(BINARIES)/libunity.a
test: input.o game.o unit_tests.c
$(CC) $(CFLAGS) -I$(unityfolder) -o $(TEST_BIN) input.o game.o unit_tests.c $(BINARIES)/libunity.a
# --------------------------
# Clean
# --------------------------
clean:
rm -f *.o wordsalad
rm -f *.o wordsalad wordsalad_myversion $(TEST_BIN)
+199 -2
View File
@@ -6,20 +6,217 @@
#define MAX_RAND_TRIES_PER_WORD 10
#define EMPTY_CHAR 0
//TODO: Spiellogik implementieren:
//DONE: Spiellogik implementieren:
/* * Wörter aus der Wortliste zufällig horizontal oder vertikal platzieren
* restliche Felder mit zufälligen Buchstaben füllen */
// enum to make it more clear what de current orientation is
typedef enum
{
HORIZONTAL,
VERTIKAL
} orientation;
// new struct for handing over the entire wordPosition
// alignment is HORIZONTAL or VERTICAL
// rowOrColumn is the int of the colum or row the word is suposed to be placed in
// startingCell is the int of where in the row/colum the first leter of the word suposed to be placed
typedef struct
{
orientation alignment;
unsigned int rowOrColumn;
unsigned int startingCell;
} wordPosition;
void initializeWordsalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
{
int i = 0;
int j = 0;
for (i = 0; i < searchFieldLen; i++)
{
for (j = 0; j < searchFieldLen; j++)
{
salad[i][j] = '=';
}
}
}
// Choses a random Position for the current Word
wordPosition choserandomPosition(unsigned int searchFieldLen, unsigned int wordLength)
{
wordPosition position = {0, 0, 0};
position.alignment = rand()%(VERTIKAL - HORIZONTAL + 1) + HORIZONTAL;
position.rowOrColumn = rand()%(searchFieldLen);
position.startingCell = rand()%(searchFieldLen - wordLength);
return position;
}
// Checks if the current Position is free
// returns 1 if the Position is free
// returns 0 if the Position is occupied
int checkIfPositionIsFree(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], wordPosition position,unsigned int wordLength, unsigned int serchFieldLen)
{
int i = 0;
int letterFound = 0;
int positionfree = 0;
if (position.alignment == HORIZONTAL)
{
// checking to see if position is free
// by scanning each column in the given row
for (i = position.startingCell; (i < serchFieldLen) && !(letterFound); i++)
{
if (((salad[position.rowOrColumn][i] >= 'A') && (salad[position.rowOrColumn][i] <= 'Z')) || ((salad[position.rowOrColumn][i] >= 'a') && (salad[position.rowOrColumn][i] <= 'z')))
{
letterFound = 1;
}
}
}
else if (position.alignment == VERTIKAL)
{
// checking to see if position is free
// by scanning each row in the given column
for (i = position.startingCell; (i < serchFieldLen) && !(letterFound); i++)
{
if (((salad[i][position.rowOrColumn] >= 'A') && (salad[i][position.rowOrColumn] <= 'z')) || ((salad[i][position.rowOrColumn] >= 'a') && (salad[i][position.rowOrColumn] <= 'z')))
{
letterFound = 1;
}
}
}
positionfree = !letterFound;
return positionfree;
}
// Places the current word into the
// selected position
// returns 1 if sucessfull
int placeWord(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], wordPosition position, const char currentWord[], unsigned int currentWordLen, unsigned int serchFieldLen)
{
int i = 0;
int j = 0;
if (position.alignment == HORIZONTAL)
{
for (i = position.startingCell; (i < serchFieldLen) && (currentWord[j] != '\0'); i++)
{
salad[position.rowOrColumn][i] = currentWord[j];
j++;
}
salad[position.rowOrColumn][i] = '\0';
}
else if (position.alignment == VERTIKAL)
{
for (i = position.startingCell; (i < serchFieldLen) && (currentWord[j] != '\0'); i++)
{
salad[i][position.rowOrColumn] = currentWord[j];
j++;
}
salad[i][position.rowOrColumn] = '\0';
}
return 1;
}
// Places random letters into the
// empty fields of the wordSalad
void placeRandomLetters(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
{
int i = 0;
int j = 0;
for (i = 0; i < searchFieldLen; i++)
{
for (j = 0; j < searchFieldLen; j++)
{
if ((salad[i][j] < 'A') || (salad[i][j] > 'z') || ((salad[i][j] < 'a') && (salad[i][j] > 'Z')))
{
salad[i][j] = rand()%('Z' - 'A' + 1) + 'A';
}
}
}
}
// Creates the word salad by placing words randomly and filling empty spaces
// returnes the number of sucessfully placed words
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 i = 0;
int j = 0;
int k = 0;
int positionFound = 0;
int placedWords = 0;
char nullWord[MAX_WORD_LEN];
char currentWord[MAX_WORD_LEN];
wordPosition currentWordPosition = {0,0,0};
for (k = 0; k < MAX_WORD_LEN; k++)
{
nullWord[k] = '\0';
}
srand(time(NULL));
initializeWordsalad(salad, searchFieldLen);
for (i = 1; i <= wordCount; i++)
{
j = 0;
strcpy(currentWord, nullWord);
strcpy(currentWord, words[i-1]);
do
{
currentWordPosition = choserandomPosition(searchFieldLen, strlen(currentWord));
positionFound = checkIfPositionIsFree(salad, currentWordPosition, strlen(currentWord), searchFieldLen);
j++;
} while ((j < MAX_RAND_TRIES_PER_WORD) && !(positionFound));
if (positionFound)
{
placedWords += placeWord(salad, currentWordPosition, currentWord, strlen(currentWord), searchFieldLen);
}
}
placeRandomLetters(salad, searchFieldLen);
return placedWords;
}
// Prints the word salad to console
void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
{
int i = 0;
int j = 0;
for (i = 0; i < searchFieldLen; i++)
{
for (j = 0; j < searchFieldLen; j++)
{
printf("%c", salad[i][j]);
}
printf("\n");
}
}
//Kommentar
Binary file not shown.
Binary file not shown.
+105
View File
@@ -2,11 +2,116 @@
#include <string.h>
#include <ctype.h>
// TODO:
// eine Funktion implementieren, die ein einzelnes Wort aus einer Textdatei (words.txt) einliest und als C-String zurückgibt.
/*
char *readSingleWord(FILE *file)
{
if (file == NULL)
{
return 0;
}
fgets(singleWordBuffer, MAX_LINE_LEN, file);
}
*/
// Read words from file and store in 'words' array
int readWords(FILE *file, char words[][MAX_WORD_LEN], unsigned int maxWordCount)
{
int currentlyInWord = 0;
int word = 0;
int wordChar = 0;
char currentChar = 0;
do
{
// get the next char from the file
currentChar = fgetc(file);
// if current char is a capital letter
// write it into the words array
if ((currentChar >= 'A') && (currentChar <= 'Z'))
{
if (!currentlyInWord)
{
currentlyInWord = 1;
}
words[word][wordChar] = currentChar;
wordChar++;
}
// if the current char is a lowercase letter
// change it to its capital version
// and write it into the words array
else if ((currentChar >= 'a') && (currentChar <= 'z'))
{
if (!currentlyInWord)
{
currentlyInWord = 1;
}
words[word][wordChar] = toupper(currentChar);
wordChar++;
}
// if the current char is NOT a letter
// the end of a word has been reached
// skip chars untill a new letter is found
else if (currentlyInWord)
{
words[word][wordChar] = '\0';
word++;
wordChar = 0;
currentlyInWord = 0;
}
} while (((currentChar != EOF) && (word <= maxWordCount)));
return word;
}
/*
#define MAX_BUFFER_LEN 256
// TODO?
// 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)
{
char buffer[MAX_BUFFER_LEN];
int count = 0;
char *teiler = ".,; !?\n";
if(file == NULL)
{
printf("Fehler beim Öffnen von words.txt!\n");
return -1;
}
while(fgets(buffer, MAX_LINE_LEN, file))
{
const char *wort = strtok(buffer, teiler);
while(wort != NULL && count < maxWordCount)
{
strncpy(words[count], wort, MAX_WORD_LEN-1);
words[count][MAX_WORD_LEN-1] = '\0';
count++;
wort = strtok(NULL, teiler);
}
}
return count;
}
*/
Binary file not shown.
+25 -1
View File
@@ -7,6 +7,13 @@
#define MAX_NUMBER_OF_WORDS 100
#define SALAD_SIZE 20
// selbstgeschriebene Definitionen:
// annahmen ist das windowWidth in pixeln gegeben
// werden muss, da auch andere funktionen wie
// createCharSquarePanel in Pixeln arbeiten
#define WINDOW_WIDTH 800
int main(int argc, char *argv[])
{
int exitCode = EXIT_SUCCESS;
@@ -36,10 +43,27 @@ int main(int argc, char *argv[])
// Create the word salad by placing words into grid
placedWords = createWordSalad(wordSalad, SALAD_SIZE, words, wordCount);
// TODO:
printf("placed Words: %d\n", placedWords);
printf("wordCount = %d\n", wordCount);
// DONE:
// Check if all words were successfully placed
// Start the game if successful
// error message if some words couldn't be placed
if (placedWords != wordCount)
{
// selbe error message wird auch von wordsalad_inital.exe ausgegeben,
// wenn diese einen fehler produziert
printf("Could only place %d of %d words.", placedWords, wordCount);
printf(" Possible solution is to choose a larger search field ...\n");
}
else
{
// annahme: windowWidth wird in Pixeln gesucht,
// da auch andere funktionen, wie createCharSquarePanel
// in Pixeln arbeiten
showWordSalad(wordSalad, SALAD_SIZE);
startGame(wordSalad, SALAD_SIZE, words, placedWords, WINDOW_WIDTH);
}
}
else
Binary file not shown.
+11 -4
View File
@@ -1,5 +1,5 @@
CC = gcc
CFLAGS = -g -Wall -I$(raylibfolder)
CFLAGS = -g -Wall
LDFLAGS = -lopengl32 -lgdi32 -lwinmm
BINARIES = ./windows
@@ -9,8 +9,15 @@ unityfolder = ./unity
# --------------------------
# initiales Spiel bauen
# --------------------------
wordsalad_initial:
$(CC) -o wordsalad_initial $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
#wordsalad_initial:
# $(CC) -o wordsalad_initial $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
# --------------------------
# eigenes Spiel bauen
# --------------------------
wordsalad_myversion: main.o graphicalGame.o $(BINARIES)/libwordsalad.a $(BINARIES)/libraylib.a
$(CC) -o wordsalad_myversion.exe main.c graphicalGame.c $(BINARIES)/libwordsalad.a $(BINARIES)/libraylib.a $(LDFLAGS)
# --------------------------
@@ -23,7 +30,7 @@ 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
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+5262
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
Hund,Katze; Maus
View File
+3
View File
@@ -0,0 +1,3 @@
Apfel
Banane
Kiwi
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.