Character objects and Whack-a-Mole Game
Assignment 2 – Character objects and Whack-a-Mole Game Total Points: 15
(accounting for 5% of your final grade) Assignment Summary
In this assignment, you will create many instances from a class that defines your characters, and use them to create a simple game along the line of whack-a-mole type of game.
Learning objectives
By the end of this assignment, you will have earned the following skills: a) Create your own classes with all the essential ingredients- the fields (for data) and methods (for
capability) and to represent your own objects, characters, and entities, in a digital application b) Use your classes as blueprints for instantiating a large number of objects for use in your
application c) Use an ArrayList to store, maintain and access a large number of your custom objects. d) Use a loop to iterate through your ArrayList and access the objects stored inside it Also with this assignment, you have the opportunity to: a) Explore some small-scale animations b) Experiment with some basic game mechanics
Total Points: 15 (Assignment + Online Assignment Quiz)
Assignment (13 points): Tech Reqs:
10 points ECO Reqs:
3 points
Part I- create a Character class Tech points: 3 ECO points: 0
Part II- create a list of Character objects Tech points: 3 ECO points: 0
Part III- create a “Whack-a-mole” game Tech points: 4 ECO points: 3
Description Create a class to describe your character so that each character has fields representing the character’s position on the screen and velocities along x and y, a constructor with parameters for initializing at lease the position fields, as well as methods that draw
Create an ArrayList for storing instances (i.e. objects) of your Character class. Instantiate character objects and add them into the list. In the main draw loop, iterate over the list of characters and call
Create a simple game using multiple character instances. When a character is clicked on by the mouse, it should appear “captured or dead” for 1 or 2 seconds, after which time it should be removed from the ArrayList. The player’s score corresponds to the number of characters they have killed. The
them and that move them around the screen
their move and draw methods. Handle cases where the characters go off screen by making them reappear at the opposite side of the screen.
player’ score appears somewhere on the screen. Finally, characters should be added back to the ArrayList at a fixed time rate, with a maximum of 10 characters appearing on the screen at any given time.
Application Requirements
Instantiate two instance s of your Character class and move them through the screen. -.5 < 2 instances
-.5 characters don’t move or appear
1. Six instances of your Character class appear to move throughout the screen. -.25 <instances * -.5 Characters don’t move or appear
2. When the characters go off the screen boundary, they reappear on the other side. -.75 characters disappear when they go off the screen -.5 characters bounce off walls instead of re- appearing on other side -.25 characters reappear on other side but the boundary collisions are visually sloppy (i.e., Characters don’t go completely off screen before switching sides or they appear on other side part- way into the screen).
* Total deduction for Application Requirements caps at 1 pt even if the add-up goes over 1
1. When a Character is clicked they appear captured or dead. -1 Character doesn’t respond to clicks at all * -.75 Character responds to click (disappears at once, or just stands still, etc.) but there is no interesting visual changes in the Character
2. When a Character appears captured or dead it won’t respond to being clicked any more. -.75 Such character still responds (in any way, including changes to the player score) if clicked multiple times
3. After 1 or 2 seconds, a dead/captured (i.e., clicked) Character is removed from the ArrayList. -.75 Characters never removed OR Characters are removed instantly (not after 1 or 2 seconds)
4. New Characters are added back to the ArrayList at a fixed time rate. -.75 new Characters aren’t added at all OR new Characters added back but all at once versus at a fixed time rate
5. There is a Maximum of 10 characters onscreen at any time. -.25 there is evidence that student has imposed a maximum number of characters but it is different than 10 -.75 student hasn’t controlled the number of Characters at all (i.e., program just continuously adds new Characters to the list until the memory overflows)
6. Display the player’s score (i.e., the number of Characters they have clicked) somewhere on the screen.
-1 score doesn’t appear on the screen -.75 score isn’t being tracked properly
* Total deduction for Application Requirements caps at 3 pts even if the add-up goes over 3
Coding Requirements
1. Define a Character class that describes your character. -2 no Character class at all. *
2. Character class has 2 fields that represent the x and y coordinates of the character. -.25 missing either field
3. Character class has 2 fields that represent the horizontal (x) and vertical (y) velocities of the character. -.25 missing either field
4. Character class has a constructor with parameters for initialzing the x and y coordinate fields. -.5 constructor lacks parameters OR has parameters but does not assign to x and y coordinate fields
5. Constructor initializes Character with random initial horizontal and vertical velocities. -.25 random initial velocities assigned but OUTSIDE of constructor -.5 constructor initializes with constant (non- random) velocities -.75 no velocities initialized at all.
6. Character class has a method with the signature move ()* that enables the caller to move the character, using the x and y velocities. -.75 code that moves Character is absent OR isn’t defined in a move method OR doesn’t work at all -.5 method is defined with parameters (versus using class fields)
1. Create an ArrayList that is typed to store instances of your Character class. -.75 declares six Character variables or uses an Array instead of ArrayList to store them -.25 ArrayList is not typed to Character
2. Use a for-loop in setup to instantiate six instances of your Character class and add them to the ArrayList. -.5 fails to use for loop or fails to add the characters to list.
3. Assign each new Character a random initial position. -.25 any error
4. Use a for-loop in draw to iterate through your ArrayList and call the move and draw methods of each element. -.5 fails to use a for loop or fails to call any method.
5. In Character class, write the code that places the Character on the opposite side of the screen when it goes off any of the screen boundaries in a method with the signature detectWall()*, and call it in the move method.
1. Create a Score class for holding, tracking and displaying player’s scores. -1 there isn’t any class for the score
2. Create a global variable of Score in the main sketch, which references a Score instance, and use it to track player’s score and display it properly
-.75 Not using a Score object to track and display the score (possible error: used a global int variable to track and display the score)
* Total deduction for Coding Requirements caps at 1 pt even if the add-up goes over 1
7. Character class has a method with the signature drawCharacter()* that enables the caller to draw the character. -.75 code that draws Character is absent OR isn’t defined in a drawCharacter() method OR doesn’t work at all -.5 method is defined but has parameters (i.e. versus using class fields)
*Alternating method names is fine. The main idea is to have two separate methods for moving and drawing the Character * Total deduction for Coding Requirements caps at 2 pts even if the add-up goes over 2
-.5 code is just written directly into the main draw loop or is placed inside of the drawCharacter method
*Alternating method names is fine. The main idea is to have two separate methods for moving and drawing the Character * Total deduction for Coding Requirements caps at 2 pts even if the add-up goes over 2
Effort, Creativity, Originality
N/A N/A Primary level ECO features (each is worth .5-.75 marks*, depending on complexity) 1. Design a small animation or
other effect that indicates that the player has been successfully clicked. For example, previous students have created a short “blood splatter” effect that is triggered when the Character is clicked.
2. Instead of just having the Character appear captured/dead in a static image, have the Character change state in some meaningful way, during the 1 or 2 second period, which indicates that it is dying. For example, previous students have made the Character spin around and also shrink in size or fade out to nothing as the 1 second period elapsed.
3. Design a cool custom cursor so that it appears more that the player is harming/capturing the Character in some way. For example, previous students have designed images of mallets, butterfly nets, swords, etc., that appear where the mouse is.
Intermediate level ECO features (each is worth .75-1 marks, depending on complexity) 4. Use push and popMatrix and
the different transform methods (scale, rotate, translate) to cause different parts of your character to move independently as the Character moves through the screen (i.e., such as to produce the appearance of realistic movement- versus just translating the entire Character image through the screen). Previous students have made their Characters’ arms swing, wings flap, etc., as they moved through the screen.
5. Design a full-fledged “heads up display” to showcase the player score, with an appearance that matches the overall theme of your game. For example, previous students have designed heads-up-displays that look like the consoles in a spaceship.
6. Implement some difficulty scaling mechanics so that game becomes harder when there are fewer Characters onscreen or the longer the player plays.
Advanced level features (each is worth 1-1.25 marks, depending on complexity) 7. Implement some additional
reward/achievement system, such as flashing a special message to the player when they kill some number of Characters within a short time interval or they go a long span without “missing” a Character (i.e., clicking somewhere on the screen that isn’t a Character).
8. Implement some kind of restriction on the player’s ability to kill Characters. For example, make it so that the Character has a limited number of clicks to use before needing to either wait for the clicks to replenish OR click somewhere else on the screen (retrieve a pickup, click a special box, etc), to reload their clicks.
There are other possibilities... think of how you can take this simple game concept and extend it in some way to make it more challenging/interesting /rewarding... (something you or your friends
might actually like to play!!!) * Total ECO marks cap at 3 pts even if the add-up goes over 3
Submission and Grading Assignment Code (13 pts):
• It is an individual assignment. • The assignment consists of 3 parts. For each part, write a separate sketch inside a
different project folder. • Each class must be stored in its own tab (aka file) which is named the same as the class • Zip the 3 project folders (MUST be the folder NOT individual files) into a single Zip
File. Rename the zip file using the following naming standard: LabNumber_FirstName_LastName_AssignmentNumber_StudentNumber.zip , e.g. E101_John_Smith_Assignment2_1234567, and then upload it to the Canvas before or by the deadline. (Please note, -0.5 will be deducted for each violation of the rules specified above)
• Before the deadline, you are allowed to resubmit if you feel necessary, and the last one submitted will be graded.
• No late submission will be accepted. If you do not complete the assignment by the deadline, you will receive 0. You will also receive 0 for missing sketch or folder.
• For a legitimate reason a late submission might be allowed pending discussion with your TA before the deadline. You may be required to provide supporting documents.
Online Test for the Assignment (2 pts):
• To demonstrate that you learned the relevant concepts, you need to answer an online test regarding the work you’ve done.
• The test will be posted in Canvas and available immediately after the Assignment DUE TIME. You must get it done within 2 day after the DUE DATE, and you have 30 minutes to finish it once started. Please note once the online test is closed by the end of its schedule, there is no way to re-open it for any individual and therefore NO Make-Up is possible. So it is your responsibility to make sure you do it in time to get full credit for your assignment.
You are graded on completeness for the basic requirements and visual style evaluated by Effort, Creativity, Originality (ECO) of your assignment
- Assignment 2 – Character objects and Whack-a-Mole Game
- Submission and Grading