Commit 8af61b7c by BellCodeEditor

save project

parent 1dd7b9f7
Showing with 11 additions and 4 deletions
import pygame
from pygame import locals
from random import choice,randint
pygame.init() # 初始化
score = 0
......@@ -36,16 +37,22 @@ L = [[(-1, 0), (0, 0), (1, 0), (1, 1)],
[(0, -1), (0, 0), (0, 1), (1, -1)],
[(-1, 0), (0, 0), (1, 0), (-1, -1)],
[(0, -1), (0, 0), (0, 1), (-1, 1)]]
shape_list = [I, J, L, O, S, T, Z] # 7种类型俄罗斯方块
# 一些RGB颜色
cube_colors = [
(204, 153, 153), (102, 102, 153),(153, 0, 102),
(255, 204, 0), (204, 0, 51),(255, 0, 51), (0, 102, 153),
(153, 0, 51), (204, 255, 102), (255, 153, 0)]
(255, 204, 0), (204, 0, 51),(255, 0, 51),
(0, 102, 153),(153, 0, 51), (204, 255, 102),
(255, 153, 0),(0, 0, 0),(23, 0, 178),
(0, 188, 34),(55, 48, 199),(211, 45, 188)]
center = [2, 8] # 第2行第8列
current_shape = [(0, -1), (0, 0), (0, 1), (-1, 0)]
shape = choice(shape_list)
index = randint(0,len(shape) - 1)
current_shape = shape[index]
color = choice(cube_colors)
while True:
for event in pygame.event.get():
......@@ -73,7 +80,7 @@ while True:
for cube in current_pos:
pygame.draw.rect(screen, color,
(cube[1] * 20-20, cube[0] * 20-20, 20, 20), 0)
pygame.draw.rect(screen, (255, 255, 255),
pygame.draw.rect(screen, (255,255,255),
(cube[1] * 20-20, cube[0] * 20-20, 20, 20), 1)
# 得分
text_surface = font.render(str(score), True, (0, 0, 0))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment