Commit ccd648a2 by BellCodeEditor

save project

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