【Python】 博饼代码2

#版权:guozhetao
import turtle
import random
import time

__Pen = turtle.Pen()


#开始进入Python的世界
t = turtle.Turtle()
t.speed(0)
t.shape('turtle')
#while 语句
def nb(b,d,c):
    t.penup()
    t.goto((-200+b), (0+d))
    t.pendown()
    a = c#随机
    #正方形框
    for i in range(4):
        t.forward(150)
        t.right(90)
    t.penup()
    #点数1
    if (a == 1):
        t.fillcolor('red')
        t.begin_fill()
        t.goto((-125+b), (-85+d))
        
        t.circle(20)
        t.end_fill()
    #点数2
    if (a == 2):
        t.fillcolor('black')
        t.begin_fill()
        t.goto((-90+b), (-75+d))
        t.circle(10)
        t.end_fill()
        t.fillcolor('black')
        t.begin_fill()
        t.goto((-155+b), (-75+d))
        t.circle(10)
        t.end_fill()
    #点数3
    if (a == 3):
        t.fillcolor('black')
        t.begin_fill()
        t.goto((-160+b), (-50+d))
        t.circle(10)
        t.end_fill()
        t.fillcolor('black')
        t.begin_fill()
        t.goto((-125+b), (-75+d))
        t.circle(10)
        t.end_fill()
        t.fillcolor('black')
        t.begin_fill()
        t.goto((-90+b), (-100+d))
        t.circle(10)
        t.end_fill()
    #点数4
    if (a == 4):
        t.fillcolor('red')
        t.begin_fill()
        t.goto((-160+b), (-50+d))
        t.circle(10)
        t.end_fill()
        t.fillcolor('red')
        t.begin_fill()
        t.goto((-100+b), (-50+d))
        t.circle(10)
        t.end_fill()
        t.fillcolor('red')
        t.begin_fill()
        t.goto((-160+b), (-120+d))
        t.circle(10)
        t.end_fill()
        t.fillcolor('red')
        t.begin_fill()
        t.goto((-100+b), (-120+d))
        t.circle(10)
        t.end_fill()
    #点数5
    if (a == 5):
        t.fillcolor('black')
        t.begin_fill()
        t.goto((-160+b), (-50+d))
        t.circle(10)
        t.end_fill()
        t.fillcolor('black')
        t.begin_fill()
        t.goto((-100+b), (-50+d))
        t.circle(10)
        t.end_fill()
        t.fillcolor('black')
        t.begin_fill()
        t.goto((-160+b), (-120+d))
        t.circle(10)
        t.end_fill()
        t.fillcolor('black')
        t.begin_fill()
        t.goto((-100+b), (-120+d))
        t.circle(10)
        t.end_fill()
        t.fillcolor('black')
        t.begin_fill()
        t.goto((-125+b), (-85+d))
        t.circle(10)
        t.end_fill()
    #点数6
    if (a == 6):
        t.fillcolor('black')
        t.begin_fill()
        t.goto((-180+b), (-50+d))
        t.circle(10)
        t.end_fill()
        t.fillcolor('black')
        t.begin_fill()
        t.goto((-130+b), (-50+d))
        t.circle(10)
        t.end_fill()
        t.fillcolor('black')
        t.begin_fill()
        t.goto((-80+b), (-50+d))     
        t.circle(10)
        t.end_fill()
        t.fillcolor('black')
        t.begin_fill()
        t.goto((-180+b), (-120+d))
        t.circle(10)
        t.end_fill()
        t.fillcolor('black')
        t.begin_fill()
        t.goto((-130+b), (-120+d))
        t.circle(10)
        t.end_fill()
        t.fillcolor('black')
        t.begin_fill()
        t.goto((-85+b), (-120+d))
        t.circle(10)
        t.end_fill()

def a():
    q=random.randint(1,6)
    w = random.randint(1, 6)
    e = random.randint(1, 6)
    r = random.randint(1, 6)
    v = random.randint(1, 6)
    y = random.randint(1, 6)
    nb(0, 0, q)
    nb(200,0,w)
    nb(400,0,e)
    nb(0, 200, r)
    nb(200, 200, v)
    nb(400, 200, y)
    t.hideturtle()
    time.sleep(5)
    t.clear()
turtle.onkeypress(a,'3')
turtle.listen()
turtle.done()
#版权:guozhetao
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值