I tried to initialize with pygame using the code below.
import pygame
pygame.init()
But I get 2 errors.
pygame 2.0.1 (SDL 2.0.14, Python 3.8.10)
Hello from the pygame community. https://www.pygame.org/contribute.html
ftruncate() failed: File too large
Failed to create secure directory (//.config/pulse): No such file or directory
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
Traceback (most recent call last):
File "main.py", line 3, in <module>
pygame.key.get_repeat()
pygame.error: video system not initialized
Can anyone help me?
My code is below.
# importing pygame module
import pygame
# importing sys module
import sys
# initialising pygame
pygame.init()
# creating display
display = pygame.display.set_mode((300, 300))
# creating a running loop
while True:
# creating a loop to check events that
# are occuring
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
# checking if keydown event happened or not
if event.type == pygame.KEYDOWN:
# if keydown event happened
# than printing a string to output
print("A key has been pressed")