Commit f49dd7bc by BellCodeEditor

auto save

parent 66d26448
Showing with 18 additions and 2 deletions
import pygame
import random
from pygame import locals
# 初始化pygame,为使用pygame做准备
......@@ -14,6 +15,7 @@ left=pygame.image.load("left.png")
down=pygame.image.load("down.png")
up=pygame.image.load("up.png")
x=240
y=120
......@@ -23,6 +25,9 @@ body=pygame.image.load("body.png")
fangxiang="right"
tou=right
apple_x=360
apple_y=300
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -49,13 +54,23 @@ while True:
y+=30
if fangxiang == "up":
y-=30
position.append((x,y))
if x==apple_x and y==apple_y:
num1=random.randint(1,22)
num2=random.randint(1,16)
apple_x=num1*30-30
apple_y=num2*30-30
else:
position.pop(0)
screen.blit(background,(0,0))
screen.blit(apple,(60,90))
screen.blit(apple,(apple_x,apple_y))
screen.blit(tou, position[-1])
for i in range(len(position)-1):
screen.blit(body, position[i])
pygame.display.update()
FPS.tick(3)
\ 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