illume avatar illume committed 85da37e

can control which player is being controlled by keys, by pressing keys 1-4

Comments (0)

Files changed (3)

alchemymadness/blocks.py

 class Grid(object):
     """ Contains Blocks()
     """
-    def __init__(self, small):
+    def __init__(self, grid_num):
         super(Grid, self).__init__()
-        self.small = small
+        self.grid_num = grid_num
+        # draw the first one big.
+        self.small = grid_num != 0
 
         self.GRID_SIZE_W = GRID_SIZE_W
         self.GRID_SIZE_H = GRID_SIZE_H
 
         if self.small:
-            self.rect = pygame.Rect(30, 20, GRID_SIZE_W * SBLOCK_W, GRID_SIZE_H * SBLOCK_H)
+            # TODO: get correct coords.
+            if self.grid_num == 1:
+                self.rect = pygame.Rect(300, 20, GRID_SIZE_W * SBLOCK_W, GRID_SIZE_H * SBLOCK_H)
+            if self.grid_num == 2:
+                self.rect = pygame.Rect(470, 20, GRID_SIZE_W * SBLOCK_W, GRID_SIZE_H * SBLOCK_H)
+            if self.grid_num == 3:
+                self.rect = pygame.Rect(630, 20, GRID_SIZE_W * SBLOCK_W, GRID_SIZE_H * SBLOCK_H)
         else:
             self.rect = pygame.Rect(30, 20, GRID_SIZE_W * BLOCK_W, GRID_SIZE_H * BLOCK_H)
 
     def __init__(self):
         """
         """
-        self.grids = [Grid() for x in range(self.NUM_GRIDS)]
+        self.grids = [Grid(x) for x in range(self.NUM_GRIDS)]
 
 
 

alchemymadness/main.py

     # Initialise level
     pot = potion.Potion()
     pot.set_formula(3, 5, 3)
-    grd = blocks.Grid(small = True)
-    blks = blocks.Blocks(grd)
     sprites = pygame.sprite.LayeredDirty(pot)
-    for b in blks.blocks:
-        sprites.add(b)
+
+
+    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))
                 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
 

alchemymadness/resources.py

     background = pygame.image.load(skelutil.data_dir("bg.png")).convert_alpha()
     block = pygame.image.load(skelutil.data_dir("block.png")).convert_alpha()
     sblock = pygame.transform.scale(block, (int(block.get_rect()[2]/2), int(block.get_rect()[3])))
-    print block, sblock
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.