Source

pygamegsoc12 / alchemymadness / main.py

Full commit
Szymon Wróblewsk… c523ef9 
illume 9a31d1e 



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



illume 9a31d1e 
Szymon Wróblewsk… 57153a0 

"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 
Szymon Wróblewsk… c523ef9 
illume 3f370bf 
Szymon Wróblewsk… 57153a0 
illume 85da37e 
illume f73f422 
illume 85da37e 
illume 605eb4e 


illume 85da37e 
"Sam...@sambull.… b088e0d 
"Sam...@sambull.… a352039 


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

"Sam...@sambull.… a352039 

illume 59db4ab 

Szymon Wróblewsk… 57153a0 
illume 4e0a69e 








Szymon Wróblewsk… c523ef9 

Szymon Wróblewsk… 57153a0 
illume 85da37e 



Szymon Wróblewsk… 57153a0 
illume 9a31d1e 


Szymon Wróblewsk… 8d74cfa 



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

illume 59db4ab 

from random import randint

import pygame
from pygame.locals import *

import resources
import layout
import potion
import blocks

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

    pygame.init()
    screen = pygame.display.set_mode(layout.screen_size)
    pygame.display.set_caption("Alchemy Madness")
    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)
    # TODO: change something so potion dont start filled with white fluid
    sprites = pygame.sprite.LayeredDirty(pot)
    sprites.clear(screen, resources.background)

    grds = blocks.Grids(sprites)

    # player index we are controlling.
    which_player = 0
    blks = grds.grids[which_player].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()
                if e.key == K_c:
                    blks.change_color((randint(0,255),randint(0,255),randint(0,255)))

                # 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.update(time)
        # Draw sprites
        rects = sprites.draw(screen)
        # TODO: Move text code somewhere else
        screen.blit(resources.font[40].render('Alchemy Madness', True, (255,255,255)), (10,555))
        pygame.display.update(rects)


    # End game
    score = pot.get_score()

    pygame.quit()

if __name__ == "__main__":
    main()