Browse Source

Add debug config and debug in 2D view

Bastien Sevajol 6 years ago
parent
commit
23de9df5ed
3 changed files with 26 additions and 0 deletions
  1. 2 0
      sandbox/tile/config.yaml
  2. 23 0
      sandbox/tile/gui/fire.py
  3. 1 0
      synergine2_cocos2d/layer.py

+ 2 - 0
sandbox/tile/config.yaml View File

@@ -8,3 +8,5 @@ game:
8 8
         walk_ref_time: 3
9 9
         run_ref_time: 1
10 10
         crawl_ref_time: 10
11
+global:
12
+    debug: true

+ 23 - 0
sandbox/tile/gui/fire.py View File

@@ -35,6 +35,29 @@ class BaseFireActorInteraction(BaseActorInteraction):
35 35
                 matrix_name='visibility',
36 36
                 opacity_property_name='opacity',
37 37
             )
38
+
39
+            # DEBUG
40
+            if self.layer_manager.debug:
41
+                grid_paths = self.layer_manager.edit_layer.matrixes.get_path_positions(
42
+                    from_=actor_grid_position,
43
+                    to=mouse_grid_position,
44
+                )
45
+                previous_grid_path = None
46
+                for grid_path in grid_paths:
47
+                    if previous_grid_path:
48
+                        previous_grid_path_pixel = self.layer_manager.grid_manager.get_pixel_position_of_grid_position(
49
+                            previous_grid_path,
50
+                        )
51
+                        current_grid_pixel = self.layer_manager.grid_manager.get_pixel_position_of_grid_position(
52
+                            grid_path,
53
+                        )
54
+                        draw_line(
55
+                            previous_grid_path_pixel,
56
+                            current_grid_pixel,
57
+                            (25, 125, 25),
58
+                        )
59
+                    previous_grid_path = grid_path
60
+
38 61
             if obstacle_grid_position:
39 62
                 obstacle_pixel = self.layer_manager.grid_manager.get_pixel_position_of_grid_position(
40 63
                     obstacle_grid_position,

+ 1 - 0
synergine2_cocos2d/layer.py View File

@@ -85,6 +85,7 @@ class LayerManager(object):
85 85
 
86 86
         from synergine2_cocos2d.gui import EditLayer
87 87
         self.edit_layer_class = self.edit_layer_class or EditLayer
88
+        self.debug = self.config.resolve('global.debug', False)
88 89
 
89 90
     def init(self) -> None:
90 91
         # TODO: cyclic import