三角形为剪刀,红色为石头,圆形为布(玩家点击)
右边为电脑
运行截图:
写的比较简易,包括鼠标的点击(主要想应付一下老师的作业,临时写的),很多都有点偏差,但是我做了控制台显示点击坐标,可以自行调整哈~
源码:
import random
import turtle
choices_index = [0, 1, 2]
choices = ["剪刀", "布", "石头"]
your_choices = 0
computer_choice = 0
# 提笔,移动🖊,放下
def move_pen(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
# 画图形
def draw_item(color: str, steps):
turtle.color(col