Commit 1da0a4a1 by BellCodeEditor

save project

parent b60ff27c
Showing with 61 additions and 5 deletions
import pygame import pygame
from pygame import locals
#asd=pygame.display.set_mode((660,480))
# 初始化pygame,为使用pygame做准备 # 初始化pygame,为使用pygame做准备
pygame.init() pygame.init()
screen=pygame.display.set_mode((660,480))
x,y=240,120
F=pygame.time.Clock()
breakgrade=pygame.image.load('bg.png')
right=pygame.image.load('right.png')
food=pygame.image.load('apple.png')
body=pygame.image.load('body.png')
left=pygame.image.load('left.png')
up=pygame.image.load('up.png')
down=pygame.image.load('down.png')
# 创建一个窗口 # 创建一个窗口
asd=pygame.display.set_mode() pygame.time.Clock()
p=[(180,90),(180,120),(210,120),(x,y)]
\ No newline at end of file s='right'
w=right
while True:
for i in pygame.event.get():
print(i)
if i.type==locals.QUIT:
exit()
elif i.type==locals.KEYDOWN:
if i.key==locals.K_RIGHT and s !='left':
s='right'
w=right
if i.key==locals.K_LEFT and s !='right':
s='left'
w=left
if i.key==locals.K_DOWN and s !='up':
s='down'
w=down
if i.key==locals.K_UP and s !='down':
s='up'
w=up
if s=='right':
x+=30
elif s=='left':
x-=30
elif s=='up':
y-=30
else:
y+=30
p.append((x,y))
p.pop(0)
screen.blit(breakgrade,(0,0))
screen.blit(food,(360,300))
screen.blit(w,p[-1])
for i in range(len(p)-1):
screen.blit(body,p[i])
pygame.display.update()
F.tick(3)
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