Commit a277a861 by BellCodeEditor

save project

parent 90bf7204
Showing with 14 additions and 5 deletions
import pygame
from pygame import locals
import random
# 初始化pygame,为使用硬件做准备
pygame.init()
......@@ -17,12 +18,21 @@ right = pygame.image.load('right.png')
up= pygame.image.load('up.png')
down = pygame.image.load('down.png')
x,y=210,120
a,b=300,360
zuobiao=[(180,90),(180,120),(210,120),(x,y)]
setheading="right"
zaoxin=right
while True:
zuobiao.append((x,y))
if x==a and y== b:
a=random.randint(0,630)
b=random.randint(0,450)
cctv=a%30
a=a-cctv
ccttv=b%30
b=b-ccttv
else:
zuobiao.pop(0)
zuobiao.append((x,y))
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
......@@ -47,11 +57,10 @@ while True:
x-=30
if setheading=="right":
x+=30
screen.blit(background, (0, 0))
screen.blit(food, (a, b))
screen.blit(zaoxin, zuobiao[-1])
screen.blit(food, (360, 300))
for i in range(len(zuobiao)-1):
screen.blit(body,zuobiao[i])
pygame.display.update()
FPSLOCK.tick(25)
\ No newline at end of file
FPSLOCK.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