12.1

In-Class Assignment 

Create an array of 6 buttons. The buttons should default to black, however when they’re clicked on, they should turn “on” and reveal an image. All six buttons should reveal a different image.

Some hints to get you started-

Create a “button” class.
The button class should have the following data associated with it: int’s x, y, w, h, boolean on, PImage image
The button class should have the following functions: display (if the button is ‘on’, show the image, if it’s not, show a black box) and clickedOn (the mouse’s coordiantes should be passed into this function, and if the mouseX and mouseY are over the button, the button is “on”).

When you make a new button, you should pass in the x, y, w, h, and the image to be displayed.

Another hint- if you make another array of 6 images, you can pass in images[i].

Even more of a hint – if your window is 800 px wide and your images are 100px wide, you can make your x argument i*125+25

This is worth the same number of points as a homework assignment. Depending on how far we get as a class today, we may continue to work on this on Thursday. You may work in pairs for this assignment.

Homework

Come up with what you would like to do for your final assignment. This should be a NEW idea similar to the midterm in that it is an interactive application with a  purpose- either a game, an animation, etc. Exceptions will be made if you are passionate about continuing to work on your midterm, but you must come talk to me about that and I will be expecting to see major additions (and for you to complete everything you set out to do). Specific requirements for the final are forthcoming, however you should expect to use Object Oriented Programming and arrays. Create a blog post explaining your idea and be prepared to present your ideas in class on Thursday.

Leave a Reply

Your email address will not be published. Required fields are marked *