Givens:
1. The words used in the game for hangman are predetermined.
2. Almost all the functions and loops will be inside the main function.
3. The Proteus is used, and the micro SD card will be used to contain the code to transfer it
to the Proteus.
4. The program and code is written using Qt Creator and contains code that allows the
Proteus to read it.
Assumptions:
1. The user understands how to use a Proteus and how the code will transfer from the Qt
Creator to the Proteus.
2. The user has a basic understanding of how to use code that directly relates to the Proteus.
3. The person who will play the game on the Proteus understands how to play the game
Hangman.
Steps:
1. Include the FEH Proteus libraries FEHLCD.h, FEHIO.h, and FEHUtility.h.
2. Declare the button board and initialize it as the variable button to connect it to the
Proteus commands using FEHIO::Bank3.
3. Declare the function prototype as an integer to determine the winning percentage using
the function winpercent and the variables wins and loss.
4. Being the main function and declare it as an integer.
5. Declare the variables x, y, a, b, e, and q, where q=1, as floats.
6. Declare the variables total, c, d, wins, and loss as integers and set them all equal to zero.
7. Create a character array called word_array with 12 rows and 7 columns.
8. Use strcpy command to declare each word_array[0] through word_array[11] as different
words.
a.
strcpy(word_array[0], "juggle");
b.
strcpy(word_array[1], "accept");
c.
strcpy(word_array[2], "answer");
d.
strcpy(word_array[3], "camera");
e.
strcpy(word_array[4], "button");
f.
strcpy(word_array[5], "jeremy");
g.
strcpy(word_array[6], "deputy");
h.
strcpy(word_array[7], "equity");
i.
strcpy(word_array[8], "morgan");
j.
strcpy(word_array[9], "module");
k.
strcpy(word_array[10], "orange");
l.
strcpy(word_array[11], "random");
9. Use srand ( TimeNow() ); to declare the current time as a random function.
10. Initialize the background color as white with LCD.Clear( FEHLCD::White); and the
font color as red with LCD.SetFontColor( FEHLCD::Red);.
11. Use a while loop for getting the program to run and to have the initial home screens
show when player quits the game, which is why q==1 since q automatically equals one
as it was declared as this earlier. This loop will encompass everything that is a part of
the rest of the code.
12. Use a while loop and the commands !LCD.Touch or (||) x==1 to have the home screen
appear while the user hasn’t touched the screen anywhere.
a. !LCD.Touch(&x,&y) uses the variables x and y as any position on the Proteus’
screen that could be touched, and the ! sign declares that the screen has not been
touched yet.
b. LCD.Clear(); will also be consistently used throughout the code to clear the
screen before printing a new phrase or image to the Proteus’ screen.
13. The home screen will appear and the while loop with x==1 and the if loop with
LCD.Touch(&x,&y) sets x=0 to exit the loop and off of the home screen.
14. Prompt the user to choose to play the game, view the instructions, or view the statistics
using the command LCD.WriteLine("Select Hangman (left button)\nView Instructions
and Credits (middle button)\nView Statistics (right button)");.
a. Use a while loop (q==1) to state that while the left button, middle button, and
right button aren’t pressed, nothing will happen, but if the user presses the left
button, a for loop will set a=1 and go up to 3 and print this count of 1, 2, and 3
(the value of a) to the screen using LCD.WriteLine. Outside the for loop,
LCD.WriteLine is used to write “BEGIN GAME!!!” to the Proteus screen and
initializes b=1 and q=0.
b. Use Sleep ( ); command with some thousand number inside the parentheses to
represent the particular phrase or action will occur for that specific duration.
c. The Sleep command will be used throughout the code.
d. If the user presses the middle button, LCD.WriteLine is used to write the
instructions to the Proteus screen for 9 seconds. Then, the screen will be cleared
and the credits will appear for four seconds.
e. If the user presses the right button, LCD.WriteLine is used to write the current
wins and losses and the winning percentage to the Proteus screen using the
variables wins and loss for 5 seconds, and then LCD.WriteLine is used again to
give the user an option to reset the statistics so the variables wins and loss are
equal to zero.
15. Once the user presses the left button, the code will enter a while loop where b==1 &&
q==0 is used to allow the game screen to appear so the user can play the game Hangman
through this while loop.
16. Draw the main structure of the hangman stand using the following commands:
a. LCD.DrawVerticalLine(10,200,50); draws a vertical line at the x position on the
Proteus screen of x=10 from the y values of y=200 to y=50, where 200 is closer to
the bottom of the screen and 50 is closer to the top of the screen.
b. LCD.DrawHorizontalLine(50,10,50); draws a horizontal line at y=50 from x=10
on the farther left side of the screen to x=50 on the farther right side of the screen.
c. LCD.DrawVerticalLine(50,50,75); draws a vertical line at x=50 from y=50 to
y=75.
17. Use the command LCD.WriteAt to prompt the Proteus to show each letter of the
alphabet at a particular (x,y) coordinate on the screen.
a. LCD.WriteAt("A",60,10);
b. LCD.WriteAt("B",80,10);
c. LCD.WriteAt("C",100,10);
d. LCD.WriteAt("D",120,10);
e. LCD.WriteAt("E",140,10);
f. LCD.WriteAt("F",160,10);
g. LCD.WriteAt("G",180,10);
h. LCD.WriteAt("H",200,10);
i. LCD.WriteAt("I",220,10);
j. LCD.WriteAt("J",240,10);
k. LCD.WriteAt("K",260,10);
l. LCD.WriteAt("L",280,10);
m. LCD.WriteAt("M",300,10);
n. LCD.WriteAt("N",60,30);
o. LCD.WriteAt("O",80,30);
p. LCD.WriteAt("P",100,30);
q. LCD.WriteAt("Q",120,30);
r. LCD.WriteAt("R",140,30);
s. LCD.WriteAt("S",160,30);
t. LCD.WriteAt("T",180,30);
u. LCD.WriteAt("U",200,30);
v. LCD.WriteAt("V",220,30);
w. LCD.WriteAt("W",240,30);
x. LCD.WriteAt("X",260,30);
y. LCD.WriteAt("Y",280,30);
z. LCD.WriteAt("Z",300,30);
18. Use LCD.DrawHorizontalLine at y=175 and at different x positions so the spaces are all
20 pixels long and 10 pixels apart, for 6 different spaces for the six characters/letters of
each word.
a. LCD.DrawHorizontalLine(175,120,140);
b. LCD.DrawHorizontalLine(175,150,170);
c. LCD.DrawHorizontalLine(175,180,200);
d. LCD.DrawHorizontalLine(175,210,230);
e. LCD.DrawHorizontalLine(175,240,260);
f. LCD.DrawHorizontalLine(175,270,290);
19. Initialize the variable e as a random variable using the command rand( ) so e can be used
for each word to randomly generate one of the 12 words that are a part of the game
Hangman (where e=rand( )%12).
20. Use the following loop for each word with e equaling a number 0 through 11, which
each refer to one of the twelve words programmed into the Proteus.
21. First use if (e==0) to set e equal to the word juggle and call on the word juggle to be
used in this loop for this round/level of the game.
22. Use a while loop where while(c<6 || d<6) encompasses the entire loop for the word
juggle since e==0 and initializes c as the count variable for every time the correct letter
is guessed and one is added to c and initializes d as the variable for the number of
incorrect guesses.
a. If the user completes the word, then c==6 and the game has been won.
b. If the user completes the hangman structure, then d==6 and the game was lost.
c. The || represents that the lop must continue until c==6 OR d==6.
23. Use a while loop to state that while the screen isn’t touched at the x and y positions,
nothing happens, which occurs for one second due to the Sleep(1000); command.
24. If the user presses between a particular two x-values and two y-values, the letter J will
be recognized as touched and is programed to be written on the first blank space that is
given for the letters of each of the six character words.
a. If the user presses a particular area for each of the five other characters for the
word, then these letters will also appear on the blank spaces that correspond to
their location in the word.
b. Once a letter appears on a line, one is added to the variable c and directly after
this an if statement is used to check if c==6 to see if the game has been won, and
if it has, then the statement sets d=6 and e=25 to exit the loop and end the game.
25. If an incorrect letter is guessed for the word, in this case a letter that isn’t in the word
“JUGGLE”, then a part of Hangman will appear, and the entire Hangman will continue
to be filled until the user has guessed incorrectly six times and the entire Hangman is
complete.
a. If the Hangman figure is complete, then d will be recognized as d==6, which
will cause c=6 and e=21 to exit the loop and end the game.
26. This process will be the same for the words accept, answer, camera, button, jeremy,
deputy, equity, morgan, module, orange, and random.
27. For the word accept (e==1), a switch-case is used for each incorrect guess to draw the
parts of the Hangman, which is all in an else statement.
a. Use switch (d) to go through each case and compare the value of d, which is the
number of incorrect guesses.
b. Use case (0): through case (5): to go through and draw each part of the
Hangman and add one to the value of d.
c. break; is entered at the end of each case statement.
28. “You win! You saved him!” will print to the screen using LCD.WriteLine for four
seconds and one point will be added to the variable wins, if the user reaches (c==6 &&
e==25) before (d==6 && e==21).
29. “You lost. Muahahahaha! Bring out the casket.” will print to the screen using
LCD.WriteLine for four seconds and one point will be added to the variable loss, if the
user reaches (d==6 && e==21) before (c==6 && e==25).
a. For both winning and losing, c and d with both be rest to zero.
30. After c==6 or d==6, the user will be given the option to play again or quit by pressing
the left button to play again and use a while loop and b=1 and q=0 to play again or press
the right button to quit using a while loop and q=1 to return to the very beginning of the
game.
31. Use int winpercent(int wins, int loss) as the function definition at the end of the code,
outside the main function.
a. Use the integer variable total to determine the winning percentage by
total=(wins/(wins+loss))*100;.
b. Give the return of total;.
© Copyright 2025 Paperzz