1

Every time when i run this, it pops up with and error saying

File "c:\Users\camer\pygfa.py", line 9, in

for event in pygame.event.get(): pygame.error: video system not initialized

I also Init everything at the start

import pygame
from pygame.locals import *
import time
import os
import sys
from sys import exit
pygame.init()

screen = pygame.display.set_mode((640, 480), 0, 32)

font = pygame.font.SysFont("arial", 32); font_height = font.get_linesize()

while True:

for event in pygame.event.get():
    if event.type == QUIT: exit()

screen.fill((255, 255, 255))

pressed_key_text = []

pressed_keys = pygame.key.get_pressed()

y = font_height

for key_constant, pressed in enumerate(pressed_keys):
    if pressed:

        key_name = pygame.key.name(key_constant)

        text_surface = font.render(key_name " pressed", True, (0,0,0))
        screen.blit(text_surface, (8, y)) y = font_height

pygame.display.update()
  • 1
    The problem is with your system, but not with your code. What is your OS? Which IDE do you use? What is your python and pygame version? – Rabbid76 May 08 '21 at 14:53
  • You could maybe try putting `pygame.display.init()` at the start too and see if that helps (tho as far as I know `pygame.init` should have initialized that already) – Matiiss May 08 '21 at 19:53
  • @Rabbid76 Im using windows 10 vs code and command prompt also – Cameron Butcher May 09 '21 at 06:26

0 Answers0