Right now i am coding a pygame zero program It is at its first steps and i am trying to make the play button why isn't it drawing? I am using screen.draw.filled_rect(text, rect, kwaargs**)
Here is my code
import pgzrun
def draw():
global x, play_button
screen.clear()
screen.blit('actualbg', (0, 0))
#screen.fill((128, 0, 0))
if first_screen:
screen.draw.text('Marvel run', center=(370, 100), fontname='impact', fontsize = 100, color="orange", owidth=1)
screen.draw.filled_rect(play_button, 'yellow')
screen.draw.textbox('Play', play_button, fo1ntname='impact', color='black')
#to be continued
WIDTH = 800
HEIGHT = 590
first_screen = True
play_screen = False
option_screen = False
play_button = Rect(100, 50)
play_button.midtop=(0, 0)
play_button.move_ip(383, 266)
first_screen = True
play_screen = False
option_screen = False
pgzrun.go()
I have looked at so many websites but they are no help:(
I ran it and it came up with
File "marvel.py", line 21, in <module>
play_button = Rect(100, 50)
^^^^^^^^^^^^^
TypeError: Argument must be rect style object
It was supposed to create a yellow rectangle with text inside it and the rectangle is filled Thanks
Right now i am coding a pygame zero program It is at its first steps and i am trying to make the play button why isn't it drawing? I am using screen.draw.filled_rect(text, rect, kwaargs**)
Here is my code
import pgzrun
def draw():
global x, play_button
screen.clear()
screen.blit('actualbg', (0, 0))
#screen.fill((128, 0, 0))
if first_screen:
screen.draw.text('Marvel run', center=(370, 100), fontname='impact', fontsize = 100, color="orange", owidth=1)
screen.draw.filled_rect(play_button, 'yellow')
screen.draw.textbox('Play', play_button, fo1ntname='impact', color='black')
#to be continued
WIDTH = 800
HEIGHT = 590
first_screen = True
play_screen = False
option_screen = False
play_button = Rect(100, 50)
play_button.midtop=(0, 0)
play_button.move_ip(383, 266)
first_screen = True
play_screen = False
option_screen = False
pgzrun.go()
I have looked at so many websites but they are no help:(
I ran it and it came up with
File "marvel.py", line 21, in <module>
play_button = Rect(100, 50)
^^^^^^^^^^^^^
TypeError: Argument must be rect style object
It was supposed to create a yellow rectangle with text inside it and the rectangle is filled Thanks
Share Improve this question edited Mar 2 at 6:55 Rabbid76 212k30 gold badges160 silver badges200 bronze badges asked Mar 2 at 6:35 user29854913user29854913 12 bronze badges 2 |1 Answer
Reset to default 1A Rect
consists of a position and a size. The position is the left top corner of the rectangle and the size is the with and height e.g.:
play_button = Rect((0, 0), (100, 50))
You can find more information in the Pygame documentation: pygame.Rect
Rect
needs 4 arguments, left, top, width, height – Rabbid76 Commented Mar 2 at 6:56