Due: , 11:59 pm
The focus on this project is to give you more experience writing child classes, working with equations and code, and integrating user input.
The first task is to create a RotatingBlock class. You could create this in your physics_objects.py file or you could create a new file. The choice is yours. The class should be called RotatingBlock, and it should inherit from the Thing class, just like Ball, Wall, Floor and Block. The RotatingBlock.__init__() method should have the following arguments.
|win||A reference to a GraphWin object|
|x0||The anchor point x value. The anchor is in the middle of the left side.|
|y0||The anchor point y value. The anchor is in the middle of the left side.|
|width||The horizontal distance of the floor.|
|height||The vertical distance of the floor.|
|Ax||The anchor point X value, with the default value of None.|
|Ay||The anchor point Y value, with the default value of None.|
As with the Ball class, the first action in the __init__() method is to call the parent Thing.__init__() method. Specify the type as the string "rotating block", and pass in [x0, y0] as the position. Next, assign the parameters width and height to two fields width and height.
Next, create the list of vertex points (self.points), which should be a list of four 2-element lists. The coordinates of the block should be (-width/2, -height/2), (width/2, -height/2), (width/2, height/2), and (-width/2, height/2).
The remaining unique fields should be identical to the ones you created in the RotatingLine class: angle, rvel, anchor, and drawn. Note that scale and vis are already created in the Thing parent class.
Make the methods draw(), getAngle(), setAngle(), getAnchor(), setAnchor(), getRotVelocity(), setRotVelocity(), and rotate(). These should be very similar, if not identical to the RotatingLine class from lab.
Make the render() method. Again, this will be identical to the RotatingLine version except that the last step will be to create a graphics Polygon instead of a Line, using the list of rotated points. At this point, you can run the first test function. You may need to modify the test code, depending on where you wrote your RotatingBlock class. The block should spin around once.
Next, you need to create an update() method in the RotatingBlock class,
since the Thing.update method does not include rotational velocity.
The update() method needs to take self and dt (time step) as arguments.
The update() method should first calculate how much the angle changes
during the time step (
self.rvel * dt) and assign that to a local
variable (e.g. da). If the da value is not equal to zero, then call
the rotate() method, passing in da as the argument. Then, call the
update() method in the Thing class, passing in self and dt.
Once you have the update() method done, try out the second second test function. Since the anchor point is different, the block should appear to rotate around the center of the screen.
Create a very simple obstacle course with one or two rotating objects. Launch one or more balls into the scene.
Create a video of your simple obstacle course in action and include a link to it on your wiki.
Create a scene that includes at least one rotating object and incorporates some form of user interaction. For example, add paddles to your pinball-style scene from last week that activate when the user hits the space bar. Make something very simple that responds to user input before doing anything more complex.
Create a video of your reactive scene in action and include a link to it on your wiki.
Each assignment will have a set of suggested extensions. The required tasks constitute about 85% of the assignment, and if you do only the required tasks and do them well you will earn a B+. To earn a higher grade, you need to undertake one or more extensions. The difficulty and quality of the extension or extensions will determine your final grade for the assignment. One complex extension, done well, or 2-3 simple extensions are typical.
The following are a few suggestions on things you can do as extensions to this assignment. You are free to choose other extensions.
Turn in your code by putting it into your private hand-in directory on the Courses server. All files should be organized in a folder titled Project10 and you should include only those files necessary to run the program. We will grade all files turned in, so please do not turn in old, non-working, versions of files.
Make a new wiki page for your assignment. Put the label cs152f17project10 in the label field on the bottom of the page. But give the page a meaningful title (e.g. Caitrin's Project 10).
In general, your intended audience for your write-up is your peers not in the class. Your goal should be to be able to use it to explain to friends what you accomplished in this project and to give them a sense of how you did it. Follow the outline below.
When you are done with the lab exercises, you may start on the rest of the project.
© 2018 Caitrin Eaton.