CST112 Project 7: Chapter 7
-
Design some object of your own (this should be a different object than the ones
you created for any previous project) that moves around the Processing output
window; be as creative as you can since your grade is
partially contingent on the complexity of the design
-
The size of the output window should be 400 by 400 pixels or larger
-
The initial location of the object should be in the center of
the output window and at the beginning the object should should
not be moving; use variables and system variables to manage the
initial location no matter what size is the output window
-
Incorporate a structured (modularized) design for this sketch
using the following programmer-designed functions called from
the
draw()
function:
 
-
drawBackground
()
draws the background for the
sketch which could include a background()
function call but
should additionally implement coding that creates a background
(no PImage
objects)
-
drawObject
()
there is no movement in this
function, just draw the object at the current x- and y-coordinate
locations; you might consider renaming this function to reflect
whatever object you are drawing (for example if your object is a
dog, the function could be called drawDog()
)
-
moveObject
()
add the current values of the
x and y 'speed' variables to the x- and y-coordinates variables
(you also could rename this function to reflect whatever object
you are drawing)
-
addMotion
()
start the object moving as follows:
-
If a keyboard key is pressed and it is the <
RIGHT
>
arrow key, set the value of the 'x-speed' variable to 1;
if a keyboard key is pressed and it is the <LEFT
>
arrow key, set the value of the 'x-speed' variable to -1;
otherwise set the value of the 'x-speed' variable to 0
-
If a keyboard key is pressed and it is the <
DOWN
>
arrow key, set the value of the 'y-speed' variable to 1;
if a keyboard key is pressed and it is the <UP
>
arrow key, set the value of the 'y-speed' variable to -1;
otherwise set the value of the 'y-speed' variable to 0
-
constrainObject
()
use the constrain()
function to limit both the x- and y-coordinates within the boundaries
of the output window so that the object never exits the window
(you also could rename this function to reflect whatever object
you are drawing)
 
-
A significant factor in grading on this assignment will
be based on your ability, to the greatest degree possible, to eliminate global variables
by passing arguments and returning values as follows:
 
-
No passing arguments or returning values (all variables are global)
maximum grade is 9 out of ten points
-
Either passing arguments or at least some returning values (minimal global variables)
maximum grade is 10 out of ten points
 
-
Hint: Use the modular approach in coding this application;
write one function at a time and test it to make sure it works before moving
on to the next function
 
-
Click this Play Project 7
link to view a sample application which demonstrates the type of functionality that
should be built into your sketch; however this is just an example since your assignment
is to create something completely different:
-
Insert the project number, your name, your e-mail address, the submission due
date and one or two sentences that describe the sketch as comments at the
beginning of the program; additionally comment each of the groups of variable
declarations as well as the sections of code
-
Students may work on all projects in teams of two or three,
and, if so, all students in the group must submit the same project to their own dropboxes
in Blackboard. In the text box's dropbox, as well as in the source code documentation
(comments), state the name(s) of the classmate(s) with whom you worked.
-
The completed project archived into a ".ZIP" file submitted
electronically via an attachment to a
Brightspace
dropbox is due to Prof. Struck no later than 11:59 p.m. on the date
listed in the course outline.