How can I generate the position of a second click in Pygame?

前端 未结 3 646
耶瑟儿~
耶瑟儿~ 2021-01-21 22:40

I\'m making the Towers of Hanoi.

It should work like this: you click on the first tower, from where you want a disk to move, and then on the second where you want the d

3条回答
  •  不思量自难忘°
    2021-01-21 23:17

    I think this line will not do what you expect it to:

    elif len(rod1) == 1 or 2 or 3:
    

    Test in the interpreter that it does not evaluate to True but rather always to the value of 2.

    You probably meant to do something like:

    elif len(rod1) in (1, 2, 3):
    

    Or even:

    elif len(rod1) > 0:
    

    Additionally, you could still go for a series of "or" statements to cover your needs:

    [not recommended]

    elif len(rod1) == 1 or len(rod1) == 2 or len(rod1) == 3:
    

    If any one of the statements evaluates to True, the conditional statement will also be True.

提交回复
热议问题