Commit 64cc0855 by BellCodeEditor

auto save

parent bc3bfe82
Showing with 27 additions and 5 deletions
import pygame import pygame
from pygame import locals from pygame import locals
x,y=240,120 x,y=240,120
# 初始化pygame,为使用硬件做准备 # 初始化pygame,为使用硬件做准备
pygame.init() pygame.init()
...@@ -7,18 +8,39 @@ re=pygame.time.Clock();re.tick(3)# 创建一个窗口 ...@@ -7,18 +8,39 @@ re=pygame.time.Clock();re.tick(3)# 创建一个窗口
screen = pygame.display.set_mode((660, 480)) screen = pygame.display.set_mode((660, 480))
se=[(180,90),(180, 120),(210, 120),(x,y)] se=[(180,90),(180, 120),(210, 120),(x,y)]
S='right'
ss=right
# 背景 # 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
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.KEPDOWN:
if event.key==locals.K_RIGHT and s !='left':
s='right'
ss=right
if event.key==locals.K_UP and s !='down':
s='up'
ss=up
if event.key==locals.K_DOWN and s !='up':
s='down'
ss=down
if event.key==locals.K_LEFT and s !='right':
s='left'
ss=left
if s=='right'
x+=30
else s=='up':
y-=30
else s=='down':
y+=30
else s=='left':
x-=30
x+=30 x+=30
se.append((x,y)) se.append((x,y))
se.pop(0) se.pop(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