Commit c5bda34b by BellCodeEditor

save project

parent 8056893e
Showing with 10 additions and 10 deletions
import pygame
from pygame import locals
import random
pygame.init() # 初始化
score = 0
grid_size = 20 # 格子大小
......@@ -105,7 +104,7 @@ while True:
index = random.randint(0, len(shape)-1) # 随机形状索引
current_shape = shape[index]
color = random.choice(cube_colors) # 随机选取一种颜色
count += 1
count += 1
if count % FPS == 0: # 降落速度的算式
center[0] = center[0] + 1
if check(center) == False:
......@@ -113,14 +112,14 @@ while True:
states = False
for cube in current_pos:
num_list[cube[0]-1][cube[1]-1] = color
# 将背景图画上去
# 将背景图画上去
screen.blit(background, (0, 0))
# 计算出所有小方块的行、列位置
# 计算出所有小方块的行、列位置
current_pos = []
for cube in current_shape:
pos = (cube[0] + center[0], cube[1] + center[1])
current_pos.append(pos)
# 取出所有小方块的行、列位置,计算坐标,绘制俄罗斯方块
# 取出所有小方块的行、列位置,计算坐标,绘制俄罗斯方块
for i,raw in zip (range(1,26),num_list):
for j,colors in zip (range(1,16),raw):
if colors !=0:
......@@ -149,8 +148,8 @@ while True:
else:
score+=1
num_list=new_list
# 得分
# 得分
text_surface = font.render(str(score), True, (0, 0, 0))
screen.blit(text_surface, (350,70))
if gameover==True:
......@@ -160,6 +159,7 @@ while True:
num_list = []
for i in range(25):
num_list.append([0] * 15)
score=0
# 刷新画面
pygame.display.update()
clock.tick(FPS)
\ No newline at end of file
pygame.display.update()
clock.tick(FPS)
\ No newline at end of file
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