def __init__(self, path, ball, frame: Frame, paddle, activetime, brick_layout): self.brick_layout = brick_layout self.path_object = path self.ball = ball self.frame = frame self.point = path.point self.paddle = paddle self.dimension = Dimension(POWERUPWIDTH, PADDLEHEIGHT) self.shape = self.shape_powerup() self.gravity = POWERUPGRAVITY self.speedx = path.speedx self.speedy = path.speedy self.directionx = path.direction_x self.directiony = path.direction_y self.display = True self.toc = time.time() self.tic = time.time() self.gtoc = time.time() self.gtic = time.time() self.gravityTP = POWERUPGRAVITYTP self.skip_iteration_tp = BALLSTEPTP self.flag = 0 self.active = False self.active_time = activetime self.atic = time.time() self.draw()
def __init__(self, point: Point, frame: Frame): ''' constructor of a single brick ''' self.break_brick_time = 1 self.point = point self.dimension = Dimension(BRICKWIDTH, BRICKHEIGHT) self.shape = self.initial_shape(Back.WHITE, Style.DIM) self.frame = frame
def __init__(self, frame: Frame): ''' constructor of the brick layout ''' self.frame = frame self.total_bricks = 0 self.point = Point(LAYOUTXOFFSET, LAYOUTYOFFSET) self.dimension = Dimension(LAYOUTWIDTH, LAYOUTHEIGHT) self.location_n_type_matrix = self.generate_location_n_type_matrix() self.brick_matrix = self.make_brick_matrix(self.frame)
def get_dimension(self): ''' Gets dimension of the UFO ''' height = len(self.shape) width = -1 for i in range(height): if width < len(self.shape[i]): width = len(self.shape[i]) return Dimension(width, height)
def add_cannon(self): r1 = [ self.shape[0][0] for i in range(self.dimension.width)] r2 = [ " " for i in range(self.dimension.width)] r2[0] = f"{Fore.GREEN}{Style.BRIGHT}^{Style.RESET_ALL}" r2[-1] = f"{Fore.GREEN}{Style.BRIGHT}^{Style.RESET_ALL}" r3 = [ " " for i in range(self.dimension.width)] r3[0] = f"{Fore.GREEN}{Style.BRIGHT}^{Style.RESET_ALL}" r3[-1] = f"{Fore.GREEN}{Style.BRIGHT}^{Style.RESET_ALL}" self.shape = [r1,r2, r3] self.dimension = Dimension(self.dimension.width,3) self.draw()
def __init__(self,frame: Frame): self.paddlestepx = PADDLESTEPX self.frame = frame self.shape = self.initial_shape(PADDLEWIDTH,PADDLEHEIGHT) self.dimension = Dimension(PADDLEWIDTH,PADDLEHEIGHT) self.point = Point( randint(50, FRAMEWIDTH-4*PADDLEWIDTH), randint(FRAMEHEIGHT-5,FRAMEHEIGHT-5) ) self.health = PADDLEHEALTH self.draw()
def __init__(self, frame, point, brick_layout, ball): self.frame = frame self.ball = ball self.brick_layout = brick_layout self.point = Point(point.x, point.y) self.dimension = Dimension(1, 1) self.shape = [[f"{Fore.GREEN}{Style.BRIGHT}|{Style.RESET_ALL}"]] self.used = False self.direction_x = False self.direction_y = True self.speedx = 0 self.speedy = 1 self.draw()
def __init__(self, frame: Frame): ''' constructor of the brick layout ''' self.frame = frame self.total_bricks = 0 self.point = Point(LAYOUTXOFFSET, LAYOUTYOFFSET) self.dimension = Dimension(LAYOUTWIDTH, LAYOUTHEIGHT) self.location_n_type_matrix = self.generate_location_n_type_matrix() self.brick_matrix = self.make_brick_matrix(self.frame) self.shift_down = SHIFTDOWN self.shift_down_after = SHIFTDOWNSTARTAFTER self.formed_time = time.time() self.lowermost = self.get_lowermost_layout_point()
def __init__(self, ufo): ''' constructor for the class ''' self.ufo = ufo self.point = Point( (self.ufo.point.x + (self.ufo.dimension.width // 2)), self.ufo.point.y + self.ufo.dimension.height) self.dimension = Dimension(1, 1) self.shape = [[ f"{Fore.RED}{Back.WHITE}{Style.BRIGHT}o{Style.RESET_ALL}" ]] self.blasted = False self.draw()
def remove_cannon(self): old_shape = self.shape old_d = self.dimension self.shape = self.initial_shape(PADDLEWIDTH,PADDLEHEIGHT) self.dimension = Dimension(PADDLEWIDTH,PADDLEHEIGHT) self.frame.restore_frame(self.point,self.shape,self.dimension,self.point,old_shape,old_d)