def can_rotate(self, field, direction): next_rotation = self.rotation.apply(direction) rotated = Rotator(self.mino_type.value, next_rotation).rotate() if self.__is_collision(field, Blocks(rotated), self.position): return False else: return True
def __init__(self) : QObject.__init__(self) # empty lists (filled with readProdukte and readZettel) #self.blocks = [] self.blocks = Blocks() self.bcs = BCs() self.postRefine = 10
def gen_next_shape(self): self.next_blocks = Blocks(width=self.width) self.next_blocks.gen_new_block() self.ui_data.next_blocks = self.next_blocks.blocks
def __update_ceched_blocks(self): rotated = Rotator(self.mino_type.value, self.rotation).rotate() self.blocks = Blocks(rotated)
from turtle import Screen from ball import Ball from paddle import Paddle from block import Blocks from score import Scoreboard screen = Screen() screen.screensize(canvheight=500, canvwidth=600) screen.bgcolor("black") screen.title("break-out") # object call ball = Ball() paddle = Paddle() blocks = Blocks() scoreboard = Scoreboard() # events screen.listen() screen.onkey(paddle.move_left, "a") screen.onkey(paddle.move_right, "d") # game game = True while game: ball.move() # wall clash if ball.xcor() > 290 or ball.xcor() < -290: ball.x_bounce() if ball.ycor() > 250: ball.y_bounce()
from block import Blocks class SimpleDraw(object): def __init__(self, one_block): self.figure = plt.figure() self.ax = self.figure.gca() self.width = len(one_block) self.height = len(one_block[0]) for j, row in enumerate(one_block): for i, item in enumerate(row): if item == 1: self._draw_one_point(i, j) self.ax.figure.canvas.draw() def draw(self): plt.axis('equal') plt.grid() plt.show() def _draw_one_point(self, px, py): rect = Rectangle((px, py), 1, 1) self.ax.add_patch(rect) if __name__ == "__main__": block = Blocks() one_block = block.gen_block(4, 3) ui = SimpleDraw(one_block) print(one_block) ui.draw()