Commit dc90dbc7 by BellCodeEditor

auto save

parent 01beaadc
Showing with 20 additions and 61 deletions
import pygame import random
from pygame import locals import turtle
c=turtle.Screen()
# 初始化pygame,为使用硬件做准备 d=turtle.Pen()
pygame.init() a=random.randint(0,100)
q=0
# 创建一个窗口
screen = pygame.display.set_mode((660, 480))
asdfk=pygame.time.Clock()
# 背景
background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
down = pygame.image.load('down.png')
left = pygame.image.load('left.png')
up = pygame.image.load('up.png')
x=240
y=120
qwer=[(210,120),(180,120),(180,90),(x,y)]
qwert='right'
qaz=right
while True: while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type == locals.KEYDOWN:
if event.key == locals.K_RIGHT and qwert != 'left':
qwert = 'right'
qaz=right
elif event.key == locals.K_UP and qwert != 'down':
qwert = 'up'
qaz=up
elif event.key == locals.K_LEFT and qwert != 'right':
qwert = 'left'
qaz=left
elif event.key == locals.K_DOWN and qwert != 'up':
qwert = 'down'
qaz=down
if qwert == 'right' :
x+=30
elif qwert == 'up':
y-=30
elif qwert == 'left':
x-=30
elif qwert == 'down':
y+=30
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
qwer.append((x,y))
qwer.pop(0)
screen.blit(qaz, (x,y))
for i in range(len(qwer)-1): b=c.textinput('猜数字','输入一个数')
screen.blit(body,qwer[i]) d.clear()
pygame.display.update() b=int(b)
asdfk.tick(5) if b==a:
\ No newline at end of file d.write('yes',font=('Times',30,'normal'))
elif b<a:
d.write('big',font=('Times',30,'normal'))
q+=1
elif b>a:
d.write('s',font=('Times',30,'normal'))
q+=1
turtle.done()
\ 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