Commit 8b8d320b by BellCodeEditor

auto save

parent d8635ca3
Showing with 45 additions and 5 deletions
a.png

453 KB

......@@ -16,24 +16,56 @@ sj=pygame.time.Clock()
screen = pygame.display.set_mode((660, 480))
# 背景
a=pygame.image.load('a.png')
background = 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')
z=[(180,90),(180,120),(210,120),(x,y)]
fx='right'
snakehead = right
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
print(event)
if event.type == locals.QUIT: #叉号
# 接收到退出事件后退出程序
exit()
x+=30
if event.type == locals.KEYDOWN:
if event.key == locals.K_RIGHT and fx !='left':
fx = 'right'
snakehead = right
if event.key == locals.K_LEFT and fx !='right':
fx = 'left'
snakehead = left
if event.key == locals.K_UP and fx !='down':
fx = 'up'
snakehead = up
if event.key == locals.K_DOWN and fx !='up':
fx = 'down'
snakehead = down
if fx == 'right':
x += 30
elif fx == 'left':
x -= 30
elif fx == 'up':
y -= 30
else:
y += 30
# x+=30
z.append((x,y))
z.pop(0)
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
screen.blit(right, (x,y))
screen.blit(snakehead, (x,y))
# 将贪吃蛇的身体画上去
for i in range(len(z)-1):
screen.blit(body,z[i])
......@@ -44,4 +76,4 @@ while True:
screen.blit(food, (360, 300))
# 刷新画面
pygame.display.update()
sj.tick(3)
\ No newline at end of file
sj.tick(6)
\ No newline at end of file
import sys
import sys
import webbrowser
sys.path.append("libs")
url = 'https://gui.makcoocode.com/?pid=do1PaAm4R5&fork=1&cburl=https%253A%252F%252Fgui.makcoocode.com%252Fshare%253Fpid%253Ddo1PaAm4R5%2526token%253D9eac3262-834e-11ed-9ec7-124e417cf71a-2800'
webbrowser.open(url)
print(webbrowser.get())
\ No newline at end of file
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