In this assignment, you will be writing a very simple implementation of tag! The rules of the game are simple:
Who the hider and the tagger is does not need to be represented in the code. The roles are up to the two players to determine.
When the sketch is first run, a window will pop up and display the following:
Notice a few things:
Both players can be moved with the keyboard. The player that begins at the top-left is controlled with the W A S D characters. W moves it up, S moves it down, A moves it left, and D moves it right. The move happens on the KeyReleased event. Here’s what the movement should look like:
The hider is The player starting in the bottom-right is controlled with the I/J/K/L characters. Again, the move happens on the KeyReleased event. Here’s what the movement should look like:
One human controls the finder with W/A/S/D, and another the hider with I/J/K/L. Both can move at the same time:
When the finder and hider land on the same tile, the game detects that the hider has been found. While they are on the same tile, the text “Tag, you are it!” appears on the screen. Once they are no longer on the same tile, the text disappears.
You should use the KeyReleased
event function to process the key presses.
Also, the players should mot be able to move off-screen.
You must use some if-statements to ensure that players are not allowed to do so.
Lastly, you should create a “menu bar” underneath the game board. The menu bar will have a number that keeps track of how many times the players have toughed one-another. You can see an example of this in the animation below.
You can add a little bit to the height of your canvas to display the bar, so that it doesnt cover over the game board.
As with any complex program, it is important to break up the work into various steps. I recommend working on this assignment in the following way.
First, just get the grid drawn onto the screen, like so:
Once you have the grid, get each player to draw in the appropriate positions in the top-left and bottom-right corners. Initially, don’t worry about player movement - just get the drawing down. Once you’ve got them drawn, implement the player movement. Initially, just make sure the appropriate key-presses are making the player move, and ignore keeping the player in-bounds, and the tagging logic. Then, add in some additional if-statements to ensure that the players always stay on the screen. Last, add an if-statement to check if the two players are on the same tile. If so, display the “tag” text. Save the menu-bar and touch-count for last. This can be a tricky feature!
If you cannot implement all of the features, you should still submit your code! You will get credit for each working feature.
All of 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. Each program file should have a header comment at the top that has roughly the following format:
//
// Author: Student Name
// Description:
// A short description of what this program does!
//
If any part of your scripts are particularly complex, you should put documentation comments above those lines of code.
Name your program netid_tag.pde
(where netid
is your UA username).
This was assigned on 10/20/2017. It is due on 10/27/2017 at 5:00pm.
Turn in each of the files described in the spec (just 1) the assignment drop-box in D2L before the due date. Make sure to name the files exactly as this document specifies. In general, make sure to follow these instructions precisely. If you don’t, we will deduct points!!!