forked from freudenreichan/info2Praktikum-Wortsalat
game.c platzierte Wörter zählen
This commit is contained in:
1 parent
4f09d24c90
commit
6eb6f6acc3
2 files changed
+8
-4
No files matched your search
+7
-3
@@ -16,7 +16,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
{
|
{
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
int startpoint_x, startpoint_y, direction, possible, tries;
|
int startpoint_x, startpoint_y, direction, possible, tries, wordsplaced = 0;
|
||||||
|
|
||||||
for(int i = 0; i < searchFieldLen; i++){
|
for(int i = 0; i < searchFieldLen; i++){
|
||||||
for(int j = 0; j < searchFieldLen; j++){
|
for(int j = 0; j < searchFieldLen; j++){
|
||||||
@@ -51,6 +51,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
salad[startpoint_x + j][startpoint_y] = words[i][j];
|
salad[startpoint_x + j][startpoint_y] = words[i][j];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
wordsplaced += 1;
|
||||||
case 1: //X-Negativ
|
case 1: //X-Negativ
|
||||||
startpoint_x = strlen(words[i]) - 1 + rand() % (searchFieldLen - strlen(words[i]) + 1);
|
startpoint_x = strlen(words[i]) - 1 + rand() % (searchFieldLen - strlen(words[i]) + 1);
|
||||||
startpoint_y = rand() % searchFieldLen;
|
startpoint_y = rand() % searchFieldLen;
|
||||||
@@ -70,6 +71,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
salad[startpoint_x - j][startpoint_y] = words[i][j];
|
salad[startpoint_x - j][startpoint_y] = words[i][j];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
wordsplaced += 1;
|
||||||
case 2: //Y-Positiv
|
case 2: //Y-Positiv
|
||||||
startpoint_x = rand() % searchFieldLen;
|
startpoint_x = rand() % searchFieldLen;
|
||||||
startpoint_y = rand() % (searchFieldLen - strlen(words[i]) + 1);
|
startpoint_y = rand() % (searchFieldLen - strlen(words[i]) + 1);
|
||||||
@@ -87,7 +89,8 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
|
|
||||||
for(int j = 0; j < strlen(words[i]); j++){
|
for(int j = 0; j < strlen(words[i]); j++){
|
||||||
salad[startpoint_x ][startpoint_y + j] = words[i][j];
|
salad[startpoint_x ][startpoint_y + j] = words[i][j];
|
||||||
}
|
}
|
||||||
|
wordsplaced += 1;
|
||||||
break;
|
break;
|
||||||
case 3: //Y-Negativ
|
case 3: //Y-Negativ
|
||||||
startpoint_x = rand() % searchFieldLen;
|
startpoint_x = rand() % searchFieldLen;
|
||||||
@@ -107,6 +110,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
for(int j = 0; j < strlen(words[i]); j++){
|
for(int j = 0; j < strlen(words[i]); j++){
|
||||||
salad[startpoint_x][startpoint_y - j] = words[i][j];
|
salad[startpoint_x][startpoint_y - j] = words[i][j];
|
||||||
}
|
}
|
||||||
|
wordsplaced += 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,5 +125,5 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return wordsplaced;
|
||||||
}
|
}
|
||||||
+1
-1
@@ -26,7 +26,7 @@ wordsalad_initial:
|
|||||||
# Normales Spiel bauen
|
# Normales Spiel bauen
|
||||||
# --------------------------
|
# --------------------------
|
||||||
wordsalad_myversion:
|
wordsalad_myversion:
|
||||||
$(CC) -o wordsalad_initial -L. $(BINARIES)/main.c $(BINARIES)/libraylib.a $(LDFLAGS)
|
$(CC) -o wordsalad_initial -L. $(codefolder)/main.c $(BINARIES)/libraylib.a $(LDFLAGS)
|
||||||
|
|
||||||
wordsalad: main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a
|
wordsalad: 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)
|
$(CC) $(CFLAGS) -o wordsalad main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a $(LDFLAGS)
|
||||||
|
|||||||
Reference in new issue
Block a user