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
+7
-3
No files matched your search
+6
-2
@@ -16,7 +16,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
{
|
||||
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 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];
|
||||
}
|
||||
break;
|
||||
wordsplaced += 1;
|
||||
case 1: //X-Negativ
|
||||
startpoint_x = strlen(words[i]) - 1 + rand() % (searchFieldLen - strlen(words[i]) + 1);
|
||||
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];
|
||||
}
|
||||
break;
|
||||
wordsplaced += 1;
|
||||
case 2: //Y-Positiv
|
||||
startpoint_x = rand() % searchFieldLen;
|
||||
startpoint_y = rand() % (searchFieldLen - strlen(words[i]) + 1);
|
||||
@@ -88,6 +90,7 @@ int createWordSalad(char salad[MAX_SEARCH_FIELD_LEN][MAX_SEARCH_FIELD_LEN], unsi
|
||||
for(int j = 0; j < strlen(words[i]); j++){
|
||||
salad[startpoint_x ][startpoint_y + j] = words[i][j];
|
||||
}
|
||||
wordsplaced += 1;
|
||||
break;
|
||||
case 3: //Y-Negativ
|
||||
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++){
|
||||
salad[startpoint_x][startpoint_y - j] = words[i][j];
|
||||
}
|
||||
wordsplaced += 1;
|
||||
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
|
||||
# --------------------------
|
||||
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
|
||||
$(CC) $(CFLAGS) -o wordsalad main.o input.o game.o graphicalGame.o $(BINARIES)/libraylib.a $(LDFLAGS)
|
||||
|
||||
Reference in new issue
Block a user