Commit 964db720 by BellCodeEditor

save project

parent 1dd7b9f7
Showing with 10 additions and 4 deletions
import pygame import pygame
import random
from pygame import locals from pygame import locals
pygame.init() # 初始化 pygame.init() # 初始化
...@@ -46,24 +47,29 @@ cube_colors = [ ...@@ -46,24 +47,29 @@ cube_colors = [
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)]
shape = random.choice(shape_list)
current_shape=random.choice(shape)
color=random.choice(cube_colors)
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
exit() exit()
if event.type == locals.KEYDOWN: if event.type == locals.KEYDOWN:
if event.key == locals.K_RIGHT: # 向右 if event.key == locals.K_d: # 向右
if center[1] < 15: if center[1] < 15:
center[1] += 1 center[1] += 1
elif event.key == locals.K_LEFT: # 向左 elif event.key == locals.K_a: # 向左
if center[1] > 1: if center[1] > 1:
center[1] -= 1 center[1] -= 1
elif event.key == locals.K_DOWN: # 向下 elif event.key == locals.K_s: # 向下
if center[0] < 25: if center[0] < 25:
center[0] += 1 center[0] += 1
elif event.key == locals.K_q: # 向下
color=random.choice(cube_colors)
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
color=random.choice(cube_colors)
# 计算出所有小方块的行、列位置 # 计算出所有小方块的行、列位置
current_pos = [] current_pos = []
for cube in current_shape: for cube in current_shape:
......
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