Jump to content
  • Advertisement
Sign in to follow this  

[pygame] white screen won't initialize

This topic is 4262 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm rewriting some code in pygame and for some reason, after initializing everything (or so it seems), screen.fill(white) (with white set to 255, 255, 255 RBG colors) won't set the screen to white. Code:
import pygame, sys,os
from pygame.locals import *
pygame.init()

def initialize():
    window = pygame.display.set_mode((800,500)) #setup screen size
    #where images can be held
    pygame.display.set_caption("Sprite walking")
    
pygame.init()
initialize()
screen = pygame.display.get_surface() # set area in memory
white = 255, 255, 255
screen.fill(white)
sprite_names = [os.path.join("pics", s) for s in ["guy.bmp", "walkone.bmp", "walktwo.bmp"]]
sprites = [pygame.image.load(s) for s in sprite_names]
running = True
time = 0
spritenumber = 0
x = 0
pygame.display.flip #update display
while running == True:
    for event in pygame.event.get():
        if event.type == QUIT:
                running = False

    ctime = pygame.time.get_ticks()
    if ctime - time > 500:
        x = x + 10
        time = ctime
        spritenumber = (spritenumber + 1) % 3
        screen.blit(sprites[spritenumber], (x, 100))
        pygame.display.flip

pygame.quit()

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!