view 001/000.py @ 12:9dc97f88e274 default tip

Added CC0 license
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sun, 08 Jul 2012 19:56:38 +0200
parents 2661d2091f1d
children
line wrap: on
line source

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import pygame
import pygame.locals as pg


def initialize_screen():
    pygame.display.init()
    screen = pygame.display.set_mode((800, 600))
    screen.fill((0x66, 0x66, 0x66))
    return screen

def load_images():
    images = {
        'X': pygame.image.load('wall.png').convert(),
        '.': pygame.image.load('dirt.png').convert(),
        '@': pygame.image.load('hero.png').convert(),
    }
    return images

def draw_map(screen, images):
    screen_rect = screen.get_rect()
    for y in xrange(screen_rect.h // 32):
        for x in xrange(screen_rect.w // 32):
            screen.blit(images['.'], (x * 32, y * 32))

def wait_for_quit():
    pygame.display.update()
    while True:
        event = pygame.event.wait()
        if event.type == pg.QUIT:
            return

def run_game():
    screen = initialize_screen()
    images = load_images()
    draw_map(screen, images)
    wait_for_quit()


if __name__ == '__main__':
    run_game()