Hi! I'm trying to create simple Tetris clone. I want to implement this: https://tetris.fandom.com/wiki/Lock_delay I need 0.5 seconds with player's control over the brick. I have no idea how to do that using pygame clocks.
You can find my full code here: https://github.com/yanazPL/Tetris/blob/main/main.py (it's not finished) Skeleton of my code is below: class Brick: """Represents active brick which player can control""" def touches_ground(self): """Checks whether brick is touching last row of world""" def touches_tile(self): """Checks if brick touches any non-brick tile""" def freeze(self): """Ends control of player over the bricks""" class GameState: def update(self): """Non player controlled after-move actions are here""" if (self.brick.touches_ground() or self.brick.touches_tile()): # I WANT TIME FOR MOVEMENT/ROTATION HERE self.brick.freeze() self._clear_lines() self.respawn() else: self.move_bricks_down() # check lines def move_bricks_down(self): epoch_dividor = 20 brick = self.brick if self.epoch >= epoch_dividor: brick.move( (brick.position[0], brick.position[1] + 1) ) self.epoch = 0 self.epoch += 1 class UserInterface(): """ user actions and game state. Uses pyGame""" def __init__(self): pygame.init() # Game state self.game_state = GameState() #window management here ... self.clock = pygame.time.Clock() self.running = True def reset(self): self.game_state = GameState() self.clock = pygame.time.Clock() def process_input(self): """Processing inupt here ...""" def update(self): self.game_state.update() if self.game_state.game_lost(): self.running = False def draw(self): """Drawing tiles with approperiate colors ...""" def run(self): """Runs the game loop""" while True: self.process_input() if self.running: self.update() self.draw() self.clock.tick(UserInterface.FPS) if __name__ == "__main__": UserInterface().run()