Ive been trying to make a game recently but all pygame windows freeze. i have to use the Task Manager to exit. I also have to use it to exit a fullscreen too. All im doing in my code is opening a blank screen. How can i fix that?

Recommended Answers

All 7 Replies

hmm well i've little experience with pygame myself but are you sure your not missing something in your code?
i think you need to type stuff like pygame.init() and you have to flip the display stuff like that, like i said i'm not too sure but if you go on the pygame website http://www.pygame.org they might have something in the documentaion or go on their irc channel
a snippet of your code might be good?
then someone can look at it and see whats wrong

This the most basic test for PyGame that I have, give it a fly ...

import pygame
from pygame.locals import *

yellow = (255,255,0)    # RGB color tuple
    
# initialise screen
pygame.init()
screen = pygame.display.set_mode((350, 250))
pygame.display.set_caption('Basic Pygame program')

# fill background
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill(yellow)

# display some text
font = pygame.font.Font(None, 36)
text = font.render("Hello from Monty PyGame", 1, (10, 10, 10))
textpos = text.get_rect()
textpos.centerx = background.get_rect().centerx
background.blit(text, textpos)

# blit everything to the screen
screen.blit(background, (0, 0))
pygame.display.flip()

# event loop
while 1:
    for event in pygame.event.get():
        if event.type == QUIT:
            raise SystemExit
    screen.blit(background, (0, 0))
    pygame.display.flip()

Powerful stuff that SDL, mind you, just a little complex at first blush!

In that simple program it still crashes. i'm guessing its something wrong with pygame or my computer. Have u heard of this happening before?

Make sure you have the right version of PyGame downloaded. I use Windows XP and Python24 so I downloaded the installer file:
pygame-1.6.win32-py2.4.exe
from http://www.pygame.org/

I understand that PyGame is simply a wrapper for SDL. That creates a problem, Python has a good memory manager, but SDL written in C++ has the usual memory management is up to you thing. THESE TWO WORLDS LIKE TO CLASH AND CRASH!

I have played around with some of the pygame examples posted on the net, and they don't always behave well! I actually managed to get the "grey screen of death" on Windoze XP!

I have it working now, but is there a way a way i can have it so the window doesnt pop asking if u really want to quit?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.