-1

I am making game from "Python Crash Course" but have a problem with showing pygame window. It looks like Python Launcher app trying to launch but nothing happens, icon of Python Launcher bouncing in Dock and that's it.

import sys

import pygame

def run_game():
    #Initilize game and create a screen object.

    pygame.init()
    pygame.display.init()
    screen = pygame.display.set_mode((1200, 800))
    pygame.display.set_caption("Alien Invasion")

#Start the main loop for the game.

    while True:

    # Watch for keyboard and mouse events.
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

    # Make the most recently drawn screen visible.
        pygame.display.flip()

run_game()

any idea how to fix it? Thank you very much for any help!

upd. I am using MacOS Catalina.

Olesya M
  • 29
  • 4
  • When I run your code a pygame window does appear and is blank — because there's nothing being put into it. Are you using MacOS by any chance? If so, please tag your question accordingly. – martineau Mar 13 '20 at 22:44
  • Thank you for your reply. Yes it should show blank window, but in my case it doesn't show anything, it is like trying to launch but can't. I tried different others code, just to check will it launch or not, still not working. All I can see it is an icon of Python Launcher app bouncing in Dock – Olesya M Mar 13 '20 at 23:21
  • Most likely an install issue - try reinstalling pygame. There are many questions here about using Python on MacOS (because the OS comes with its own version — or at least it used to). – martineau Mar 14 '20 at 00:18
  • @OlesyaM Can you share some more information on your environment? Which packages, versions, how were they installed, etc. – AMC Mar 14 '20 at 00:30
  • Python 3.8.2 and PyGame 1.9.6. PyGame was installed via terminal "pip3 install pygame". I am new at python, so I am not sure what else to add. I googled my problem, found only one question on Redit like mine but it was not answered. I did reinstall pygame, but still have the same problem. – Olesya M Mar 14 '20 at 20:04
  • Found the solution [https://stackoverflow.com/a/60496097/1739955] needed different version of pygame – Olesya M Mar 14 '20 at 20:09

0 Answers0