Upon completing this assignment, you will be able to:
- Design and create new classes that use their own variables, have their own methods, and define their own constructors.
- Use arrays of objects to control complex animations.
- Structure Processing programs using multiple files.
This assignment will continue our work with visualizing poetry. In this assignment, you will create a dynamic visualization of a poem.
Specifically, you will create a class called PoemWord which stores and displays single words from your poem in the manner of your choosing. Your program will create one PoemWord object for each word in the poem, storing them in an array. While in the previous assignment you were expected to create a visual analog for each word, in this assignment you should display the words themselves (though you may vary the color, font, size, etc. of the text for different words and decorate them with additional shapes and forms). Your program must be dynamic, i.e. animated and/or interactive so that what we see on the screen changes over time. At least one aspect of each word (e.g. size, position, color, transparency) must change continuously with each new frame from the time it is created for at least 3 subsequent frames.
This assignment includes a series of 'finger exercises' to get you warmed up and ready for your unique design.
Design requirements for the visualization
Your original composition must fulfill the following requirements:
- Your program must be based on a class called PoemWord which you define and store in a separate file in your sketch.
- Your program must load the poem you have chosen in plain text from a file. It must parse each of the words out of the loaded file using split() or splitTokens(). For each word, it must create one PoemWord object and store it in an array.
- You are not required to display all the words at the same time on the screen, however over the course of interaction eventually all the words should be shown.
- Your composition must be original, i.e. it should not closely resemble examples covered in class nor your fellow classmates'. It is fine if it is inspired by examples for which source code is not readily available, or by your previous homework assignment.
- As always, your code must be clean, clear, and well-documented.
You should note that for many of these exercises it makes sense to copy and paste your answer to the previous problem as the start for your answer to the next problem. If particular finger exercises are covered in class, you can submit your in-class-created pair-programming version as a solution.
- Load the program
fe1 included in this assignment. Using the
Star class defined in this file, create a star with the parameters of your choice and display it on the screen.
- Write a dynamic program which has a String variable containing the sentence of your choice, and when draw() is called clears the screen and displays that sentence to the screen at the location of your choice.
- Modify this program to use a class called MyWord to store and display the string. First, define the class to have 3 fields: the characters in the string, and the x and y location of the string. Then, write a constructor that accepts a string, an x, and a y location and stores them in the local fields. Next, define a method, draw(), that displays the string to the screen. Then, in your top-level draw() function, create a global variable to store your MyWord object, create the object with the string you want it to hold, and call its draw() method to see it.
- Modify this program so that it splits the string up into its individual words using split() or splitToken(). Create a MyWord object for each of the individual words, and draw each to the screen.
- Modify this program so that it stores the MyWord class in a separate file in the sketch.
- Modify this program so that it first stores each of the MyWord objects in an array, and then in a separate for loop walks through this array to draw each word to the screen. Your array should start out as an empty array of 0 length, and you should use 'append' to add each word to it. Note you will not need to change the MyWord class for this to work.
- Modify this program to make the array of MyWord's a global variable, and move its initialization into setup(). In other words, the draw() function will only contain a loop that runs through the array and calls the draw() method for each object.
- Modify your MyWord class so that the word falls towards the bottom of the screen after it is first displayed. In other words, every time the word's draw() method is called, it increases the word's y coordinate. Note: for this step, you only need to change the MyWord class in its own file; you should make no changes to the main file, except to get rid of the noLoop() call in setup(), if you had one.
- Modify your program so that instead of displaying words out of a String, it displays lines out of a text file. In other words, when your program starts, it will read in a text file and create one MyWord object for each line in the file. As before, the MyWord will be stored in an array, and you will walk thorugh the array to display each piece of text to the screen.
- Modify your program so that instead of creating one MyWord object for each line in the file, it creates one for each word in each line in the file. This will require you, as in HW7, to loop twice: once for each line, then inside that loop once for each word.
For this assignment, please submit a zipped folder which contains both your finger exercises and your poem composition sketch. The poem sketch should include the poem text file you are using located properly to load when the sketch is started.
A+ - All required elements included, plus an interesting and creative approach to fulfilling the assignment requirements.
A - All required elements included and functioning correctly. Code is clean, clear and well-documented. Clear thought went into the selection of algorithmsused. Finger exercises completed satisfactorily.
B - Competent response to the assignment showing overall mastery of course material, with some small errors that do not greatly affect the quality of the assignment. For example, the code may be somewhat baroque (too complex for what it does), the choice of algorithms appears accidental, the code may be formatted incorrectly, or the finger exercises are poorly completed.
C - Some bigger errors, or a larger collection of smaller errors, but with potential to develop into a competent response. For example, the code may not run, but with a few small syntactical fixes would properly fulfill the assignment; the code may work but not be comprehensibly written; the code completely misses on one of the requirements, but still shows some understanding of the unit's material; or the finger exercises are not completed.
D - Serious errors show clear effort, but serious gaps in understanding, such as code that does not run and is not close to being correct, fulfills only part of a requirement, or is copied fairly directly from examples used in class.
F - Little demonstrated effort, or clear effort with no understanding, such as code fragments submitted which are only the start of a response to the assignment.