Python Forum
question about my Pygame code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
question about my Pygame code
#1
Hi everyone, I am trying to learn about the Pygame framework by following this Medium article. However, my code so far only shows the game window screen for a split second and then it closes out. I know that as long as my while loop boolean remains "True" it should keep the window screen open until the player exits out the screen. I am not sure why it keeps running to completion and closes by itself. Any or help or suggestions would be greatly appreciated. Thanks!

import pygame

pygame.init()

screen = pygame.display.set_mode((500, 500))
pygame.display.set_caption('Pygame from Medium')

done = False
while not done:
    for event in pygame.get():
        if event.type == pygame.QUIT:
            done = True
    
    pygame.display.flip()
Reply
#2
for event in pygame.event.get () :
Instead of...
for event in pygame.get () :
Reply
#3
(Feb-06-2022, 06:41 PM)BashBedlam Wrote:
for event in pygame.event.get () :
Instead of...
for event in pygame.get () :

Thanks!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  question about my pygame code for space shooter Than999 4 2,540 Feb-07-2022, 03:55 AM
Last Post: metulburr
  [PyGame] Problems with jump code in pygame Joningstone 4 5,395 Aug-23-2021, 08:23 PM
Last Post: deanhystad
  Distributing Python/Pygame code with CX_Freeze jfng75 2 2,827 Jan-11-2021, 10:23 PM
Last Post: snippsat
  My Pygame Code always says "(Not responding") noodlespinbot 3 8,148 Feb-29-2020, 10:50 PM
Last Post: Windspar
  [pygame] Improvement with code SheeppOSU 1 2,422 Jul-24-2019, 11:09 AM
Last Post: metulburr
  [PyGame] Beginning PyGame question about "self" jakegold98 2 3,195 Dec-09-2017, 12:51 AM
Last Post: metulburr
  Python Pygame code help Trajme 1 4,045 Dec-07-2017, 04:55 PM
Last Post: nilamo
  Appropriately delay this PyGame code kleynah22 2 4,404 Nov-09-2017, 02:00 PM
Last Post: Windspar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020