All pastes #425353 Raw Edit

Untitled

public text v1 · immutable
·published 2007-04-05 13:05 UTC
rendered paste body
import os,sys
import pygame
from grid import *
from pygame.locals import *
 
maze = [[1,0,0],[0,1,0],[0,0,1]]
n=len(maze)
pixels = 800/n
 
 
grid = Grid((pixels,pixels), (n,n), "Generated Maze")
 
blackBlock = pygame.Surface( (pixels, pixels) )
whiteBlock = pygame.Surface( (pixels, pixels) )
blackBlock.fill((0,0,0))
whiteBlock.fill((255,255,255))
clock = pygame.time.Clock()
 
while True:
    clock.tick(30)
    for event in pygame.event.get():
        if event.type == QUIT or (event.type == KEYDOWN and event.key==K_ESCAPE):
            pygame.quit()
            sys.exit()
    for row in xrange(grid.grid_size[1]):
        for col in xrange(grid.grid_size[0]):
            pos = col,row
            if maze[col][row]:
                grid.screen.blit(blackBlock, (col*grid.block_size[0], row*grid.block_size[1]))
            else:
                grid.screen.blit(whiteBlock, (col*grid.block_size[0], row*grid.block_size[1]))
    pygame.display.flip()