Commit 25f31147 by BellCodeEditor

save project

parent 2006da31
Showing with 12 additions and 0 deletions
import turtle
import pygame import pygame
from pygame import locals from pygame import locals
import random
# 初始化pygame,为使用pygame做准备 # 初始化pygame,为使用pygame做准备
pygame.init() pygame.init()
background=pygame.image.load('bg.png') background=pygame.image.load('bg.png')
...@@ -7,7 +8,12 @@ food=pygame.image.load('apple.png') ...@@ -7,7 +8,12 @@ food=pygame.image.load('apple.png')
right=pygame.image.load('right.png') right=pygame.image.load('right.png')
st=pygame.image.load('body.png') st=pygame.image.load('body.png')
# 创建一个窗口 # 创建一个窗口
screen=pygame.display.set_mode((660,480)) screen=pygame.display.set_mode((660,480))
apple_x=360
apple_y=300
x,y=240,120
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type==locals.QUIT: if event.type==locals.QUIT:
...@@ -18,4 +24,8 @@ while True: ...@@ -18,4 +24,8 @@ while True:
screen.blit(st,(210,120)) screen.blit(st,(210,120))
screen.blit(st,(180,120)) screen.blit(st,(180,120))
screen.blit(st,(180,90)) screen.blit(st,(180,90))
if x==apple_x and y==apple_y:
apple_x=random.randint(0,660)
apple_y=random.randint(0,480)
pygame.display.update() pygame.display.update()
\ 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