Commit 0489faac by BellCodeEditor

save project

parent ccd648a2
Showing with 25 additions and 8 deletions
import pygame
from pygame import locals
from random import randint
from random import*
pygame.init() # 初始化
score = 0
......@@ -18,10 +18,7 @@ background = pygame.image.load('bg.png')
font = pygame.font.Font('STKAITI.TTF', 60) # 字体
# 俄罗斯方块所有形状
O = [[(0, 0), (0, 1), (1, 0), (1, 1)],
[(0, 0), (0, 1), (1, 0), (1, 1)],
[(0, 0), (0, 1), (1, 0), (1, 1)],
[(0, 0), (0, 1), (1, 0), (1, 1)]]
O = [[(0, 0), (0, 1), (1, 0), (1, 1)]]
I = [[(0, -1), (0, 0), (0, 1), (0, 2)],
[(-1, 0), (0, 0), (1, 0), (2, 0)]]
Z = [[(0, -1), (0, 0), (1, 0), (1, 1)],
......@@ -49,8 +46,15 @@ cube_colors = [
(153, 0, 51), (204, 255, 102), (255, 153, 0)]
center = [2, 8] # 第2行第8列
current_shape = shape_list[randint(0,6)][randint(0,3)]
color=cube_colors[randint(0,10)]
shape = choice(shape_list)
ind=randint(0,len(shape)-1)
current_shape = shape[ind]
color= choice(cube_colors)
def check(center):
for cube in current_shape:
cube = (cube[0]+center[0],cube[1]+center[1])
if cube[0] < 1 or cube[1] < 1
while True:
for event in pygame.event.get():
......@@ -66,7 +70,20 @@ while True:
elif event.key == locals.K_DOWN: # 向下
if center[0] < 25:
center[0] += 1
elif event.key == locals.K_z:
if ind > 0:
ind-=1
current_shape = shape[ind]
else:
ind=len(shape)-1
current_shape = shape[ind]
elif event.key == locals.K_x:
if ind < len(shape)-1:
ind+=1
current_shape = shape[ind]
else:
ind=0
current_shape = shape[ind]
# 将背景图画上去
screen.blit(background, (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