Commit 5bd3099f by BellCodeEditor

auto save

parent a2902203
Showing with 38 additions and 59 deletions
import pygame """
from pygame import locals from turtle import *
def curvemove():
# 初始化pygame,为使用硬件做准备 for i in range(200):
pygame.init() right(1)
x=240 forward(1)
y=120 setup(600,600,400,400)
# 创建一个窗口 hideturtle()
screen =pygame.display.set_mode((660, 480)) pencolor("black")
fpsclock=pygame.time.Clock() fillcolor("red")
position=[(210, 120),(180, 120),(180, 90),(x,y)] pensize(2)
# 背景 begin_fill()
background = pygame.image.load('bg.png') left(140)
right = pygame.image.load('right.png') forward(111.65)
left = pygame.image.load("left.png") curvemove()
down = pygame.image.load("down.png") left(120)
up = pygame.image.load("up.png") curvemove()
food = pygame.image.load('apple.png') forward(111.65)
body = pygame.image.load('body.png') end_fill
setheading = "right" penup()
snake_head = right goto(-27,85)
x=240 pendown()
while True: done()
for event in pygame.event.get(): """
if event.type == locals.QUIT: """
# 接收到退出事件后退出程序 from turtle import *
exit() pensize(5)
if event.type==locals.KEYDOWN: for i in range(6):
if event.key == K_UP and setheading != "down": fd(100)
setheading = "up" right(60)
snake_head = up color("red")
if event.key == K_DOWN and setheading != "up": circle(60,steps=13)
setheading = "down" """
snake_head = down txt=input("请输入:")
if event.key==K_LEFT and setheading !="left": fo=open("py202.txt","w")
setheading ="left"
snake_head=left
if event.key==K_LEFT and setheading !="right":
setheading ="right"
snake_head=right
position.append((x,y))
position.pop
# 将背景图画上去
position.append((x,y))
position.pop(0)
screen.blit(background, (0, 0)
# 将贪吃蛇画上去
screen.blit(right,(x, 120))
# 将贪吃蛇的身体画上去
for i in range(len(position)-1):
screen.blit(body,position[i])
#screen.blit(body, (210, 120))
#screen.blit(body, (180, 120))
#screen.blit(body, (180, 90)
# 将果实画上去
screen.blit(food, (360, 300))
# 刷新画面
pygame.display.update()
fpsclock.tick(3)
d={}
ls=list(d.items())
\ 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