Assignment
When you complete a task, show it to me, and I will record that you got points for that task.
The listed due date is the last day we will have to work on these problems in-class. Any tasks you show me during class or e-mail to me by midnight that day will be worth full credit. (I will usually still ask to see e-mailed problems in class the next day.) After that day, tasks will earn you 20% fewer points per day. You can still get full credit on the assignment for 3 class days after the due date.
For all these problems you are required to use arrays and loops to avoid writing similar lines of code many times. Additionally, if only some elements of an array are relevant, you should make sure your code only uses those elements.
Tasks
1) Write a program that, every time you click the mouse, creates an ellipse at the mouse's location. The ellipse should then gradually move down at a constant rate. You don't need to worry about removing the ellipses from the array when they leave the screen, or making them stay on the screen.
2) Write a program that, whenever you press a letter key, displays that letter at the current location of the mouse (and keeps it there). This doesn't need to behave nicely if you press non-letter keys. (Hint: You will need to create a String array. In order to turn the key variable into a String, you can just add it to an empty string, like this: ""+key. There's no space in between those quotes.)
Tasks
1) Write a program that creates an ellipse every time you click the mouse, at the mouse's location. If you press 'a', then it should erase the earliest drawn ellipse that is still showing. If you press 'z' then it should erase the most recently drawn ellipse that is still showing.
2) Write a program that creates a rectangle every time you click, drag, and then release the mouse. One corner of the rectangle should be where you click the mouse, and the opposite corner should be where you release the mouse. The rectangle doesn't need to be shown while you are dragging the mouse, it can just show up when you release the mouse. (Hint: you will probably want to use the mousePressed() method to record where you click the mouse, and the mouseReleased() method to actually create the rectangle.)
Tasks
1) Write a program that allows you to "throw" ellipses on the screen. Whenever you click, drag, and release the mouse, it should create an ellipse where you release the mouse. The velocity of the ellipse should be proportional to how far you dragged the mouse...the further you dragged it, the faster it goes... and should be in the direction you dragged the mouse. (Hint: this means that the x-velocity should be proportional to x-distance you moved the mouse, and y-velocity is proportional to y-distance.) The ellipse should then bounce around the screen. Make it so that the ellipses move at a reasonable velocity for reasonable mouse movements, not super fast.
a. You can turn this into a 30 point task by having each ellipse bounce 3 times, and then disappear.
2) Write a program that creates ellipses at the bottom of the screen. They should always start out moving upwards, but they should have a random x velocity (that includes sometimes being to the right and sometimes being to the left). They should also all accelerate downwards (gradually changing y velocity). After they reach their peak and start falling back down, they should disappear when they are within 100 pixels of the bottom of the screen.
Tasks
1) Write a program that starts with several ellipses bouncing around the screen. Every time you click the mouse, it should create a black dot (a small ellipse) that moves straight upwards. If a dot hits one of the bouncing ellipses, both the dot and the big ellipse should disappear (and be removed from their respective arrays). If the dot gets to the top of the screen, it should disappear and be removed from its array.