Commit cc5636ea by BellCodeEditor

save project

parent eb6b22b0
Showing with 8 additions and 3 deletions
import random
import pygame
from pygame import locals
......@@ -5,7 +6,7 @@ from pygame import locals
pygame.init()
SB = pygame.time.Clock()
# 创建一个窗口
screen = pygame.display.set_mode((6600, 480))
screen = pygame.display.set_mode((660, 480))
# 背景
background = pygame.image.load('bg.png')
......@@ -21,6 +22,7 @@ x,y = 240,120
a = [(180,90),(180,120),(210,120),(x,y)]
se = 'ri'
s_e = ri
a_x,a_y = 360, 300
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -48,7 +50,9 @@ while True:
y -= 30
else:
y += 30
if x ==a_x and y == a_y:
a_x = random.randint(0, 660)
a_y = random.randint(0, 480)
a.append((x,y))
a.pop(0)
# 将背景图画上去
......@@ -59,7 +63,7 @@ while True:
for i in range(len(a)-1):
screen.blit(body, a[i])
# 将果实画上去
screen.blit(food, (360, 300))
screen.blit(food, (a_x, a_y))
# 刷新画面
pygame.display.update()
SB.tick(10)
\ 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