Pygame Window Closing Automatically
I am using Python 3.4.4 with the appropriate PyGame version. While this code runs, for some reason the application does not close. I have to close the IDLE shell itself in order to close the window. I'm not sure why the game doesn't close. I'm having troubles with my pygame window immediately closing, even though its encased in a 'While True:' loop. Import os import pygame import sys import random import Projectile import Enemy import Player # Define constants WHITE = (255, 255, 255) BLACK = (0, 0, 0) RED = (255, 0, 0) GREY = (30, 30, 30) # Center the game window & start the environment, set up display os.environ'SDLVIDEO. I'm guessing because pygame is hardware accelerated there are issues running the display on a remote desktop, also because tight vnc creates a separate desktop sessions it seems to me. I've tried initialized the pygame display with pygame.SWSURFACE but I still get the MIT-MAGIC-COOKIE-1 error.
Hello, I am relatively new with Python and Pygame, however, I am an experienced PHPer, so programming isn't something new to me. My problem is this: I got Python 2.4 installed and Pygame 1.6 for Python 2.4 installed. I know Pygame works because I can make calls to the Pygame modules.
My problem is, when I try to open a window through Pygame using
it opens a window, but then lags, and finally crashes and I have to use the oh-so-lovable Crtl-Alt-Del to kill it. I can't figure this out. If I use Tkinter to open windows, they open and execute just fine. The problem only persists with Pygame. Any help at all would be appreciated.
- 2 Contributors
- forum3 Replies
- 347 Views
- 9 Hours Discussion Span
- commentLatest PostLatest Postby vegaseat
Pycharm Pygame
Recommended Answers
The mode you are trying to set in ...
is really not very close to any recognizable mode. Pygame does search for the closest possible mode, but may be overtaxed in this case!
Jump to PostPygame Window Closing Automatically Change
All 3 Replies
The mode you are trying to set in ...
Pygame Window Closing Automatically Start
is really not very close to any recognizable mode. Pygame does search for the closest possible mode, but may be overtaxed in this case!
Pygame Window Closing Automatically Start
http://www.learningpython.com/2006/0...game-part-one/
and when closing the program the window stays up and doesnt respond. i
tried adding this:
http://www.pygame.org/wiki/FrequentlyAskedQuestions
bu it doesnt work, or maybe im doing it wrong.
heres the code without the added tutorial exit:
import os, sys
import pygame
from pygame.locals import *
if not pygame.font: print 'Warning, fonts disabled'
if not pygame.mixer: print 'Warning, sound disabled'
class PyManMain:
''The Main PyMan Class - This class handles the main
initialization and creating of the Game.''
def __init__(self, width=640,height=480):
''Initialize''
''Initialize PyGame''
pygame.init()
''Set the window Size''
self.width = width
self.height = height
''Create the Screen''
self.screen = pygame.display.set_mode((self.width
, self.height))
def MainLoop(self):
''This is the Main Loop of the Game''
while 1:
for event in pygame.event.get():
if event.type pygame.QUIT:
sys.exit()
class Snake(pygame.sprite.Sprite):
''This is our snake that will move around the screen''
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.image, self.rect = load_image('snake.png',-1)
self.pellets = 0
if __name__ '__main__':
MainWindow = PyManMain()
MainWindow.MainLoop()