Commit ada42052 by BellCodeEditor

save project

parent 83d9b868
Showing with 10 additions and 3 deletions
import pygame
from pygame import locals
import random
x=240
y=120
apple_x = 360
apple_y = 300
SHENTI=[(180,90),(180,120),(210,120),(x,y)]
# 初始化pygame,为使用硬件做准备
pygame.init()
# 创建一个窗口
screen = pygame.display.set_mode((889, 880))
screen = pygame.display.set_mode((660, 480))
# 背景
background = pygame.image.load('bg.png')
......@@ -49,6 +52,9 @@ while True:
x-=30
else :
x+=30
if apple_x and y == apple_x:
apple_x = random.randint(0,660)
apple_y = random.randint(0,480)
SHENTI.append((x,y))
SHENTI.pop(0)
# 接收到退出事件后退出程序
......@@ -66,7 +72,7 @@ while True:
#screen.blit(body, (180, 120))
#screen.blit(body, (180, 90))
# 将果实画上去
screen.blit(food, (360, 300))
screen.blit(food, (apple_x, apple_y))
# 刷新画面
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