Source

pygamegsoc12 / alchemymadness / main.py

Full commit

import pygame
from pygame.locals import *

import skelutil

import potion

SCREEN_SIZE = (800, 600)


def main():
    """ your app starts here
    """

    pygame.init()
    screen = pygame.display.set_mode(SCREEN_SIZE)
    clock = pygame.time.Clock()
    going = True

    screen.fill((0,0,0))
    background = pygame.image.load(skelutil.data_dir("bg.png")).convert_alpha()

    # Tetris area
    pygame.draw.rect(background, (0,0,255),
                     (10, 10, SCREEN_SIZE[0]*.4, SCREEN_SIZE[1]*.7), 1)

    screen.blit(background, (0,0))
    pygame.display.flip()

    # Initialise level
    pot = potion.Potion()
    pot.set_formula(10, 20, 30)

    #TEST
    pot.add_color((0,0,255))

    while going:
        time = clock.tick(30)

        rects = []
        events = pygame.event.get()
        for e in events:
            if e.type == KEYDOWN and e.key == K_SPACE:
                pot.add_color((255,0,0))
                screen.fill(pot.col, pot.rect)
                rects.append(pot.rect)
            if e.type == QUIT or e.type == KEYDOWN and e.key == K_ESCAPE:
                going = False

        screen.blit(background, (0,0))
        pygame.display.update(rects)

    # End game
    score = pot.get_score()

    pygame.quit()