Receiving ValueError: invalid recstyle object

后端 未结 1 1282
失恋的感觉
失恋的感觉 2021-01-27 02:54

I am following the instructions of a pygame project on youtube, this is the video, I am on the project called "Snake", and in the description of the video, you can fin

1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-27 03:29

    You have to specify the color by a tuple:

    surface.fill(0,0,0)

    surface.fill( (0, 0, 0) )
    

    Explanation:

    The first argument of fill() is the color (tuple). The other arguments are optional. The 2nd argument is an optional rectangle specifying area to be filled. The 3rd arguments are optional flags.

    Hence the instruction surface.fill(0,0,0) can be read as:

    surface.fill(0, rect=0, special_flags=0)
    

    The 2nd argument (rect=0) causes the error

    ValueError: invalid rectstyle object

    0 讨论(0)
提交回复
热议问题