Saba Fazlali
11 months ago
2 changed files with 52 additions and 18 deletions
@ -1,33 +1,67 @@ |
|||
#include "word_selector.h" |
|||
#include "playHangman.h" |
|||
|
|||
const char wordsList[NUM_WORDS][MAX_WORD_LENGTH + 1] = { |
|||
"skill", |
|||
// easy words |
|||
const char wordsList_easy[NUM_WORDS][MAX_WORD_LENGTH + 1] = { |
|||
"apple", |
|||
"world", |
|||
"difference", |
|||
"celebration", |
|||
"association", |
|||
"customer", |
|||
"banana", |
|||
"cat", |
|||
"lemon", |
|||
"dog", |
|||
"mood", |
|||
"agreement", |
|||
"audience", |
|||
"professor", |
|||
"orange", |
|||
"kite", |
|||
"nest", |
|||
"year", |
|||
"dealer", |
|||
"patience", |
|||
"table tennis", |
|||
"pollution", |
|||
"awareness", |
|||
"grape", |
|||
"sun", |
|||
"mouse", |
|||
"tennis", |
|||
"queen", |
|||
"problem", |
|||
"vehicle", |
|||
"death", |
|||
"cousin" |
|||
}; |
|||
|
|||
const char* selectRandomWord() { |
|||
// hard words |
|||
const char wordsList_hard[NUM_WORDS][MAX_WORD_LENGTH + 1] = { |
|||
"database", |
|||
"programming", |
|||
"mountain", |
|||
"customer", |
|||
"table tennis", |
|||
"customer", |
|||
"laughter", |
|||
"expression", |
|||
"audience", |
|||
"professor", |
|||
"twilight", |
|||
"dealer", |
|||
"symphony", |
|||
"table tennis", |
|||
"pollution", |
|||
"inspiration", |
|||
"supermarket", |
|||
"difficulty", |
|||
"budget", |
|||
"quarter" |
|||
}; |
|||
|
|||
const char* selectRandomWord(int difficulty) { |
|||
|
|||
// pick a random number and assign it to index of wordsList array |
|||
// pick a random number and assign it to index of wordsList_easy array |
|||
srand((unsigned int)time(NULL)); |
|||
int randomIndex = rand() % NUM_WORDS; |
|||
|
|||
return wordsList[randomIndex]; |
|||
switch(difficulty){ |
|||
case 1: |
|||
return wordsList_easy[randomIndex]; |
|||
case 2: |
|||
return wordsList_hard[randomIndex]; |
|||
default: |
|||
printf("Invalid difficulty level. Using easy difficulty.\n"); |
|||
return wordsList_easy[randomIndex]; |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue