1

I believe this is the necessary code to initialize Pygame:

running = True

pygame.init()

while running:
    screen.fill((0, 0, 0))
    screen.blit(background, (0,0))
    for event in pygame.event.get(): 
        if event.type == pygame.QUIT:
            running = False

However, it isn't working. I have already tried to update my "pip install pygame", and it did, but to no avail. I use Sublime Text 3.

Navzyx-kun
  • 11
  • 1
  • 1
    Probably the problem is not with your code, but on your system. It makes no sense to ask a question about your code. You have to repair your system yourself. We have no access to your system and can only guess. What is you OS, IDE, Python and Pygame verison? – Rabbid76 Apr 03 '21 at 08:02
  • The problem is that Pygame is looking for keyboard input, which Sublime can't provide with the default build system. You will either have to run it via SublimeREPL or use a modified build system. Instructions are available in the two linked duplicates. – MattDMo Apr 04 '21 at 19:03
  • Did you create the screen? I don’t see it in the code at all – Samantha Garcia Apr 04 '21 at 19:03

1 Answers1

0

You have to create a display Surface with pygame.display.set_mode:

import pygame

pygame.init()
screen = pygame.display.set_mode((640, 480))

running = True
while running:    
    for event in pygame.event.get(): 
        if event.type == pygame.QUIT:
            running = False

    screen.fill((0, 0, 0))
    pygame.display.update()
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • still didn't work, i updated my pygame, i believe i'm using the latest windows version, and i use python 3.8.1 – Navzyx-kun Apr 04 '21 at 07:49
  • @Navzyx-kun I have told you in my comment that the issue very likely is not related to your code but your system. You have to fix your system yourself – Rabbid76 Apr 04 '21 at 08:02
  • 1
    my guess is that i use sublime for free, and it says that you can use it for a limited time. i guess my time has come – Navzyx-kun Apr 04 '21 at 08:11
  • 1
    @Navzyx-kun functionality of Sublime in it's Licensed versus Evaluation state is the same. Is your question meant to indicate that if you run your Python program from a command prompt/terminal it works fine but from Sublime it doesn't? – OdatNurd Apr 04 '21 at 13:57