Пример #1
0
 def __init__(self, canvas, column: int, garbage_frame: str):
     self.rows_number, self.columns_number = canvas.getmaxyx()
     self.column = max(column, 0)
     self.column = min(column, self.columns_number - 1)
     self.row = 0
     self.frame = garbage_frame
     x, y = get_frame_size(self.frame)
     self.speed = GARBAGE_SPEED - math.sqrt(x * y) / 100
     self.destroyed = False
Пример #2
0
async def explode(canvas, center_row: int, center_column: int) -> None:
    rows, columns = get_frame_size(EXPLOSION_FRAMES[0])
    corner_row = center_row - rows / 2
    corner_column = center_column - columns / 2

    curses.beep()
    for frame in EXPLOSION_FRAMES:
        draw_frame(canvas, corner_row, corner_column, frame)

        await asyncio.sleep(0)
        draw_frame(canvas, corner_row, corner_column, frame, negative=True)
        await asyncio.sleep(0)
Пример #3
0
async def show_game_over(canvas) -> None:
    """Show game over message."""
    max_y, max_x = canvas.getmaxyx()
    filename = 'gameplay/frames/game_over.txt'
    with open(filename) as f:
        frame = f.read()
    rows, columns = get_frame_size(frame)
    draw_row = max_y // 2 - rows // 1.5
    draw_column = max_x // 2 - columns // 1.5
    while True:
        draw_frame(canvas, draw_row, draw_column, frame)
        await asyncio.sleep(0)
Пример #4
0
 def get_gun_coords(self) -> Tuple[int, int]:
     """Get spaceship gun coords (up center)."""
     rows, columns = get_frame_size(self.current_frame)
     return self.row, self.column + columns // 2
Пример #5
0
 def size(self) -> Tuple[int, int]:
     return get_frame_size(self.current_frame)