Commit c0d905d3 by BellCodeEditor

auto save

parent c6188a1e
Showing with 50 additions and 5 deletions
import pygame
# 初始化pygame,为使用pygame做准备
x=90
y=30
a=[(0,0),(30,30),(60,30),(x,y)]
FPSCLOCK=pygame.time.Clock()
from pygame import locals
pygame.init()
bg = pygame.image.load("bg.png")
tou = pygame.image.load("right.png")
apple = pygame.image.load("apple.png")
body = pygame.image.load("body.png")
screen = pygame.display.set_mode((800,600))
tt='right'
while True:
for i in pygame.event.get():
if i.type == locals.QUIT:
exit()
if i.type==locals.KEYDOWN:
if i.key==locals.K_RIGHT and tt!='left':
tt='right'
if i.key==locals.K_LEFT and tt!='right':
tt='left'
if i.key==locals.K_UP and tt!='down':
tt='up'
if i.key==locals.K_DOWN and tt!='up':
tt='down'
if tt=='right':
x+=30
if tt=='left':
x-=30
if tt=='up':
y-=30
if tt=='down':
y+=30
a.append((x,y))
a.pop(0)
screen.blit(bg,(0,0))
for i in range(len(a)-1):
screen.blit(body,a[i])
screen.blit(apple,(120,120))
screen.blit(tou,(x,y))
# screen.blit(body,(60,0))
# screen.blit(body,(30,0))
# screen.blit(body,(0,0))
# 创建一个窗口
??
\ No newline at end of file
pygame.display.update()
FPSCLOCK.tick(5)
\ 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