Browse Source

Display pheromones when 'p' key pressed

Bastien Sevajol 9 years ago
parent
commit
6cf5e5b2b6
1 changed files with 15 additions and 1 deletions
  1. 15 1
      intelligine/display/Pygame.py

+ 15 - 1
intelligine/display/Pygame.py View File

@@ -1,13 +1,20 @@
1 1
 from xyzworld.display.Pygame import Pygame as XyzPygame
2
+import pygame
2 3
 from intelligine.cst import PHEROMON_INFOS, PHEROMON_DIRECTION, PHEROMON_DIR_EXPLO, PHEROMON_POSITIONS
3 4
 from intelligine.synergy.object.ant.Pheromon import Pheromon
4 5
 
5 6
 
6 7
 class Pygame(XyzPygame):
7 8
 
9
+    def __init__(self, config, context):
10
+        super().__init__(config, context)
11
+        self._is_display_pheromones = False
12
+
13
+
8 14
     def receive(self, synergy_object_manager, context):
9 15
         super().receive(synergy_object_manager, context)
10
-        self._display_pheromones(context.metas.list.get(PHEROMON_POSITIONS, PHEROMON_POSITIONS, allow_empty=True), context)
16
+        if self._is_display_pheromones:
17
+            self._display_pheromones(context.metas.list.get(PHEROMON_POSITIONS, PHEROMON_POSITIONS, allow_empty=True), context)
11 18
 
12 19
     def _display_pheromones(self, pheromones_positions, context):
13 20
         for point in pheromones_positions:
@@ -31,3 +38,10 @@ class Pygame(XyzPygame):
31 38
                 pheromon = Pheromon(object(), context)
32 39
                 pheromon.set_direction(direction)
33 40
                 self._draw_objects_with_decal(point, [pheromon])
41
+
42
+    def _key_pressed(self, key):
43
+        if key == pygame.K_p:
44
+            if self._is_display_pheromones:
45
+                self._is_display_pheromones = False
46
+            else:
47
+                self._is_display_pheromones = True