CSC 120 Introduction to Creative Graphical Coding, Fall 2015 Dr. Dale E. Parson, Assignment 3, Implementing and testing a function that plots your avatar. This assignment is due via D2L Dropbox Assignment 3 avatarClass by 11:59 PM on Tuesday November 22. We will have in-class work sessions on November 9, 16, & 21. When using Processing on the Kutztown campus Windows computers, make sure to start out every time by setting your Processing Preferences -> Sketchbook Location to U:\Processing. The U:\ drive is a networked drive that will save your work and make it accessible across campus. If you save it to your desktop or the lab PC you are using, you will lose your work when you log out. You must save it to the U:\ drive. If you do not have a folder called Processing under U:\, you must create one using the Windows Explorer. Processing Preferences is under the File menu on Windows. If you have a working avatar from assignment 2 (avatarFunction), load it into Processing and save it as sketch avatarClass. You will turn in file avatarClass.pde. If avatarFunction lost points, get it working according to my assignment grade instructions. Please follow any instructions on your assignment 2 grade sheet. REQUIREMENTS: The numbered paragraphs 1-10 below are steps that I did in migrating my avatarFunction sketch to avatarClass, and the lettered steps A-J are the requirements that you must fulfill. Each is worth 10% of this midterm exam. You must get the assignment turned in on time in order to earn 100%. 1. I changed function name avatar(…) to display(…) and save the sketch as avatarClass. A. Do that. Do not call your display function something else. Call it display so I can find it readily when reading code. Write documentation comments for this function. 2. I created “class Avatar” around the display(…) function and increased the indent of the display(…) page 1 function. B. Do that. You need to create class Avatar, named Avatar. Write documentation comments for this class. 3. I moved and renamed the variables that keep track of an Avatar object’s location, speed, and other bodily properties inside the Avatar class. Each Avatar object will keep track of its own location, rate of location change (speed), wiggle variables, scale, or other properties of your Avatar. Each Avatar object must be a complete visual avatar that uses its own internal variables to determine its *state* (location, direction, speed, etc.). You may pass additional values from draw() via function parameters as explained below; they should have to do with “the state of the world”, not with “the state of this Avatar”. I removed the assignment 2 parameters from the display(…) function, because it now uses the Avatar *data field* variables. You may add some new parameter or parameters to the display() function per instruction 4D below. Such a parameter would affect how an Avatar object displays without affecting its stored internal state. C. Move all variables that give location, scale, or other properties of the avatar to the inside of the Avatar class. Variables that do not make up part of Avatar state must stay outside of that class. Write documentation comments for these object variables. Your display() function for the each Avatar must use these object variables to set location and scale for the Avatar’s body parts. The Avatar variable fields should give the information on where to plot body parts. 4. I kept several global variables that have to do with “the state of the world”. They do not appear in the Avatar class. D. Retain or create some global variable(s) that affect the Avatar in some way. I kept level and associated variables. This is modeling something in the world that affects your avatar’s behavior. You could, for example, have a rotateDegrees variable that cycles from 0 through 360 degrees, and pass its value as an argument to the display() function. You could also experiment with the shearX() or shearY() library functions, passing parameter values for them to display(). Write documentation comments for any global variables and new parameters to display(). 5. I added a Constructor to initialize the variable fields of the Avatar object. E. Do that. You need to write a constructor for the Avatar class that initializes its fields. Write documentation comments for this constructor. 6. I MOVED the code that updates the Avatar state variables inside a new function Avatar.move(). The code that updates any global variables that exist outside the Avatar’s body remains in the draw() code. F. Create function Avatar.move that updates Avatar location and other Avatar state variables. Write documentation comments for this function. 7. I ADDED a 4-element array of Avatars as a global variable, along with a level variable to keep track of the level of Avatar being plotted, which is part of my global state. You may have something different. I changed the location update code at the bottom of draw() to update other cyclic global variables. That code no longer moves the Avatars, since those moves occur inside Avatar.move(…). G. Create an array of 2 or more Avatar objects. Write documentation comments for this array. page 2 8. I constructed the 4 Avatar objects and stored them in the avatars array within the top of the initial call to the draw() function. You must use the “new” operator when calling a constructor. H. Construct an Avatar object for each element of your array. 9. I added getX(), getSpeedX(), and setX() utility functions to class Avatar, and call them from draw() to assist with level-based drawing. I. You do not need to create utility functions nor keep track of levels. You do need to display all of the Avatars in your array at some point during execution. You must update the documentation comments at the top of the sketch to reflect Assignment 3 avatarClass. 10. I completed the assignment on time. J. You just turn it in on time to earn this last 10%. Update the documentation at the top of avatarClass. If I need to do use the mouse or keyboard to trigger some behavior, DOCUMENT THAT IN UPPER CASE IN A COMMENT NEAR THE TOP. Drop avatarClass.pde into D2L Dropbox Assignment 3 avatarClass by 11:59 PM on Tuesday November 22. Drop all image files used by the sketch into D2L as well. I need them all. Assignment 4 will require using the JPEG or PNG images that you are capturing (it will be a fastturnaround assignment), and Assignment 5 will be a small team project with multiple, interacting avatar classes. My example avatarClass sketch that meets these requirements is here. http://faculty.kutztown.edu/parson/fall2016/avatarClass.txt page 3
© Copyright 2026 Paperzz