Commit 034e26d4 by BellCodeEditor

save project

parent 1dd7b9f7
Showing with 17 additions and 4 deletions
import pygame import pygame,random
from pygame import locals from pygame import locals
pygame.init() # 初始化 pygame.init() # 初始化
...@@ -15,6 +15,7 @@ clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) ...@@ -15,6 +15,7 @@ clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 载入素材 # 载入素材
background = pygame.image.load('bg.png') background = pygame.image.load('bg.png')
font = pygame.font.Font('STKAITI.TTF', 60) # 字体 font = pygame.font.Font('STKAITI.TTF', 60) # 字体
font = pygame.font.Font('minecraft_font.ttf', 60) # 字体
# 俄罗斯方块所有形状 # 俄罗斯方块所有形状
O = [[(0, 0), (0, 1), (1, 0), (1, 1)]] O = [[(0, 0), (0, 1), (1, 0), (1, 1)]]
...@@ -44,8 +45,21 @@ cube_colors = [ ...@@ -44,8 +45,21 @@ cube_colors = [
(255, 204, 0), (204, 0, 51),(255, 0, 51), (0, 102, 153), (255, 204, 0), (204, 0, 51),(255, 0, 51), (0, 102, 153),
(153, 0, 51), (204, 255, 102), (255, 153, 0)] (153, 0, 51), (204, 255, 102), (255, 153, 0)]
color=random.choice(cube_colors)
shape=random.choice(shape_list)
index=random.randint(0,len(shape)-1)
current_shape=random.choice(random.choice(shape_list))
center = [2, 8] # 第2行第8列 center = [2, 8] # 第2行第8列
current_shape = [(0, -1), (0, 0), (0, 1), (-1, 0)] # current_shape = [(0, -1), (0, 0), (0, 1), (-1, 0)]
def a():
pygame.draw.rect(screen, color,(cube[1] * 20-20, cube[0] * 20-20, 20, 20), 0)
pygame.draw.rect(screen, (255, 255, 255), (cube[1] * 20-20, cube[0] * 20-20, 20, 20), 1)
def check():
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -53,8 +67,7 @@ while True: ...@@ -53,8 +67,7 @@ while True:
exit() exit()
if event.type == locals.KEYDOWN: if event.type == locals.KEYDOWN:
if event.key == locals.K_RIGHT: # 向右 if event.key == locals.K_RIGHT: # 向右
if center[1] < 15:
center[1] += 1
elif event.key == locals.K_LEFT: # 向左 elif event.key == locals.K_LEFT: # 向左
if center[1] > 1: if center[1] > 1:
center[1] -= 1 center[1] -= 1
......
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