def __init__(self) -> None: self.move_timer = 0 self.text = Text("select player", (200, 200, 200), 30, Position(s.WIN_W / 2, 50)) self.text2 = Text( "Start to change current player name", (200, 200, 200), 15, Position(s.WIN_W / 2, 75), ) self.text3 = Text("A to play", (200, 200, 200), 15, Position(s.WIN_W / 2, 95)) self.name_input = NameInput() self.name_input_enabled = False self.player_button = SwitcherButton( save.score_list.players, 0, (200, 200, 200), 20, Position(s.WIN_W / 4 + 20, s.WIN_H / 2), horizontal=True, ) self.level_button = SwitcherButton( list(map(str, range(31))), 0, (200, 200, 200), 20, Position(s.WIN_W * 3 / 4, s.WIN_H / 2), horizontal=False, )
def set_3_rotation(self) -> None: x = self.position.x y = self.position.y self.body[0].position = Position(x + s.CELL_SIZE, y) self.body[1].position = Position(x + 2 * s.CELL_SIZE, y) self.body[2].position = Position(x + s.CELL_SIZE, y + s.CELL_SIZE) self.body[3].position = Position(x + s.CELL_SIZE, y + 2 * s.CELL_SIZE)
def __init__(self) -> None: self.btn = self.ButtonPos.PLAY self.state = MenuState.MAIN self.main_screen = [] self.score_screen = [] self.main_screen.append( Button( "PLAY", self.ButtonPos.PLAY.value, 50, Position(s.WIN_W * s.scale / 2, 130 * s.scale), utils.window_manager.window, )) self.main_screen.append( Button( "SCORE", self.ButtonPos.SCORE.value, 30, Position(s.WIN_W * s.scale / 2, 200 * s.scale), utils.window_manager.window, )) self.main_screen.append( Button( "QUIT", self.ButtonPos.QUIT.value, 30, Position(s.WIN_W * s.scale / 2, 250 * s.scale), utils.window_manager.window, )) self.update_score() self.start_menu = StartMenu()
def __init__( self, options: list, current_index: int, color: tuple, size: int, position: Position, horizontal: bool = True, ) -> None: self._options = options self._current_index = current_index self.color = color self.size = size self.position = position self.horizontal = horizontal self._text = Text(options[current_index], color, size, position) if horizontal: self.width = int(size * (len(options[current_index])) / 3.3 + 5) self.ar1 = Arrow( Position(self._text.position.x - self.width, self._text.position.y), size, horizontal=True, flip=False, tag="Left", ) self.ar2 = Arrow( Position(self._text.position.x + self.width, self._text.position.y), size, horizontal=True, flip=True, tag="Right", ) else: self.ar1 = Arrow( Position(self._text.position.x, self._text.position.y - size), size, horizontal=False, flip=False, tag="Up", ) self.ar2 = Arrow( Position(self._text.position.x, self._text.position.y + size), size, horizontal=False, flip=True, tag="Down", )
def update_score(self) -> None: self.score_screen = [] self.score_screen.append( Text("High scores:", (200, 200, 200), 30, Position(s.WIN_W / 2, 50))) for i, score in enumerate(high_score.score_list.score_list): self.score_screen.append( Text( (score[0] + ": " + str(score[1])) if score[1] != 0 else "...vacant...", (200, 200, 200), 20, Position(s.WIN_W / 2, 100 + (i + 1) * 30), ))
def __init__(self) -> None: self.position = Position(5 * s.CELL_SIZE, 0) self.state = 0 self.body = [Cube() for _ in range(4)] self._move_timer = 0 self._fall_timer = 0 self.moved = False self.landed = False
def change() -> None: global next_one, x next_one = tetromino.generator.get_new() next_one.position = Position(0, 0) next_one.set_0_rotation() if type(next_one) == tetromino.tetromino_collection.TypeI: x = 250 elif type(next_one) == tetromino.tetromino_collection.TypeO: x = 270 else: x = 260
def __init__(self) -> None: self.name = "enter your name" self.letter = "A" self.buttons = [] self.move_timer = 0 self.plate = pygame.Surface((300 * s.scale, 300 * s.scale)) self.game_over = Text("Name change", (255, 255, 255), 30, Position(s.WIN_W // 2, s.WIN_H // 4)) self.name_text = Text(self.name, (255, 255, 255), 30, Position(s.WIN_W // 2, s.WIN_H * 2 // 4)) self.press_a_btn = Text( "A to select letter", (255, 255, 255), 15, Position(s.WIN_W // 2, s.WIN_H * 3 // 4), ) self.press_start_btn = Text( "Start to confirm", (255, 255, 255), 15, Position(s.WIN_W // 2, s.WIN_H * 3 // 4 + 15), ) self.press_b_btn = Text( "B to clear letter", (255, 255, 255), 15, Position(s.WIN_W // 2, s.WIN_H * 3 // 4 + 30), ) x0 = 0 y0 = 0 for letter in LETTERS: x = x0 * 15 * s.scale + 90 * s.scale y = y0 * 20 * s.scale + 75 * s.scale self.buttons.append( Button(letter, letter, 14, Position(x, y), self.plate)) x0 += 1 if x0 == 9: x0 = 0 y0 += 1
def __init__(self) -> None: self.text_color = (200, 200, 200) self.next_text = Text("next", self.text_color, 20, Position(290, 20)) self.lines_cleared_block = UIBlock(Position(290, 120)) self.lines_cleared_block.add( Text("cleared", self.text_color, 20, Position(0, 0))) self.lines_cleared_block.add( Text("0", self.text_color, 20, Position(0, 0))) self.score_block = UIBlock(Position(290, 180)) self.score_block.add(Text("score", self.text_color, 20, Position(0, 0))) self.score_block.add(Text("0", self.text_color, 20, Position(0, 0))) self.level_block = UIBlock(Position(290, 240)) self.level_block.add(Text("level", self.text_color, 20, Position(0, 0))) self.level_block.add(Text("0", self.text_color, 20, Position(0, 0))) self.pause = Text("PAUSE", (255, 255, 255), 20, Position(s.GAME_W // 2, s.GAME_H // 2)) self.game_over = Text("GAME OVER", (255, 255, 255), 20, Position(s.GAME_W // 2, s.GAME_H // 2)) self.score_plate = NameInput() self.fps = Text("fps: 60", self.text_color, 20, Position(290, 400))
def __init__(self) -> None: super().__init__() self.position = Position(4 * s.CELL_SIZE, -s.CELL_SIZE) self.set_0_rotation() for i in self.body: i.color_tag = "TypeI"
def generate_sides(self) -> None: for i in range(-1 * s.CELL_SIZE, s.ROWS * s.CELL_SIZE, s.CELL_SIZE): self.positions.append(Position(0, i)) self.positions.append(Position((s.COLUMNS + 1) * s.CELL_SIZE, i))
def generate_floor(self) -> None: for i in range(0, s.COLUMNS * s.CELL_SIZE, s.CELL_SIZE): self.positions.append( Position(i + 1 * s.CELL_SIZE, (s.ROWS - 1) * s.CELL_SIZE))