From 5bc969328cf265e8a90f56872981ba70e4e26b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20G=C3=B6r?= Date: Sat, 15 Jul 2023 13:47:34 +0300 Subject: [PATCH] tetris example 1 --- python-temel/tetris.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 python-temel/tetris.py diff --git a/python-temel/tetris.py b/python-temel/tetris.py new file mode 100644 index 0000000..c3fd781 --- /dev/null +++ b/python-temel/tetris.py @@ -0,0 +1,39 @@ +class Shape: + pass + +class SquareShape(Shape): + def move_down(self): + print('SquareShape moves down') + +class BarShape(Shape): + def move_down(self): + print('BarShape moves down') + +class TShape(Shape): + def move_down(self): + print('TShape moves down') + +class LShape(Shape): + def move_down(self): + print('LShape moves down') + +class ZShape(Shape): + def move_down(self): + print('ZShape moves down') + +import random +import time + +class Tetris: + def get_random_shape(self): + return random.choice([ZShape, TShape, SquareShape, BarShape, LShape])() + + def run(self): + while True: + shape = self.get_random_shape() + for i in range(20): + shape.move_down() + time.sleep(0.5) + +tetris = Tetris() +tetris.run()