admin管理员组

文章数量:1345190

My goal is to use a mouse click handler to determine in which sections the mouse was clicked, and, according to the section, add the image on the preset coordinates very raw code and sections to click on the right How can i possibly add an if statement with x and y of the mouse event handler? general imbedded descritpion. almost fot, my overall goal is a graphical tic-tac-toe game

code:

set_size(300, 300)
count = 0
memory = [1, 1, 1
        , 1, 1, 1
        , 1, 1, 1]

def draw_grid():

    first = Rectangle(12, get_height())
    first.set_position(get_width()/3-6, 0)
    first.set_color(Color.black)
    
    second = Rectangle(12, get_height())
    second.set_position(2*get_width()/3-6, 0)
    second.set_color(Color.black)
    
    third = Rectangle(get_width(), 12)
    third.set_position(0, get_height()/3-6)
    third.set_color(Color.black)
    
    fourth = Rectangle(get_width(), 12)
    fourth.set_position(0, 2*get_height()/3-6)
    fourth.set_color(Color.black)
    
    add(first)
    add(second)
    add(third)
    add(fourth)
draw_grid()

def turn():
    
global count
    while count <= 9:
        if count % 2 == 0:
            insert_image_x()
        else: 
            insert_image_o()
        count +=1
        
def insert_image_x():
    cross = Image("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOEAAADhCAMAAAAJbSJIAAAAjVBMVEX/////AAD/2dn/0tL/wMD/xMT/xcX/1dX/BAT/bm7/cXH/a2v/+/v/u7v/aGj/zMz/dXX/t7f/nJz/7u7/s7P/qKj/o6P/5+f/YWH/XV3/9vb/eHj/sLD/f3//V1f/NDT/TEz/PT3/4+P/JCT/FBT/LS3/RUX/UFD/Hh7/iIj/MTH/OTn/U1P/Jyf/k5M2pYV9AAAGvElEQVR4nN3dbVvbNhgF4LgjFEIK7cbWbXSDhEJpWff/f95qHOOXyLJ09Lwc73zd5aB7so4sKGa1iuTmTey/8uTqCrxwU1WLIJ5WFUZ8X/3IW+HRKOS0HidCfAFW1U/iIxLOuhlnPvEArM7IiQdgPvG8eg01cY2O86Lqhbhu1v1x5hAHQGLiejjOdOJ5VS2CuB6PM3Utvh9fSEo8AqYSA0DKujkJjTOFGAQSEoPAlHFuwhfS7YvvJsY5S7yY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BZ/B+/3I54avRR0E3+gOQ4BWwM0FL5mn/+hHcRBT4ed/7EKpXo48CP4t+HHwM0avRR0FbdATkbdTfwVF9HgNpXo0uBPy+D3wY4yyit2gQSPFqdF0g36ZR+CQjSlTZNFBgoGS6MP2dKfQWPYsBmepGcJvgJP4BjuJ+DshCRGfwYR7IcZiCgdMtKkOUqhvRJxlGItqiCWuwje9hCm7RXzK+iOdhCm3RLKBno/4Nft37PKDfYQoFJm0Tw/jMInqLfssH+hym0JKBgB6bhuqTjCgR3DRQ4FNuyXSxPUwZbRNSxPy6+Qf8SgUzaEv8An6db2VAOyI6g7elQKvDFLrRP6MtKkNMrxu0ZARm0IaIAh9kgPqHKRT49KcQUPswha7Bwm1iGM1GvQM/+UFuBuvoHaZQoFDJdNGaRXQffJYGKh2mtvA+KA9U2TRgoPgtWkic2jRgoHDJdJE+TKFr8LsWULpuSLYJPeIj+EnPmkBJIjqDO52S6SJ0mNqia1AdKLRpwECVfVCByLYPjlN8mNqi35NR3CaGKT1MoSVjBixs1O0OvFZ5mxim5DD1L3jlzhJYUDc36L91erQpmWLieX0t8q9+zYEgcdNcm080vkVh4qa9NvdfW9x6AIFG3XTX5v0gTfU0IUi86F+bQ3SawTpZxMvhtenfBnZZg20yiJfja1Nn8dETmFE3F8fXptWNMzCZuAldm0J0ByYSg8DVdp7ougbbJKzFMHA1vxZvt5aSycw+hp9PXxtvVBLg7CwetWg/MeKOBTgzi1Fg7KeHBCXTJTKLM8DptXjHBIw0amQNHrINE8mAk8TJFu0lSKS6RZsEiSnAIJGoZLoE1mIacHXcqM+MwAAx8Cw6lWGj7vQGWZYRcbZF++kT7zhnsM4aBvaJdC3aT69uMm7RJm3dfGEG9ojJJfOaQ6NSz2CdExT4g1g36iPvGmyzRoEvP3SjbdF+TlMe1cLZfuWfwTqnUeB/ZLeA6Qddy/kAAAAASUVORK5CYII=")
    cross.set_size(88, 88)
    cross.set_position(3, 0)
    add(cross)
def insert_image_o():
    o = Image(":ANd9GcRklAkZYW829gXYYmGLG_FOosd0FJMjbVL5RA&s")
    o.set_size(88, 88)
    o.set_position(get_width()/3+6, 0)
    add(o)
#    if turn() = player_one():
        
#def check_win():
    
#def list_procedure():
#insert_image()
print(memory)

本文标签: pythoncheck mouse click positionBrython 30CodeHSStack Overflow