samedi 30 janvier 2021

IndexError: tuple index out of range walking dot

i want to create a dot using create_line in a canvas that corresponds to a random position inside the canvas shape specifically a circle one that loops until it reaches outside the circle like a walking dot scenario the code is as follows

    def movem(self, movesetx, movesety): #function for having movement
    self.movesetx = movesetx
    self.movesety = movesety
    xar.append(movesetx)
    yar.append(movesety)


    if directw == "E" :
        movesetx = centerx + 1
        movesety = centery

    elif directw == "N":
        movesetx = centerx
        movesety = centery + 1

Here is the code getting a value in a list of Directions (N for North, E for east etc.) Canva = canvas(tkinter)

p1=Full().movem(movesetx=random.choice(directw),movesety=random.choice(direction))
l = canva.create_line(p1,p2,p1,p2)



Aucun commentaire:

Enregistrer un commentaire