def newBlock(self): self.down = False self.currentBlock = self.nextShapes.pop(0) self.nextShapes.append(Shapes.Shapes(3, 0, self.picked)) self.picked = self.nextShapes[-1].picked if self.intersects(): self.gameOver = True
def __init__(self, resultsQueue): self.height = 24 self.width = 10 self.field = [ ] # Initialising the field with this for some reason breaks things [[0]*self.width]*self.height self.currentBlock = None self.score = 0 self.linesCleared = 0 self.level = 0 self.down = False self.gameOver = False self.reserved = None self.startX = (1920 / 2) - ( self.width * (35 / 2) ) #The top left of the grid's x cord, 35 is how big each square is in units self.startY = (1080 / 2) - ( self.height * (35 / 2) ) #The top left of the grid's y cord, 35 is how big each square is in units self.nextShapes = [] self.resultsQueue = resultsQueue for i in range(3): self.picked = self.nextShapes.append( Shapes.Shapes(3, 0, self.picked)) self.picked = self.nextShapes[-1].picked for i in range(self.height): newRow = [] for j in range(self.width): newRow.append(0) self.field.append(newRow)
def __init__(self, handle): super(PeterActivity, self).__init__(handle) # Build the activity toolbar. toolbox = activity.ActivityToolbox(self) activity_toolbar = toolbox.get_activity_toolbar() activity_toolbar.keep.props.visible = False activity_toolbar.share.props.visible = False toolbox.show() self.set_toolbox(toolbox) # Create the game instance. self.game = Shapes.Shapes() # Build the Pygame canvas. self._pygamecanvas = \ sugargame.canvas.PygameCanvas(self) # Note that set_canvas implicitly calls # read_file when resuming from the Journal. self.set_canvas(self._pygamecanvas) self.game.canvas=self._pygamecanvas # Start the game running. self._pygamecanvas.run_pygame(self.game.run)