Back

Assignment 2 - Objects, Lists, Games

Guidelines

Due 11.59pm, Sunday, June 14th.

  • You are graded on the completeness, neatness, comments, and visual style of your final assignment
  • All assignments are individual
  • Complete each part as a separate sketch (and folder)
  • ZIP SKETCH FOLDERS (not individual files) INTO ONE FILE
  • Submit to WebCT before the deadline

There is no late policy for this course!

If you do not complete the assignment by the deadline, you will receive 0
You "may" be excused pending discussion with your TA

Overview

In this assignment, we will be creating objects from a class that defines our character from Assignment 1. By doing this we will be able to create many instances of our character and create a simple game.

Part 1 - A Character Class

Create a class to describe your character so each character has a position on the screen. Move your characters around the screen.

Requirements:

  • A class to describe your character
  • 2 fields for the x and y position of the character
  • 2 fields for the x and y velocity of the character
  • A constructor with arguments that are assigned to the x and y position fields
  • A method to move your character
  • A method to draw your character
  • Create and instantiate 2 characters and call their move and draw methods from the main draw loop

Part 2 - A List of Characters

Create an ArrayList to store many instances of your Character class. Instantiate character objects and add them to the list. In the main draw loop, iterate over the list of characters calling their move and draw methods.

Requirements:

  • An ArrayList of characters
  • A for loop in setup to instantiate all characters
  • A for loop in draw to move and draw all characters
  • When the characters leave an edge of the screen, they should reappear on the opposite side (this code goes in your move method)

Part 3 - Whack-a-Mole Game

Create a simple game using multiple character instances. When a character is clicked on by the mouse, it should be removed from the ArrayList. Characters will be added back to the ArrayList at a fixed time rate.

Requirements:

  • When a character is clicked on they appear captured or dead
  • After 2 seconds, a dead / captured character should be removed from the ArrayList
  • Add characters at a steady interval up to a maximum of 10 on screen
  • Keep track of the score using a global int variable (10 points for each character clicked)
  • Print the score out somewhere on the screen

Tips and Tricks

  • Remember mouseX and mouseY are special global variables in Processing
  • Use an integer in your character class to keep track of the time since that character has been clicked by the mouse
  • Strings and Text
  • Pay attention in the labs and lectures, check the notes and use the examples
  • Style counts! Take time to design your scene and character
  • Start now!