-1

i am a beginner to pygame and i tried loading an image but it didn't work heres my code (also the image is just a deltarune characters face that i found funny)

import pygame 
import os

pygame.init()
screen = pygame.display.set_mode((1280, 720))
clock = pygame.time.Clock()
running = True
dt = 0

player_pos = pygame.Vector2(screen.get_width() / 2, screen.get_height() / 2)

goofyahgamer = pygame.image.load(os.path.join("goofyahgamer.png"))

while running:
    

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
    screen.fill("purple")

    pygame.draw.circle(screen, "red", player_pos, 40)

    keys = pygame.key.get_pressed()
    if keys[pygame.K_w]:
        player_pos.y -= 300 * dt
    if keys[pygame.K_s]:
        player_pos.y += 300 * dt
    if keys[pygame.K_a]:
         player_pos.x -= 300 * dt
    if keys[pygame.K_d]:
         player_pos.x += 300 * dt

    pygame.display.flip()


    dt = clock.tick(60) / 1000

pygame.quit     

i tried following the pygame docs to learn how to load an image but it didn't work it still was a circle a purple one

  • You have to [`blit`](https://www.pygame.org/docs/ref/surface.html#pygame.Surface.blit) the image instead of drawing the circle: `screen.blit(goofyahgamer, player_pos)` – Rabbid76 Aug 25 '23 at 11:49

0 Answers0