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.
The following are a few examples of potential extensions. Please do not feel that your extensions must be drawn from this list. Get creative, design extensions that interest you, and explain why they are awesome when you present the results in your writeup. Your interest in your own extensions really does make a difference.
Make a new wiki page for your assignment. Put the label
on the page. Each of you needs to make your own writeup.
In addition to making the wiki page writeup, put the python files you wrote on the Courses server in your private directory in a folder named project10.
In general, your writeup should follow the outline below.
© 2018 Caitrin Eaton.