May-23-2018, 07:42 PM
Just started to get into programming with pygame. Unfortunately, I am constantly getting the following error:
[b]"C:\Programming\pygame.template.py", line 29, in <module>
for event in pygame.event.get():
pygame.error: video system not initialized
Here is my code:
# a skeleton for new pygame projects
import pygame
import random
width = 360
height = 480
FPS = 30
#define colors
white = (255, 255, 255)
black = (0, 0, 0)
red =(255, 0 ,0)
green = (0, 255, 0)
blue = (0, 0, 255)
#initialize pygame and create window
pygame.init()
pygame.mixer.init()
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("My Game")
clock = pygame.time.Clock()
# Game Loop
running= True
while running:
# keep loop running at the right speed
clock.tick(FPS)
# Process input (events)
for event in pygame.event.get():
# check for closing window
if event.type == "pygame.QUIT":
running = False
# Update
# Draw / render
screen.fill(black)
#after drawing flip everything
pygame.display.flip()
pygame.quit()
I appreciate you guys/girls help to the fullest!
[b]"C:\Programming\pygame.template.py", line 29, in <module>
for event in pygame.event.get():
pygame.error: video system not initialized
Here is my code:
# a skeleton for new pygame projects
import pygame
import random
width = 360
height = 480
FPS = 30
#define colors
white = (255, 255, 255)
black = (0, 0, 0)
red =(255, 0 ,0)
green = (0, 255, 0)
blue = (0, 0, 255)
#initialize pygame and create window
pygame.init()
pygame.mixer.init()
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("My Game")
clock = pygame.time.Clock()
# Game Loop
running= True
while running:
# keep loop running at the right speed
clock.tick(FPS)
# Process input (events)
for event in pygame.event.get():
# check for closing window
if event.type == "pygame.QUIT":
running = False
# Update
# Draw / render
screen.fill(black)
#after drawing flip everything
pygame.display.flip()
pygame.quit()
I appreciate you guys/girls help to the fullest!
