Guest User

Untitled

a guest
Feb 28th, 2023
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.97 KB | Source Code | 0 0
  1. // Visuals
  2. //  ____
  3. //  |  o
  4. //  | /|\
  5. //  | / \
  6. // _|_
  7. //
  8. // _ _ _ _
  9. //
  10. // Enter Guess
  11. //
  12.  
  13. // Include Libarys
  14. #include <stdio.h>
  15. #include <stdbool.h>
  16. #include <time.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19.  
  20. void draw_board(char Letters[], bool BodyParts[])
  21. {
  22.     const int LetterSize = strlen(Letters);
  23.     char LetterString[LetterSize*2];
  24.  
  25.     char LA = 'E';
  26.     char RA = 'E';
  27.     char LL = 'E';
  28.     char RL = 'E';
  29.  
  30.     for (int i=0; i < LetterSize; i++)
  31.     {
  32.         LetterString[i*2] = *(Letters+i);
  33.         LetterString[i*2+1] = ' ';
  34.     }
  35.     for (int i=0; i < 4; i++)
  36.     {
  37.         switch (i) {
  38.             case 0:
  39.                     LA = *(BodyParts+i) ? '/' : ' ';
  40.             case 1:
  41.                     RA = *(BodyParts+i) ? '\\' : ' ';
  42.             case 2:
  43.                     LL = *(BodyParts+i) ? '/' : ' ';
  44.             case 3:
  45.                     RL = *(BodyParts+i) ? '\\' : ' ';
  46.         }
  47.     }
  48.     printf(" _____\n |   o\n |  %c|%c\n |  %c %c\n_|_\n\n%s\n\nEnter Guess: \0", LA, RA, LL, RL, LetterString);
  49. }
  50.  
  51. int main()
  52. {
  53.     const char *Words[] = {
  54.     "fight",
  55.     "baseball",
  56.     "hobbies",
  57.     "wax",
  58.     "farm",
  59.     "bead",
  60.     "board",
  61.     "cheese",
  62.     "regret",
  63.     "advertisement",
  64.     "interest",
  65.     "part",
  66.     "lettuce",
  67.     "wall",
  68.     "quarter",
  69.     "neck",
  70.     "aunt",
  71.     "arm",
  72.     "sneeze",
  73.     "fireman"
  74.     };
  75.  
  76.     const int table_size = 20; // This must match the number of entries above
  77.  
  78.     srand(time(NULL)); // randomize the start value
  79.  
  80.     const char *Word = Words[rand() % table_size];
  81.     const int Size = strlen(Word);
  82.  
  83.     printf("Your Word is: %s. With a len of %d.", Word, Size);
  84.  
  85.     char *Word_Letters = malloc(Size);
  86.  
  87.     for (int i = 0; i < Size; i++)
  88.     {
  89.         *(Word_Letters + i) = '_';
  90.     }
  91.     *(Word_Letters+Size) = '\0';
  92.     *(Word_Letters+Size+1) = 'N';
  93.  
  94.     bool BodyParts[] = {true, false, true, false};
  95.     draw_board(Word_Letters, BodyParts);
  96. }
  97.  
Advertisement
Add Comment
Please, Sign In to add comment