p1.py - import import import import columns_logic pygame...

This preview shows page 1 - 2 out of 4 pages.

import columns_logicimport pygameimport randomimport timeROWS = 12COLS = 6WHITE = (255, 255, 255)BLACK = (0, 0,0 )RED = (255, 0, 0)BLUE = (0, 0, 255)GREEN = (0, 255, 0)YELLOW = (255, 255, 0)ORANGE = (255, 150, 0)PINK = (255, 50, 255)GREY = (128, 128, 128)PURPLE = (100, 0, 200)DARKBLUE = (150, 0, 0)BROWN = (100, 50, 0)GOLD = (204, 204, 0)COLORS = {'A': RED, 'B': BLUE, 'C': GREEN, 'D': YELLOW, 'E': ORANGE,'F': PINK, 'G': GREY, 'H': PURPLE, 'I': DARKBLUE, 'J': BROWN, ' ': WHITE}class ColumnsGame:def __init__(self):self._running = Trueself._state = columns_logic.Columns(ROWS,COLS)self._screen = pygame.display.set_mode((600, 600), pygame.RESIZABLE)self._width = 600self._height = 600self._current_faller = columns_logic.Faller(0, [])self._clock = pygame.time.Clock()self._clock_counter = 0self._events_clock = 0#self._land_sound = pygame.mixer.Sound('SoftDrop.OGG')def run(self) -> None:'''the entire running of the game'''pygame.init()col, faller = self._produce_col(), self._produce_faller()self._current_faller = columns_logic.Faller(col, faller)while self._running:self._clock.tick(30)self._clock_counter += 1self._events_clock += 1if self._state.is_gameover(self._current_faller):self._end_game()if self._current_faller.is_frozen():if self._state.get_any_matches():time.sleep(0.5)self._state.erase_matches()else:

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture