赞
踩
全部代码:
import turtle
from turtle import *
from random import randrange
from time import sleep
import pygame
snake = [[0,0],[10,0],[20,0],[30,0],[40,0],[50,0]]
apple_x = randrange(-20,18)*10
apple_y = randrange(-19,19)*10
aim_x = 10
aim_y = 0
def square(x,y,size,color_name):
up()
goto(x,y)
down()
#设置颜色
color(color_name)
#填充
begin_fill()
forward(size)
left(90)
forward(size)
left(90)
forward(size)
left(90)
forward(size)
left(90)
end_fill()
def change(x,y):
global aim_x,aim_y
aim_x = x
aim_y = y
def inside_snake():
for i in range(len(snake)-1):
if snake[i][0] == snake[-1][0] and snake[i][1] == snake[-1][1]:
#蛇咬住自己
return True
return
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。