1

When running this code, i don't get any error but my window doesn't display anything except the name of the window, why? It doesn't work in Atom editor nor PyCharm. EDIT: I'm using a mac

import pygame as pg

pg.init()

window = pg.display.set_mode((400, 300))
name = pg.display.set_caption('Hello World!')

white = (255, 255, 255)
green = (0, 255, 0)
blue = (0, 0, 128)

run = True

while run: # Main game loop
    pg.draw.rect(window, green, (0, 0, 50, 50))
    for event in pg.event.get():
        if event.type == pg.QUIT:
            run = False

    pg.display.flip()
eyllanesc
  • 235,170
  • 19
  • 170
  • 241

1 Answers1

0

I solved it by:

  1. Changing my Virtual environment to Anaconda 3 in atom

  2. Opening jupyter notebook in anaconda and installed pygame using pip

  3. Returned to Atom and ran the code again, the output was correct

I didn't have a selected virtual env on my project before so I'm sure it works by having any other virt-env as well. Thanks for the responses anyways.