pygamegsoc12 / alchemymadness / main.py

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 
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… 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 

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)
    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()

                # 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()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.