Example #1
0
 def __init__(self, width=1024, height=600):
     """ Create pong court of 'width' and 'height' """
     # Get __init__ from _Screen
     super().__init__()
     # Get __init__ from TurtleScreen (parent class of _Screen)
     TurtleScreen.__init__(self, self._canvas)
     # Borrow piece of code from turtle module, to initialize screen
     if Turtle._screen is None:
         Turtle._screen = self
     # Setup court
     self.width = width
     self.height = height
     self.setup(self.width + 100, self.height + 50)
     self.screensize(self.width, self.height)
     self.title("Pong")
     self.bgcolor("black")
     self.delay(8)
     # Define size of score board, above the play field
     self.score_height = self.height / 10
     # Offset 0 axis line, due to score bar
     self.yzero = -(self.height / 2 - (self.height - self.score_height) / 2)
     self.top_border = ((self.height / 2) -
                        self.score_height)
     self.low_border = -self.height / 2
     self.right_border = self.width / 2
     self.left_border = -self.width / 2
Example #2
0
 def __init__(self):
     super().__init__()
     TurtleScreen.__init__(self, self._canvas)
     if Turtle._screen is None:
         Turtle._screen = self
     self.setup(500,500)
     self.screensize(1000,1000)
     self.title("Title")
     self.bgcolor("black")
     self.root = self._canvas._root()
     self.menubar = tk.Menu(self.root)