I am getting argument 1 must be pygame.Surface, not string. How do I fix the error? I saw others had the same problem, but not for the same reasons. I can swear I am doing things the same way I was in another project.
import pygame
# Defining important variables
pygame.init()
keys = pygame.key.get_pressed()
clock = pygame.time.Clock()
# Screen stuff
bg_color = 255, 232, 210
screen_y = 360
screen_x = 480
screen = pygame.display.set_mode((screen_x, screen_y))
# Player's img and start coordinates.
player_img = "player.png"
player_y = 0
player_x = 0
pygame.image.load(player_img).convert()
def sprite(img, x, y):
screen.blit(img, (x + 224, y + 164))
def main():
global player_y
global player_x
sprite(player_img, player_y, player_x)
# Main script
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
break
main()
pygame.display.update()
clock.tick(60)
Traceback:
Traceback (most recent call last):
File "C:\Users\Matt\PycharmProjects\lettherebechaos\main.py", line 36, in <module>
main()
File "C:\Users\Matt\PycharmProjects\lettherebechaos\main.py", line 28, in main
sprite(player_img, player_y, player_x)
File "C:\Users\Matt\PycharmProjects\lettherebechaos\main.py", line 22, in sprite
screen.blit(img, (x + 224, y + 164))
TypeError: argument 1 must be pygame.Surface, not str
Process finished with exit code 1
Any help would be appreciated! (try to ignore that the main is pretty pointless, I just stripped out keyboard movement since it wasn't causing any issues.)