[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Pygame graphics window Freezes



ryan luna wrote:
hey, im trying to follow the Tut on the pygame site, but whenever i open a new window like

window = pygame.display.set_mode((468, 60))

the window opens but it crashes, im running for the IDE like
it says to, but i don't know whats going wrong -_-.

btw, i do import pygame and all that stuff.

I think what you're seeing is that the Pygame window doesn't do anything, and that's because it's not being updated. If you type:


import pygame ## Load Pygame
pygame.init() ## Initialize Pygame
screen = pygame.display.set_mode( (640,480) ) ## Create the screen window
screen.set_at( (42,42), (0,0,255) ) ## A tiny blue dot

Nothing will happen! The dot won't be visible because the screen hasn't been updated. So:

pygame.display.update()

Now the dot should appear; if you can't see it try repeating the set_at command to draw a 2x2 square, then updating.

In an actual game, you'll want to update the screen very frequently, so put the update command inside the game's main loop, something like:

game_over = False
while not game_over:
    HandleInput()
    AwesomeAI()
    CalculateRealisticPhysics()
    DrawAmazingGraphics()
    pygame.display.update()


I hope this is useful.

Kris