Commits

Chas Leichner committed 14513e0

time based updates working

  • Participants
  • Parent commits 6c02f21

Comments (0)

Files changed (1)

File games/mole/mole.py

 class Mole( MTButtonMatrix ):
     
     def __init__(self,**kwargs):
+        self.time = time.time()
         kwargs.setdefault('matrix_size', (5, 5))
         super(Mole, self).__init__(**kwargs)
         self.matrix = [[1 for x in xrange(kwargs.get('matrix_size')[0])] for y in xrange(kwargs.get('matrix_size')[1])]
             #print i, j
             if self.matrix[i][j]:
                 self.matrix[i][j] = 0
-
-            if self.matrix_proportion() < 0.5:
-                self.matrix = [[1 for x in xrange(len(self.matrix))] for y in xrange(len(self.matrix[0]))]
             '''
             else:
                 self.matrix[i][j] = 1
             self.last_tile = (i, j)
 
     def draw(self):
-        #print time.time()
+        current_time = time.time()
+        if self.matrix_proportion() < 0.8 or current_time - self.time > 2:
+            self.time = current_time
+            self.matrix = [[1 for x in xrange(len(self.matrix))] for y in xrange(len(self.matrix[0]))]
+
         for i in range (self._matrix_size[0]):
             for j in range (self._matrix_size[1]):
                 self.draw_tile(i, j)