Commit a074c56b by BellCodeEditor

save project

parent 1d161ee1
Showing with 21 additions and 5 deletions
......@@ -2,29 +2,45 @@ import pygame
from pygame import locals
pygame.init() # 初始化
score = 0
score = 0 #分数值
grid_size = 20 # 格子大小
grid_num_width = 15 # 横向格子数量
grid_num_height = 25 # 纵向格子数量
FPS = 30
pos = [2,7]
# 创建窗口
screen = pygame.display.set_mode((460, 500))
pygame.display.set_caption("俄罗斯方块")
clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 载入素材
background = pygame.image.load('bg.png')
background = pygame.image.load('bg.png') #背景
font = pygame.font.Font('STKAITI.TTF', 60) # 字体
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_DOWN:
if pos[0] < grid_num_height:
pos[0] += 1
if event.key == pygame.K_LEFT:
if pos[1] > 1:
pos[1] -= 1
if event.key == pygame.K_RIGHT:
if pos[1] < grid_num_width:
pos[1] += 1
# 将背景图画上去
???
screen.blit(background,(0,0))
pygame.draw.rect(screen,(255,0,0),
((pos[1]-1)*grid_size,(pos[0]-1)*grid_size,grid_size,grid_size),0)
pygame.draw.rect(screen,(255,255,255),
((pos[1]-1)*grid_size,(pos[0]-1)*grid_size,grid_size,grid_size),1)
# 得分
???
score_info = font.render(str(score),True,(255,255,255))
screen.blit(score_info,(350,70))
# 刷新画面
pygame.display.update()
clock.tick(FPS)
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