summaryrefslogtreecommitdiff
path: root/pycameltris/piece.py
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2021-11-12 13:32:37 +0100
committerOlivier Gayot <olivier.gayot@sigexec.com>2021-11-12 13:32:37 +0100
commitadf005bd29a395b653df1d990aa72694360a11dc (patch)
treed3cf034b95fc38c0e2d0217581d5e5f7f3689b43 /pycameltris/piece.py
parent5bbc2d3008910bb9c1f9eb07d7dde5bda8aa52f4 (diff)
Rename the package cameltris and provide __main__.py
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'pycameltris/piece.py')
-rw-r--r--pycameltris/piece.py128
1 files changed, 0 insertions, 128 deletions
diff --git a/pycameltris/piece.py b/pycameltris/piece.py
deleted file mode 100644
index 2f3e7ce..0000000
--- a/pycameltris/piece.py
+++ /dev/null
@@ -1,128 +0,0 @@
-import pygame
-
-
-square_template = pygame.Surface((48, 48))
-
-black = (0, 0, 0)
-white = (0xff, 0xff, 0xff)
-brown = (163, 75, 31)
-blue = (30, 34, 164)
-green = (30, 164, 59)
-red = (164, 30, 30)
-purple = (126, 30, 164)
-yellow = (164, 164, 30)
-cyan = (30, 164, 150)
-
-
-class Piece:
- def __init__(self):
- self.square = square_template.copy()
-
- def rotate_clockwise(self):
- self.elements = list(zip(*self.elements[::-1]))
-
- def rotate_counter_clockwise(self):
- self.rotate_clockwise()
- self.rotate_clockwise()
- self.rotate_clockwise()
-
-
-class ZPiece(Piece):
- def __init__(self):
- super().__init__()
-
- self.square.fill(blue)
- self.elements = (self.square, self.square, None), (None, self.square, self.square), (None, None, None)
- self.vertical = False
-
- def rotate_clockwise(self):
- self.rotate()
-
- def rotate_counter_clockwise(self):
- self.rotate()
-
- def rotate(self):
- if self.vertical:
- self.elements = (self.square, self.square, None), (None, self.square, self.square), (None, None, None)
- else:
- self.elements = (None, None, self.square), (None, self.square, self.square), (None, self.square, None)
-
- self.vertical = not self.vertical
-
-
-class SPiece(Piece):
- def __init__(self):
- super().__init__()
-
- self.square.fill(green)
- self.elements = (None, None, None), (None, self.square, self.square), (self.square, self.square, None)
- self.vertical = False
-
- def rotate_clockwise(self):
- self.rotate()
-
- def rotate_counter_clockwise(self):
- self.rotate()
-
- def rotate(self):
- if self.vertical:
- self.elements = (None, self.square, self.square), (self.square, self.square, None), (None, None, None)
- else:
- self.elements = (None, self.square, None), (None, self.square, self.square), (None, None, self.square)
-
- self.vertical = not self.vertical
-
-
-class SquarePiece(Piece):
- def __init__(self):
- super().__init__()
-
- self.square.fill(brown)
- self.elements = ((self.square, self.square), (self.square, self.square))
-
-
-class IPiece(Piece):
- def __init__(self):
- super().__init__()
-
- self.square.fill(red)
- self.elements = (None, None, None, None), (None, None, None, None), (self.square, self.square, self.square, self.square), (None, None, None, None)
- self.vertical = False
-
- def rotate_clockwise(self):
- self.rotate()
-
- def rotate_counter_clockwise(self):
- self.rotate()
-
- def rotate(self):
- if self.vertical:
- self.elements = (None, None, None, None), (None, None, None, None), (self.square, self.square, self.square, self.square), (None, None, None, None)
- else:
- self.elements = (None, None, self.square, None), (None, None, self.square, None), (None, None, self.square, None), (None, None, self.square, None)
-
- self.vertical = not self.vertical
-
-
-class LPiece(Piece):
- def __init__(self):
- super().__init__()
-
- self.square.fill(cyan)
- self.elements = (None, None, None), (self.square, self.square, self.square), (None, None, self.square)
-
-
-class JPiece(Piece):
- def __init__(self):
- super().__init__()
-
- self.square.fill(purple)
- self.elements = (None, None, None), (self.square, self.square, self.square), (self.square, None, None)
-
-
-class TPiece(Piece):
- def __init__(self):
- super().__init__()
-
- self.square.fill(yellow)
- self.elements = (None, None, None), (self.square, self.square, self.square), (None, self.square, None)