Commit 132e79fe by BellCodeEditor

save project

parent 56218f3d
Showing with 14 additions and 4 deletions
import pygame
from pygame import locals
cender=[2,8]
pygame.init() # 初始化
score = 0
grid_size = 20 # 格子大小
......@@ -20,11 +20,21 @@ while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
pygame.draw.rect(screen,(255,0,0),(120,20,20,20),0)
pygame.draw.rect(screen,(255,255,255),(120,20,20,20),1)
if event.type == locals.KEYDOWN:
if event.key == locals.K_RIGHT:
if cender[1]<15:
cender[1]+=1
if event.key == locals.K_LEFT:
if cender[1]>1:
cender[1]-=1
if event.key == locals.K_DOWN:
if cender[0]<25:
cender[0]+=1
# 将背景图画上去
screen.blit(background,(0,0))
# 得分
pygame.draw.rect(screen,(255,255,0),(cender[1]*20-20,cender[0]*20-20,20,20),0)
pygame.draw.rect(screen,(255,255,255),(cender[1]*20-20,cender[0]*20-20,20,20),1)# 得分
scoretext=font.render(str(score),True,(0,0,0))
screen.blit(scoretext,(330,50))
# 刷新画面
......
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