贪吃蛇
音频素材:
链接:https://pan.baidu.com/s/1zGeDx8pDx4DAb5I3PGXEGQ
提取码:3uez
链接
全部代码:
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