Compare commits

..
29 Commits
Author SHA1 Message Date
kegelmannni100026 d5587ef787 kommentare bei mac 2025-10-27 14:27:18 +01:00
stammjo100588 d61e703a42 Actual final commit? :> 2025-10-27 14:20:25 +01:00
starksa100587 5d8f68558e Target makefile 2025-10-27 14:17:42 +01:00
stammjo100588 00e3a50e8e One final Comment. And Goodbye World! 2025-10-27 14:05:58 +01:00
starksa100587 6ecb30fdfe Updated comments 2025-10-26 20:30:30 +01:00
stammjo100588 69decc037a |WORKING| All Test OK and Game runs! 2025-10-24 22:29:03 +02:00
stammjo100588 a1cb0f9626 Changed Input.c to solve All Remaining Tests 2025-10-24 22:16:55 +02:00
stammjo100588 000bc1ebdf Changed Input.c to solve Test 2 & 3 Aswell 2025-10-24 22:09:30 +02:00
kegelmannni100026 713355b1ac Game und input bei mac geändert
input bei win geändert

unittests: 3 SUCCESS 2 FAIL
2025-10-24 22:01:21 +02:00
stammjo100588 2a71e61f96 in game.c Version des CODES im Kommentar 2025-10-24 20:34:36 +02:00
stammjo100588 423506b80d revert 0a627137fa
revert in game.c steht jetzt bei TODO welche version der Code ist und welche Test er schafft
2025-10-24 18:31:43 +00:00
stammjo100588 0a627137fa in game.c steht jetzt bei TODO welche version der Code ist und welche Test er schafft 2025-10-24 20:26:16 +02:00
stammjo100588 22996a3363 Merge remote-tracking branch 'origin/main' 2025-10-24 20:17:47 +02:00
stammjo100588 5499bbcf2a Added fixes and new Mechanics to game.c to also Pass Test 4.
Also I killed the comments and wrote worse new ones
2025-10-24 20:17:00 +02:00
kegelmannni100026 14f6dd37f5 paar updates gemacht 2025-10-24 17:40:03 +02:00
stammjo100588 6b5ea6b989 Additional Changes to clean up 2025-10-22 21:43:13 +02:00
stammjo100588 a845fd7000 Added Schröder Changes to makefiles 2025-10-22 21:41:46 +02:00
stammjo100588 83f2ff4ec5 revert 8dc8b060f2
revert Added Schröder Changes to makefiles and 49 other files
2025-10-22 19:30:41 +00:00
stammjo100588 8a9bb66d8a revert 93da8ea94d
revert Added Schröder Changes to makefiles and 49 other files
2025-10-22 19:29:43 +00:00
stammjo100588 8dc8b060f2 Added Schröder Changes to makefiles and 49 other files 2025-10-22 21:14:37 +02:00
stammjo100588 93da8ea94d Added Schröder Changes to makefiles and 49 other files 2025-10-22 21:11:46 +02:00
kegelmannni100026 bda856b9db makefile neu
z16 selber geschrieben
2025-10-22 20:58:20 +02:00
kegelmannni100026 3899d22cde todo in main.c mit chat gemacht 2025-10-22 20:48:47 +02:00
starksa100587 dd79f00618 added 'include lib' 2025-10-22 18:57:23 +02:00
starksa100587 4fcf133a29 Spiel-Logik works maybe
noch nicht getestet
2025-10-22 18:36:01 +02:00
kegelmannni100026 a8e47993e6 Target Aufgabe
Makefile vervollständigt
2025-10-20 15:41:40 +02:00
kegelmannni100026 9c8841cb07 Target Aufgabe
- Main: Words checken und game starten (Versuch)
- Makefile: wordsalad_myversion grundlegend angelegt
2025-10-20 15:32:17 +02:00
kegelmannni100026 50533a4c86 Merge remote-tracking branch 'origin/main'
# Conflicts:
#	.idea/editor.xml
#	.idea/misc.xml
2025-10-20 14:59:16 +02:00
kegelmannni100026 0db585f97d Mac Ordner Changes 2025-10-20 14:58:36 +02:00
16 changed files with 298 additions and 127 deletions

No files matched your search

-96
View File
@@ -244,101 +244,5 @@
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=IfStdIsConstantEvaluatedCanBeReplaced/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StdIsConstantEvaluatedWillAlwaysEvaluateToConstant/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StringLiteralTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXPRESSION/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXTENDS_LIST/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_FOR_STMT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_PARAMETER/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_ARGUMENT/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_PARAMETER/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTIPLE_DECLARATION/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_TERNARY/@EntryValue" value="ALIGN_ALL" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_CLASS_DEFINITION/@EntryValue" value="1" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_DECLARATIONS/@EntryValue" value="0" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DECLARATION/@EntryValue" value="1" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DEFINITION/@EntryValue" value="1" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BREAK_TEMPLATE_DECLARATION/@EntryValue" value="LINE_BREAK" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CONTINUOUS_LINE_INDENT/@EntryValue" value="Double" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_ACCESS_SPECIFIERS_FROM_CLASS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CLASS_MEMBERS_FROM_ACCESS_SPECIFIERS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_COMMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_SIZE/@EntryValue" value="4" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_STYLE/@EntryValue" value="Space" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INITIALIZER_BRACES/@EntryValue" value="END_OF_LINE_NO_SPACE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INT_ALIGN_EQ/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INVOCABLE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_CODE/@EntryValue" value="2" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue" value="2" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_USER_LINEBREAKS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_COLON_IN_MEMBER_INITIALIZER_LISTS/@EntryValue" value="ON_SINGLE_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/MEMBER_INITIALIZER_LIST_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_INDENTATION/@EntryValue" value="All" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/OTHER_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_CATCH_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_ELSE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_NAMESPACE_DEFINITIONS_ON_SAME_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_WHILE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_BLOCK_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_EXTENDS_COLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_COLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_SEMICOLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_METHOD/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_NESTED_DECLARATOR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_METHOD/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_UNARY_OPERATOR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_EXTENDS_COLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_COLON/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_SEMICOLON/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_METHOD/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_METHOD/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BETWEEN_CLOSING_ANGLE_BRACKETS_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_ARRAY_ACCESS_BRACKETS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_DECLARATION_PARENTHESES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_BLOCKS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_METHOD_PARENTHESES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPECIAL_ELSE_IF_TREATMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TAB_WIDTH/@EntryValue" value="4" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TYPE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_BINARY_OPSIGN/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_DECLARATION_LPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_INVOCATION_LPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_ARGUMENTS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_LPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_RPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_LPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_RPAR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_TERNARY_OPSIGNS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_PARAMETERS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
<option name="/Default/CodeStyle/EditorConfig/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
</component>
</project>
-10
View File
@@ -1,23 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CMakePythonSetting">
<option name="pythonIntegrationState" value="YES" />
</component>
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MakefileSettings">
<option name="linkedExternalProjectsSettings">
<MakefileProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$/Start_Windows" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$/Start_Windows" />
</set>
</option>
<option name="version" value="2" />
</MakefileProjectSettings>
</option>
</component>
<component name="MakefileWorkspace" PROJECT_DIR="$PROJECT_DIR$/Start_Windows">
<contentRoot DIR="$PROJECT_DIR$" />
</component>
</project>
+86 -2
View File
@@ -2,22 +2,106 @@
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define MAX_RAND_TRIES_PER_WORD 10
#define EMPTY_CHAR 0
//TODO: Spiellogik implementieren:
//TODO: Spiellogik implementieren: | VERSION: Erfolgreicher Test 4 & 5 I
/* * 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)
{
//Random Zeit initialisieren
srand(time(NULL));
for (unsigned int i = 0; i < searchFieldLen; i++)
{
for (unsigned int j = 0; j < searchFieldLen; j++)
{
salad[i][j] = EMPTY_CHAR;
}
}
int placed = 0; //Anzahl der Erfolgreich platzierten Worte
//Platzieren
for (unsigned int w = 0; w < wordCount; w++)
{
const char *word = words[w];
unsigned int wordLen = strlen(word);
for (int attempt = 0; attempt < MAX_RAND_TRIES_PER_WORD; attempt++)
{
int row = rand() % searchFieldLen;
int col = rand() % searchFieldLen;
int direction = rand() % 2;
int canPlace = 1;
//Ob EIN Wort platziert werden kann (wird noch nicht platziert!)
for (unsigned int k = 0; k < wordLen; k++)
{
int r = row + (direction == 1 ? k : 0);
int c = col + (direction == 0 ? k : 0);
//Ränder des Spielfeldes beachten
if (r >= (int)searchFieldLen || c >= (int)searchFieldLen)
{
canPlace = 0;
break;
}
//Ist die Stelle nicht leer und passt Die stelle nicht zum passenden Buchstaben des Wortes
if (salad[r][c] != EMPTY_CHAR && salad[r][c] != word[k])
{
canPlace = 0;
break;
}
}
if (canPlace) //Wenn geprüft wurde ob ein Wort erfolgreich platziert werden kann.
{
for (unsigned int k = 0; k < wordLen; k++)
{
int r = row + (direction == 1 ? k : 0);
int c = col + (direction == 0 ? k : 0);
if (r < (int)searchFieldLen && c < (int)searchFieldLen)
salad[r][c] = word[k];
}
placed++;
break; //Beim Nächsten Wort weiter machen
}
}
}
//Mit Zufälligen Buchstaben füllen
for (unsigned int i = 0; i < searchFieldLen; i++)
{
for (unsigned int j = 0; j < searchFieldLen; j++)
{
if (salad[i][j] == EMPTY_CHAR)
{
salad[i][j] = 'A' + (rand() % 26);
}
}
}
return placed;
}
// Prints the word salad to console
void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
{
for (unsigned int i = 0; i < searchFieldLen; i++)
{
for (unsigned int j = 0; j < searchFieldLen; j++)
{
printf("%c ", salad[i][j]);
}
printf("\n");
}
}
BIN
View File
Binary file not shown.
+33 -2
View File
@@ -1,12 +1,43 @@
#include "input.h"
#include <string.h>
#include <ctype.h>
#include <stdio.h>
// 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)
{
unsigned int count = 0;
int c;
unsigned int idx = 0;
if (!file) return 0;
while ((c = fgetc(file)) != EOF && count < maxWordCount) {
if (isalpha((unsigned char)c)) {
if (idx < MAX_WORD_LEN - 1) {
words[count][idx++] = (char) toupper((unsigned char)c);
} else {
// word too long: truncate remaining letters until delimiter
idx = MAX_WORD_LEN - 1;
}
} else {
if (idx > 0) {
words[count][idx] = '\0';
count++;
idx = 0;
}
// skip consecutive delimiters
}
}
// If file ended while reading a word, terminate and count it
if (idx > 0 && count < maxWordCount) {
words[count][idx] = '\0';
count++;
}
return count;
}
}
BIN
View File
Binary file not shown.
+15 -1
View File
@@ -36,11 +36,25 @@ 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 von Niklas)
// Check if all words were successfully placed
// Start the game if successful
// error message if some words couldn't be placed
if (placedWords == wordCount) //überprüfung: alle wörter im gitter
{
printf("All words have been placed successfully.\n");
startGame(wordSalad, SALAD_SIZE, words, wordCount, 800); //header datei wird ausgeführt
}
else
{
fprintf(stderr, "Error: Only %u out of %u words could be placed.\n", placedWords, wordCount); //fprintf in selbst gewählter ausgabe
fprintf(stderr, "Try reducing the number or length of words.\n"); // std err = error
exitCode = EXIT_FAILURE; //exit_failure von der stdlib eine funktion => fehler beim ausführen; wert = 1
}
}
else
{
BIN
View File
Binary file not shown.
+5 -2
View File
@@ -4,7 +4,7 @@ LDFLAGS = -framework OpenGL -framework CoreFoundation -framework CoreGraphics -f
ARCH := $(shell uname -m)
BINARIES = ./macos-$(ARCH)
raylib_folder = ./raylib
raylibfolder = ./raylib
unityfolder = ./unity
# --------------------------
@@ -13,6 +13,9 @@ unityfolder = ./unity
wordsalad_initial:
$(CC) -o wordsalad_initial $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
wordsalad_myversion:
$(CC) -o wordsalad_myversion $(BINARIES) main.c $(BINARIES)/libwordsalad.a
# --------------------------
# Normales Spiel bauen
# --------------------------
@@ -43,4 +46,4 @@ test: input.o game.o unit_tests.c $(BINARIES)/libunity.a
# Clean
# --------------------------
clean:
rm -f *.o wordsalad
rm -f *.o wordsalad $(TEST_BIN)
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+89 -2
View File
@@ -2,22 +2,109 @@
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define MAX_RAND_TRIES_PER_WORD 10
#define EMPTY_CHAR 0
//TODO: Spiellogik implementieren:
//TODO: Spiellogik implementieren: | VERSION: Erfolgreicher Test 4 & 5 I
/* * 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)
{
//Random Zeit initialisieren
srand(time(NULL));
//Matrix leeren
for (unsigned int x = 0; x < searchFieldLen; x++)
{
for (unsigned int y = 0; y < searchFieldLen; y++)
{
salad[x][y] = EMPTY_CHAR;
}
}
int placed = 0; //Anzahl der Erfolgreich platzierten Worte
//Platzieren
for (unsigned int w = 0; w < wordCount; w++)
{
const char *word = words[w];
unsigned int wordLen = strlen(word);
for (int attempt = 0; attempt < MAX_RAND_TRIES_PER_WORD; attempt++)
{
//random kästchen in der matrix auswählen zwischen 0 und searchfieldlen (row,col)
int row = rand() % searchFieldLen;
int col = rand() % searchFieldLen;
int direction = rand() % 2; //0 = horizontal; 1 = vertikal
int canPlace = 1;
//Ob EIN Wort platziert werden kann (wird noch nicht platziert!)
for (unsigned int k = 0; k < wordLen; k++)
{
int r = row + (direction == 1 ? k : 0); //buchstaben werden vertikal darunter gestzt wenn direction = 1 (neue zeile)
int c = col + (direction == 0 ? k : 0); //buchstaben werden horizontal rechts daneben gesetzt wenn direction = 0 (neue spalte)
//Ränder des Spielfeldes beachten
if (r >= (int)searchFieldLen || c >= (int)searchFieldLen)
{
canPlace = 0;
break;
}
//Ist die Stelle schon besetzt und passt Die stelle nicht zum passenden Buchstaben des Wortes
if (salad[r][c] != EMPTY_CHAR && salad[r][c] != word[k])
{
canPlace = 0;
break;
}
}
if (canPlace) //Wenn geprüft wurde ob ein Wort erfolgreich platziert werden kann.
{
//platzieren der buchstaben
for (unsigned int k = 0; k < wordLen; k++)
{
int r = row + (direction == 1 ? k : 0);
int c = col + (direction == 0 ? k : 0);
if (r < (int)searchFieldLen && c < (int)searchFieldLen)
salad[r][c] = word[k];
}
placed++;
break; //Beim Nächsten Wort weiter machen
}
}
}
//Mit Zufälligen Buchstaben füllen
for (unsigned int x = 0; x < searchFieldLen; x++)
{
for (unsigned int y = 0; y < searchFieldLen; y++)
{
if (salad[x][y] == EMPTY_CHAR)
{
salad[x][y] = 'A' + (rand() % 26); //random buchstabe zw A und Z platzieren
}
}
}
return placed;
}
// Prints the word salad to console
void showWordSalad(const char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsigned int searchFieldLen)
{
for (unsigned int x = 0; x < searchFieldLen; x++)
{
for (unsigned int y = 0; y < searchFieldLen; y++)
{
printf("%c ", salad[x][y]);
}
printf("\n");
}
}
+44 -4
View File
@@ -1,12 +1,52 @@
#include "input.h"
#include <string.h>
#include <ctype.h>
#include <stdio.h>
// TODO:
// TODO: | VERSION: Erfolgreicher Test 1,2 & 3
// 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)
{
printf("Hallo");
}
unsigned int count = 0;
int c;
unsigned int idx = 0;
if (!file) return 0; //Wenn keine file gefunden oder geöffnet wurde
//scannt jedes zeichen in der file durch bis zum end of file oder bis es genug wörter hat
while ((c = fgetc(file)) != EOF && count < maxWordCount)
{
if (isalpha((unsigned char)c))// prüft ob das zeichen ein buchstabe ist (also kein komma oder leerzeichen usw)
{
//macht die buchstaben zu Großbuchstaben und schreibt sie ins array (toupper)
//prüft ob das wort kurz genug ist
if (idx < MAX_WORD_LEN - 1)
{
words[count][idx++] = (char) toupper((unsigned char)c);
} else
{
// word too long: schneidet das ende vom wort ab bis es reinpasst
idx = MAX_WORD_LEN - 1;
}
} else // bei leerzeichen, komma usw
{
if (idx > 0) //wort endet -> \0 ;stellt den idx wieder auf 0; neues wort beginnt -> count++
{
words[count][idx] = '\0';
count++;
idx = 0;
}
// skip consecutive delimiters
}
}
//Erkennung vom Ende der file wenn das letze wort endet und wort counten
if (idx > 0 && count < maxWordCount) {
words[count][idx] = '\0';
count++;
}
return count;
}
+17 -2
View File
@@ -36,15 +36,30 @@ 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 von Niklas)
// Check if all words were successfully placed
// Start the game if successful
// error message if some words couldn't be placed
//prüft ob die die anzahl der wörter und der tatsächlich platzierten wörter übereinstimmen
if (placedWords == wordCount)
{
printf("All words have been placed successfully.\n");
// Start graphical game
startGame(wordSalad, SALAD_SIZE, words, wordCount, 800);
}
else
{
fprintf(stderr, "Error: Only %u out of %u words could be placed.\n", placedWords, wordCount);
fprintf(stderr, "Try reducing the number or length of words.\n");
exitCode = EXIT_FAILURE;
}
}
else
{
// Print error message if file couldn't be opened
//Wenn die file nicht geöffnet werden konnte
fprintf(stderr, "Could not open file %s for reading ...\n", argv[1]);
exitCode = EXIT_FAILURE;
}
+7 -5
View File
@@ -1,9 +1,9 @@
CC = gcc
CFLAGS = -g -Wall -I$(raylibfolder)
CFLAGS = -g -Wall
LDFLAGS = -lopengl32 -lgdi32 -lwinmm
BINARIES = ./windows
raylib_folder = ./raylib
raylibfolder = ./raylib
unityfolder = ./unity
# --------------------------
@@ -12,7 +12,6 @@ unityfolder = ./unity
wordsalad_initial:
$(CC) -o wordsalad_initial $(BINARIES)/libwordsalad_complete.a $(BINARIES)/libraylib.a $(LDFLAGS)
# --------------------------
# Normales Spiel bauen
# --------------------------
@@ -23,13 +22,13 @@ 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
graphicalGame.o: graphicalGame.c
$(CC) -I$(raylib_folder) -c $(CFLAGS) graphicalGame.c
$(CC) -I$(raylibfolder) -c $(CFLAGS) graphicalGame.c
# --------------------------
# Unit Tests
@@ -44,3 +43,6 @@ test: input.o game.o unit_tests.c
# --------------------------
clean:
del /f *.o *.exe
wordsalad_myversion: main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a
$(CC) $(CFLAGS) -o wordsalad_myversion main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a $(LDFLAGS)
+2 -1
View File
@@ -2,4 +2,5 @@ Yeti,Nessie Werwolf; Vampir
Monster
Hydra;Frankenstein
Dracula;KingKong;Gremlin;Kobold,Hexe;Poltergeist
Gespenst, Ogerp
Gespenst, Oger
AHHHHHHH