I am learning to make games with pygame, which I am not very familiar with, and everything has been going great. Recently, I got an error which confuses me...
Here is the specific code which gives me the error...
def draw(self, win):
self.move()
if self.visible:
if self.walkCount + 1 >= 33: # Since we have 11 images for each animtion our upper bound is 33.
# We will show each image for 3 frames. 3 x 11 = 33.
self.walkCount = 0
if self.vel > 0: # If we are moving to the right we will display our walkRight images
win.blit(self.walkRight[self.walkCount // 3], (self.x, self.y))
self.walkCount += 1
else: # Otherwise we will display the walkLeft images
win.blit(self.walkLeft[self.walkCount // 3], (self.x, self.y))
self.walkCount += 1
pygame.draw.rect(win, (255, 0, 0), (self.hitbox[0], self.hitbox[1], -20, 50, 10))
pygame.draw.rect(win, (0, 255, 0), (self.hitbox[0], self.hitbox[1], -20, 50, 10))
self.hitbox = (self.x + 17, self.y + 2, 31, 57)
When I execute my code, I get this error...
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "/Users/user/PycharmProjects/Marvel2/Pepe.py", line 215, in <module>
redrawGameWindow()
File "/Users/user/PycharmProjects/Marvel2/Pepe.py", line 133, in redrawGameWindow
goblin.draw(win)
File "/Users/user/PycharmProjects/Marvel2/Pepe.py", line 95, in draw
pygame.draw.rect(win, (255, 0, 0), (self.hitbox[0], self.hitbox[1], -20, 50, 10))
TypeError: Rect argument is invalid
Process finished with exit code 1
Can anyone help me?
Thanks!