Commits

illume committed 4e0a69e

Added some movement of blocks to test. Buggy when move full right.

  • Participants
  • Parent commits 3f370bf

Comments (0)

Files changed (2)

File alchemymadness/blocks.py

             b[0] -= 1
             if b[0] < 0:
                 b[0] = 0
+        self.on_moved()
 
     def action_move_right(self):
         for b in self.grid_positions:
             b[0] += 1
             if b[0] >= GRID_SIZE_W:
                 b[0] = GRID_SIZE_W - 1
+        self.on_moved()
 
 
     def action_move_up(self):
             b[1] -= 1
             if b[1] < 0:
                 b[1] = 0
+        self.on_moved()
 
     def action_move_down(self):
         for b in self.grid_positions:
             b[1] += 1
             if b[1] >= GRID_SIZE_H:
                 b[1] = GRID_SIZE_H - 1
+        self.on_moved()
 
 
 class Grid(object):
         self.GRID_SIZE_W = GRID_SIZE_W
         self.GRID_SIZE_H = GRID_SIZE_H
 
-        self.rect = pygame.Rect(100, 100, 300, 300)
+        self.rect = pygame.Rect(100, 100, GRID_SIZE_W * BLOCK_W, GRID_SIZE_H * BLOCK_H)
 
         self.restart()
     def restart(self):

File alchemymadness/main.py

             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.type == QUIT or e.type == KEYDOWN and e.key == K_ESCAPE:
                 going = False