Pages

duminică, 7 august 2011

PyGame : The script tool with colors.

This is a simple script to allow us to see all colors used by pygame.
import pygame
from pygame.locals import *
from pygame.color import THECOLORS
from time import sleep

def main():
    WINSIZE = 640,480
    pygame.init()
    screen = pygame.display.set_mode(WINSIZE,0,8)
    pygame.display.set_caption('Colors in pygame!')

    for i,j in THECOLORS.iteritems():
        print i
 screen.fill(THECOLORS[i])
 font = pygame.font.Font(None, 36)
 text = font.render(i, 1,(0,0,0),(100,100,100))
 sleep(1.1)
 textpos = text.get_rect()
 textpos.centerx = screen .get_rect().centerx
 screen.blit(text, textpos)
 pygame.display.update()

if __name__=="__main__":
    main()
The script is very simple, just try it.