summaryrefslogtreecommitdiff
path: root/cameltris.py
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2020-12-22 20:08:15 +0100
committerOlivier Gayot <olivier.gayot@sigexec.com>2020-12-22 20:10:31 +0100
commitbc4759d90701263450a023881de28edb048fc073 (patch)
tree61bd58977b8062b9a5263e77ef92c4c54616a440 /cameltris.py
parent73a2e406302fc863d0d62926a2c451238c863c77 (diff)
Show the score in the terminal
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'cameltris.py')
-rwxr-xr-xcameltris.py37
1 files changed, 34 insertions, 3 deletions
diff --git a/cameltris.py b/cameltris.py
index ca4ffed..d3973be 100755
--- a/cameltris.py
+++ b/cameltris.py
@@ -255,9 +255,11 @@ def burn_rows():
grid.insert(0, [None for _ in range(10)])
grid.remove(row)
+ return len(rows_to_burn)
+
def stick_piece():
- global current_piece, current_piece_position, next_piece, next_piece_position
+ global current_piece, current_piece_position, next_piece, next_piece_position, lines_burnt, level, score
for row_id, row in enumerate(current_piece.elements):
for col_id, element in enumerate(row):
@@ -265,7 +267,32 @@ def stick_piece():
continue
grid[row_id + current_piece_position[0]][col_id + current_piece_position[1]] = element
- burn_rows()
+ count = burn_rows()
+
+ if count == 1:
+ print("Single")
+ rate = 1
+ elif count == 2:
+ print("Double")
+ rate = 2.5
+ elif count == 3:
+ print("Triple")
+ rate = 7.5
+ elif count == 4:
+ print("Tetris!")
+ rate = 30
+ else:
+ rate = 0
+
+ lines_burnt += count
+
+ score += int(level * 40 * rate)
+
+ print("Score is ", score)
+
+ if lines_burnt >= level * 10:
+ level += 1
+ print("Level up to ", level)
current_piece, current_piece_position = next_piece, next_piece_position
next_piece, next_piece_position = generate_piece()
refresh_piece_preview_canvas()
@@ -302,12 +329,16 @@ refresh_piece_preview_canvas()
frames_per_gridcell = [48, 43, 38, 33, 28, 23, 18, 13, 8, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]
piece_drop_frames = 0
-level = 16
+level = 1
+score = 0
pygame.key.set_repeat(200, 50)
clock = pygame.time.Clock()
+print("Level is ", level)
+lines_burnt = 0
+
while True:
piece_drop_frames += 1