Skip to content

Commit b71115d

Browse files
Add files via upload
1 parent 00b705d commit b71115d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+345
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from settings import *
2+
from sys import exit
3+
4+
class Main:
5+
def __init__(self):
6+
7+
# general
8+
pygame.init()
9+
self.display_surface = pygame.display.set_mode((WINDOW_WIDTH,WINDOW_HEIGHT))
10+
self.clock = pygame.time.Clock()
11+
pygame.display.set_caption('Tetris')
12+
13+
def run(self):
14+
while True:
15+
for event in pygame.event.get():
16+
if event.type == pygame.QUIT:
17+
pygame.quit()
18+
exit()
19+
20+
# display
21+
self.display_surface.fill(GRAY)
22+
23+
# updating the game
24+
pygame.display.update()
25+
self.clock.tick()
26+
27+
if __name__ == '__main__':
28+
main = Main()
29+
main.run()
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import pygame
2+
3+
# Game size
4+
COLUMNS = 10
5+
ROWS = 20
6+
CELL_SIZE = 40
7+
GAME_WIDTH, GAME_HEIGHT = COLUMNS * CELL_SIZE, ROWS * CELL_SIZE
8+
9+
# side bar size
10+
SIDEBAR_WIDTH = 200
11+
PREVIEW_HEIGHT_FRACTION = 0.7
12+
SCORE_HEIGHT_FRACTION = 1 - PREVIEW_HEIGHT_FRACTION
13+
14+
# window
15+
PADDING = 20
16+
WINDOW_WIDTH = GAME_WIDTH + SIDEBAR_WIDTH + PADDING * 3
17+
WINDOW_HEIGHT = GAME_HEIGHT + PADDING * 2
18+
19+
# game behaviour
20+
UPDATE_START_SPEED = 800
21+
MOVE_WAIT_TIME = 200
22+
ROTATE_WAIT_TIME = 200
23+
BLOCK_OFFSET = pygame.Vector2(COLUMNS // 2, -1)
24+
25+
# Colors
26+
YELLOW = '#f1e60d'
27+
RED = '#e51b20'
28+
BLUE = '#204b9b'
29+
GREEN = '#65b32e'
30+
PURPLE = '#7b217f'
31+
CYAN = '#6cc6d9'
32+
ORANGE = '#f07e13'
33+
GRAY = '#1C1C1C'
34+
LINE_COLOR = '#FFFFFF'
35+
36+
# shapes
37+
TETROMINOS = {
38+
'T': {'shape': [(0,0), (-1,0), (1,0), (0,-1)], 'color': PURPLE},
39+
'O': {'shape': [(0,0), (0,-1), (1,0), (1,-1)], 'color': YELLOW},
40+
'J': {'shape': [(0,0), (0,-1), (0,1), (-1,1)], 'color': BLUE},
41+
'L': {'shape': [(0,0), (0,-1), (0,1), (1,1)], 'color': ORANGE},
42+
'I': {'shape': [(0,0), (0,-1), (0,-2), (0,1)], 'color': CYAN},
43+
'S': {'shape': [(0,0), (-1,0), (0,-1), (1,-1)], 'color': GREEN},
44+
'Z': {'shape': [(0,0), (1,0), (0,-1), (-1,-1)], 'color': RED}
45+
}
46+
47+
SCORE_DATA = {1: 40, 2: 100, 3: 300, 4: 1200}
256 Bytes
371 Bytes
371 Bytes
262 Bytes
Binary file not shown.
321 Bytes
321 Bytes
320 Bytes

0 commit comments

Comments
 (0)