
import turtle
import random
screen = turtle.Screen( )
screen.setup(1100,650)
screen.bgcolor("#0B1748")
t = turtle.Turtle()
t.pensize(2)
t.speed(0)
t.color("black")
list_color=["#E30B5C","#FFC000","#FFBF00","#FF3131","#AAFF00","#FAFA33","#FFFF00","#FF10F0","#BF40BF"]
fish_pos=[(363,284),(478,133)]
fish2_pos=[(368,-126),(-143,286),(-433,89)]
star_pos=[(-323,-245),(192,-286),(-433,-212)]
grass_pos=[(-147,-270),(-130,-270),(-110,-270),(442,-191),(462,-191),(497,-206),(515,-207),(525,-207),(-453,-143),(-413,-148),(-403,-148),(-431,-147)]
#########################################################
def fish1(a):
#身体
t.seth(a)
t.fillcolor ('sky blue')
t.begin_fill()
t.circle(40,170)
t.left(120)
t.circle(-10,190)
t.left(-90)
t.circle(-38,-190)
t.end_fill()
#尾巴
t.fillcolor(random.choice(list_color))
t.begin_fill()
t.left(120)
t.forward(20)
t.right(140)
t.forward(50)
t.right(120)
t.forward(16)
t.end_fill()
#眼睛
t.pu()
t.forward(60)
t.dot(20)
t.pu()
t.forward(1)
t.dot(5,"white")
def fish2(a,r):
#尾巴
t.seth(a)
t.fillcolor(random.choice(list_color))
t.begin_fill()
t.forward(r)
t.left(135)
t.forward(r*0.8)
t.end_fill()
#身体
t.seth(a)
t.fillcolor(random.choice(list_color))
t.begin_fill()
t.forward(r*2)
t.left(135)
t.forward(r*3)
t.left(90)
t.forward(r*3)
t.end_fill()
#眼睛
t.pu()
t.seth(a)
t.forward(r*2)
t.left(90)
t.forward(r)
t.dot(r/2)
t.pu()
t.forward(1)
t.dot(r/6,"white")
#海星
def drawstar(r):
t.left(10)
t.fd(40/r)#臂长
t.circle(5/r,155)#手末端
t.fd(40/r)
#水草
def grass(a):
r=random.randint(10,20)#宽度
n=random.randint(2,4)#长度
t.fillcolor("#228B22")
t.begin_fill()
t.seth(a)#角度
for i in range(n):
t.circle(r, 80)
t.circle(-r, 80)
random.randint(160,170)
t.seth(a+170)
for i in range(n):
t.circle(r, 80)
t.circle(-r, 80)
t.end_fill()
def qipao(x1,y1,r):
t.pensize(2)
t.pencolor('white')
t.penup()
t.goto(x1,y1)
t.pendown()
t.circle(r)
t.penup()
t.goto(x1-r*0.5,y1+r*1.5)
t.dot(r/2)
qipao(412,-108,5)
qipao(405,-50,10)
qipao(389,0,15)
qipao(389,50,20)
t.pencolor('black')
for i in grass_pos:
t.pu()
t.goto(i)
grass(50)
for i in fish_pos:
t.pu()
t.goto(i)
fish1(random.randint(70,110))
for i in range(8):
t.pu()
if i==0:
t.goto(-320,250)
fish2(-90,30)
else:
t.goto(random.randint(-550,-320),random.randint(200,300))
fish2(-90,random.randint(8,20))
#沙滩
t.fillcolor("#DAA06D")
t.begin_fill()
t.pu()
t.goto(568,-195)
# t.down()
t.seth(161)
t.circle(883,62)
t.goto(575,-401)
t.goto(568,-195)
t.end_fill()
t.fillcolor("#C19A6B")
t.begin_fill()
t.pu()
t.goto(-563,-125)
# t.down()
t.seth(184)
t.circle(519,-61)
t.goto(-557,-367)
t.goto(-563,-128)
t.goto(-563,-125)
t.end_fill()
#海星
for i in star_pos:
t.fillcolor(random.choice(list_color))
t.begin_fill()
t.pu()
t.goto(i)
r=random.randint(1,4)
t.seth(random.randint(1,270))
for j in range(5):
drawstar(r)
t.right(93)
t.end_fill()
#潜艇
t.pu()
t.goto(194,126)
t.down()
t.fillcolor("#B2BEB5")
t.begin_fill()
t.seth(141)
t.circle(306,72)
t.seth(215)
t.circle(132,109)
t.seth(325)
t.circle(291,74)
t.goto(195,123)
t.goto(194,126)
t.end_fill()
#座舱
t.pu()
t.goto(-70,182)
t.down()
t.fillcolor("red")
t.begin_fill()
t.goto(-79,68)
t.seth(87)
t.circle(42,-66)
t.goto(-219,17)
t.goto(-216,-5)
t.goto(-119,9)
t.seth(7)
t.circle(74,59)
t.goto(-54,184)
t.goto(-54,187)
t.goto(-70,182)
t.end_fill()
#驾驶室
t.pu()
t.goto(-70,182)
t.fillcolor("white")
t.begin_fill()
t.down()
t.goto(-79,68)
t.seth(87)
t.circle(42,-66)
t.goto(-219,17)
t.seth(277)
t.circle(152,-89)
t.goto(-72,185)
t.goto(-70,182)
t.end_fill()