0

I get same error as this person: pygame.error: video system not initialized, but I have called pg.init().

Two unexpected things happened,

  1. link didnt appear (the background did, and they're in the same directory
  2. after i close the pygame window i get the error mentioned in title
# -*- coding: utf-8 -*-

import pygame as pg

pg.init()

overflate = pg.display.set_mode((500,350))

pg.display.set_caption("Spill")
bg = pg.image.load("castle.jpg")
link = pg.image.load("link.png")
linkx = 0
linky = 0

overflate.blit(link,(linkx, linky))
pg.display.update()

overflate.blit(bg,(0, 0))
pg.display.update()

while True:
    for e in pg.event.get():
        if e.type == pg.K_w:
                spillerx+=10
        if e.type == pg.QUIT:
            pg.quit()
    pg.display.update()

1 Answers1

0

You have to blit the image after drawing the background:

run = True
while run:
    for e in pg.event.get():
        if e.type == pg.K_w:
            spillerx+=10
        if e.type == pg.QUIT:
            run = False
    
    overflate.blit(bg,(0, 0))
    overflate.blit(link,(linkx, linky))
    pg.display.update()

pg.quit()

The typical PyGame application loop has to:

Rabbid76
  • 202,892
  • 27
  • 131
  • 174