Assignment #8 - Simple Tag
Submission and Grading Instructions:
- Read all the assignment specifications carefully.
- All assignments are designed to use only the features of Processing we’ve discussed so far to test your understanding of the material presented in class. Files using features that we have not covered in the lecture will be flagged as cheating. For example, you can never use the function translate.
- You cannot use generative AI to help you solve any part of the assignment.
- If you have questions, you must ask the instructor or the TAs. You cannot search for the answer on Google nor use YouTube videos or any other material not provided by us.
- Turn in the file(s) as described in the following specifications to Gradescope before the due date. Make sure to name the file exactly as this document specifies.
- You must use Gradescope as a backup. Upload to Gradescope frequently, and if you ever have issues with your computer, you can get your latest code by downloading your program from Gradescope.
- You should follow the coding style guidelines covered in the lecture. That means using proper comments and blank lines to separate the key parts of your code, proper indentation, variable names should be well-chosen, and using camelCase.
Specification of Assignment
In this assignment, you will develop a program with four screens. The first screen will display a message saying, “Welcome to my game,” and a smaller message saying, “Press any key to continue.” Once the user presses any key, this message will disappear, and the game from Assignment 7 will begin. After the user wins, a third screen will appear, asking if the user wants to play again. If the user chooses to play again, you will display the second screen again, and the game will restart. If the user decides not to play again, a fourth screen will show the message “Goodbye!” and the fewest number of moves that took the user to win the game.
Use this file as based code (the game from Assignment 7): screen2.pde
The following workflow outlines the sequence in which the screens will open:
Requirement 1: Welcome screen
- A 500 pixels wide and 550 pixels tall white screen will open when the program starts.
- This screen has two text messages: “Welcome to my game!” in large letters and “Press any key to continue” in smaller size.
- When the user presses any key, the game from Assignment 7 will begin. Refer to lecture slide 26 for an example demonstrating the process of transitioning from one screen to the next.
Requirement 2: The game screen
- After the message “You win!” appears, check for the mouse cursor’s position. If the user places the mouse over the green grid, the next screen, “Play again” screen, will show up.
- Modify the code you have from Assignment 7 to include the count of the number of moves the user makes before the game ends using arrays and recursive functions .
- Ilegal moves like trying to go outside the screen also count, but pressing keys different to ‘a’,’s’,’d’, or ‘w’ do not increase the counter.
- The arraycounter should show at the bottom of the screen with white letters over a black background.
The following video demonstrates the functionality of the counter. The letters shown in the bottom-left corner of the screen are the keys I pressed.
Requirement 3: Play again screen
- This is the third screen. This screen contains the text “Do you want to play again?” and two rectangles.
- Decorate the screen with similar colors, as shown below.
- Using switch-case statements: If the user clicks on the “yes” rectangle, you will display the second screen again, and the game will restart.
- If the user decides not to play again, a fourth screen will be shown.
- You should define a global array variable to track the fewest moves that took the user to win the game.
Requirement 4: Goodbye screen
- This is the fourth screen. This screen contains the text “Goodbye!”.
- Make the background of this screen reddish.
- This screen displays the fewest number of moves that took the user to win the game. For example, Let’s say the user played three times: the first time, it took 40 moves to win; the second time, they won in 34 moves; and the third time, they won in 60 moves. The message should read: “Fewest number of moves: 34”. This video shows another example.
Comments and Style
Name the file game_with_score.pde
.
Note: A portion of your score on this assignment will awarded based on your comments and style. Your programming should be well-formatted and easy for the graders to read and comprehend. You should follow the style guidelines that we have discussed in class and previous assignments. (See the lecture slides for reference.)
Grading Rubric
Points | Requirement |
---|---|
2 | Name the file game_with_score.pde (autograder). |
3 | Style |
6 | Screen 1 is drawn properly |
6 | When the user presses any key on Screen 1, Screen 2 is shown |
6 | Screen 2 counts the number of moves properly (only when pressing a,s,d,w) |
4 | When the user wins the game, Screen 3 is shown properly |
3 | When the user clicks “NO” on Screen 3, Screen 4 is displayed |
7 | When the user clicks “YES” on Screen 3, Screen 2 is displayed, and all the variables are reset properly, so the game works properly every time. |
7 | After playing a few rounds, Screen 4 shows the fewest moves properly. |