Source

pygamegsoc12 / alchemymadness / main.py

Full commit
illume 9a31d1e 



Szymon Wróblewsk… 8d74cfa 
"Sam...@sambull.… b088e0d 
Szymon Wróblewsk… 1d1479c 
"Sam...@sambull.… b088e0d 
"Sam...@sambull.… a352039 
illume cced44c 





illume 9a31d1e 
"Sam...@sambull.… b088e0d 
illume ec1b1a4 
"Sam...@sambull.… b088e0d 
illume 9a31d1e 
Szymon Wróblewsk… 2661df1 
Szymon Wróblewsk… 8d74cfa 
illume 9a31d1e 
"Sam...@sambull.… b088e0d 

Szymon Wróblewsk… 8d74cfa 
illume 9a31d1e 

"Sam...@sambull.… b088e0d 
"Sam...@sambull.… 9b5db54 
"Sam...@sambull.… 47c1374 
illume 3f370bf 
illume 85da37e 








"Sam...@sambull.… b088e0d 
"Sam...@sambull.… a352039 


illume 9a31d1e 
"Sam...@sambull.… b088e0d 
"Sam...@sambull.… 9b5db54 
illume 9a31d1e 

"Sam...@sambull.… a352039 

illume 59db4ab 


illume 4e0a69e 









illume 85da37e 




illume 9a31d1e 


Szymon Wróblewsk… 8d74cfa 


Szymon Wróblewsk… 2661df1 
Szymon Wróblewsk… 8d74cfa 

illume 9a31d1e 
Szymon Wróblewsk… 2661df1 
illume 9a31d1e 
"Sam...@sambull.… b088e0d 
"Sam...@sambull.… 9b5db54 
illume 9a31d1e 

illume 59db4ab 


import pygame
from pygame.locals import *

import resources
import potion
import blocks

SCREEN_SIZE = (800, 600)


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

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

    resources.init()

    screen.fill((0,0,0))

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

    # Initialise level
    pot = potion.Potion()
    pot.set_formula(3, 5, 3)
    sprites = pygame.sprite.LayeredDirty(pot)


    grds = blocks.Grids()
    for grd in grds.grids:
        for b in grd.blocks.blocks:
            sprites.add(b)

    blks = grds.grids[0].blocks


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

    while going:
        time = clock.tick(30)

        events = pygame.event.get()
        for e in events:
            if e.type == KEYDOWN and e.key == K_SPACE:
                pot.add_color((255,0,0))
            if e.type == KEYDOWN and e.key == K_s:
                pygame.image.save(screen, "screeny.png")
                
            if e.type == KEYDOWN:
                if e.key == K_LEFT:
                    blks.action_move_left()
                if e.key == K_RIGHT:
                    blks.action_move_right()
                if e.key == K_UP:
                    blks.action_move_up()
                if e.key == K_DOWN:
                    blks.action_move_down()
            
                # press keys 1-4 to control player 1-4.
                if e.key in [K_1, K_2, K_3, K_4]:
                    which_player = [K_1, K_2, K_3, K_4].index(e.key)
                    blks = grds.grids[which_player].blocks
                    
            if e.type == QUIT or e.type == KEYDOWN and e.key == K_ESCAPE:
                going = False

        # Update sprites
        sprites.clear(screen, resources.background)
        sprites.update(time)

        # Draw sprites
        rects = sprites.draw(screen)
        pygame.display.update(rects)


    # End game
    score = pot.get_score()

    pygame.quit()

if __name__ == "__main__":
    main()