In this exercise we will create a vector class. Start with this class definition skeleton (vector.py). Fill in the methods so that the class passes all of the tests at the bottom of the skeleton. When all the tests pass, submit the file vector.py through the online turnin form.
Import vector.py into a new processing sketch and continue on to the next exercise.
In this exercise we will create a Processing sketch that lets the user place bouncing balls on the canvas. Read about simulated Newtonian motion to help you write your program. Write a sketch that:
allows the user to click on the canvas to create a new ball there with random x and y velocities (each between -10 and 10).
uses gravity to attract the balls towards the bottom boundary of the canvas.
lets the balls bounce off of the walls at the edges of the canvas.
represents the balls using a Ball class. The Ball initializer method should accept at least the initial position vector and initial velocity vector.
In addition, the Ball class should have an update() method that updates the position of the ball according to the velocity and acceleration. And, a draw() method that draws the ball.
Finally, the vector class defined in vector.py should be used to represent the position, velocity, and acceleration as vectors. Add the vector.py file that you created in the previous exercise to your processing sketch and put from vector import * at the top of your processing sketch.
uses a list to hold all of the ball objects.
includes some kind of Above & Beyond element. Note: It's okay if this replaces some of the earlier requirements. For example, the slingshot effect that I built replaces the original mouse click behavior specified in point (a).
Submit the .pyde file for your sketch using the
the online turnin form. If you have
added further methods to the vector class, please also submit your
revised vector.py
file.
Submit a proposal for a game in a separate file named proposal.txt
.
After receiving feedback from me about the feasibility of the idea, you
and your current partner will program the game in Processing for the
final homework assignment.
You should have submitted three files using the online turnin form: vector.py, bouncy_balls.pyde (or something similar), and proposal.txt. Individually complete the assignment Wrapper on Google Forms.
owercase_with_underscores
for functions and variables;
Created April 3, 2016
Last revisedApril 19, 2016, 09:31:28 AM PDT
Acknowledgements: This assignment
is adapted from one
developed by Karen Reid and disseminated through SIGCSE Nifty
Assignments.
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.