# play.py # YOUR NAME(S) AND NETID(S) HERE # DATE COMPLETED HERE """Subcontroller module for Breakout This module contains the subcontroller to manage a single game in the Breakout App. Instances of Play represent a single game. If you want to restart a new game, you are expected to make a new instance of Play. The subcontroller Play manages the paddle, ball, and bricks. These are model objects. Their classes are defined in models.py. Most of your work on this assignment will be in either this module or models.py. Whether a helper method belongs in this module or models.py is often a complicated issue. If you do not know, ask on Piazza and we will answer.""" from constants import * from game2d import * from models import * # PRIMARY RULE: Play can only access attributes in models.py via getters/setters # Play is NOT allowed to access anything in breakout.py (Subcontrollers are not # permitted to access anything in their parent. To see why, take CS 3152) class Play(object): """An instance controls a single game of breakout. This subcontroller has a reference to the ball, paddle, and bricks. It animates the ball, removing any bricks as necessary. When the game is won, it stops animating. You should create a NEW instance of Play (in Breakout) if you want to make a new game. If you want to pause the game, tell this controller to draw, but do not update. See subcontrollers.py from Lecture 25 for an example. INSTANCE ATTRIBUTES: _paddle [Paddle]: the paddle to play with _bricks [list of Brick]: the list of bricks still remaining _ball [Ball, or None if waiting for a serve]: the ball to animate _tries [int >= 0]: the number of tries left As you can see, all of these attributes are hidden. You may find that you want to access an attribute in class Breakout. It is okay if you do, but you MAY NOT ACCESS THE ATTRIBUTES DIRECTLY. You must use a getter and/or setter for any attribute that you need to access in Breakout. Only add the getters and setters that you need for Breakout. You may change any of the attributes above as you see fit. For example, you may want to add new objects on the screen (e.g power-ups). If you make changes, please list the changes with the invariants. LIST MORE ATTRIBUTES (AND THEIR INVARIANTS) HERE IF NECESSARY """ # GETTERS AND SETTERS (ONLY ADD IF YOU NEED THEM) # INITIALIZER (standard form) TO CREATE PADDLES AND BRICKS # UPDATE METHODS TO MOVE PADDLE, SERVE AND MOVE THE BALL # DRAW METHOD TO DRAW THE PADDLES, BALL, AND BRICKS # HELPER METHODS FOR PHYSICS AND COLLISION DETECTION # ADD ANY ADDITIONAL METHODS (FULLY SPECIFIED) HERE