due: Tuesday, September 23, 8pm
Conditionals and keyboard interaction. Create a composition that is dynamic and changing in discrete and discontinuous ways (unlike last week when you created dynamic interaction in smooth and continuous ways). You can start with your abstract interaction from last week (part 2) as a starting point, or you can create something totally new.
Use conditionals (if statements) so that your
sketch makes abrupt, non-continuous changes. Use
conditionals with keyboard interaction so that the user can
affect the behavior with key commands. Do you want these
keyboard commands to be single presses? If so, use the
new def keyPressed(): block. Do you want the
keys to be held down? If so, use key inside a
conditional in the def draw(): block.
Making things move (on their own). Build on part 1 or start something new, but either way, please start a new Processing sketch. (If you're building on part 1, say File > Save As... and rename.) Add some elements to your composition that move on their own. Think about how they are moving (horizontally? vertically? both? Always in one direction, or in a changing direction?) and add a variable for each dynamic aspect.
Use conditionals to control this motion. For example, maybe your moving elements bounce off the walls of the draw window, or consider integraing a raster image as a background and create the effect that your moving elements are crossing a road, or through a pipe. Can you use keyboard interaction to influence the movement? For example to change speed, direction, or something else.
Consider this an optional challenge if you're up
for it. At this point, you have all the elements to
implement something like basic game play. Can you create one
sketch with: (a) an object or character that the user
controls with the keyboard, and (b) an object or character
that moves on its own? If you get that far, try to code some
behavior that is triggered when the user-controlled object
touches the self-movingx object. You can use
dist()
(reference)
to determine the distance between two x,y points —
perhaps you can use this to determine if two elements have
collided (if their distance is less than some amount).