1. Kevin Luikens
  2. whackamole

Commits

Chas Leichner  committed daa4993

added red flash to touched tiles

  • Participants
  • Parent commits 206faf4
  • Branches default

Comments (0)

Files changed (1)

File games/mole/mole.py

View file
         #TODO
         #self.player_images = (MTWidget(),MTSvg(filename='cross.svg'),MTSvg(filename='circle.svg') )
         self.done = False
+        self.score = 0
 
     def matrix_proportion(self, matrix):
         size = len(matrix) * len(matrix[0])
             i, j = self.collide_point(touch.x, touch.y)
             #print i, j
             if self.matrix[i][j]:
-                self.matrix[i][j] = 0
+                self.matrix[i][j] = -2
+                self.score+=100
 
             self.dispatch_event('on_value_change', self.matrix)
             self.dispatch_event('on_press', (i, j, self.matrix[i][j]))
         for row in self.matrix:
             new_line = []
             for cell in row:
-                if cell:
+                if cell == 1:
                     new_line.append(generate_num(density * sustain_factor))
                 else:
                     new_line.append(generate_num(density / create_factor))
                     else:
                         cell = 1
 
+    def draw_tile(self, i, j):
+        destroy_color = (1,0,0,1)
+        if self.matrix[i][j] == 0:
+            set_color(*self.buttoncolor)
+        elif self.matrix[i][j] == -2:
+            set_color(*destroy_color)
+            self.matrix[i][j]+=1
+        elif self.matrix[i][j] == -1:
+            set_color(*destroy_color)
+            self.matrix[i][j] = 0
+        else:
+            set_color(*self.downcolor)
+
+        with gx_matrix:
+            glTranslatef(self.width / self._matrix_size[0] * i + self.x,
+                         self.height / self._matrix_size[1] * j + self.y,
+                         0)
+            s =  (self.width / self._matrix_size[0] - self.border,
+                  self.height / self._matrix_size[1] - self.border)
+            drawRectangle(size=s)
+
     def draw(self):
         # using time.time may cause problems on windows (if something weird is
         # happening, check here)