Browse Source

Superposition pygame render

Bastien Sevajol 9 years ago
parent
commit
16a2ae1d76

BIN
intelligine/display/pygame/image/egg_c2.png View File


BIN
intelligine/display/pygame/image/egg_c3.png View File


BIN
intelligine/display/pygame/image/egg_c4.png View File


BIN
intelligine/display/pygame/image/egg_c5.png View File


BIN
intelligine/display/pygame/image/egg_c7.png View File


+ 25 - 0
intelligine/display/pygame/visualisation.py View File

@@ -23,6 +23,11 @@ dead_blue_ant = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/
23 23
 bug = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/ant.png')
24 24
 rock = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/rock.png')
25 25
 egg = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/egg.png')
26
+eggc2 = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/egg_c2.png')
27
+eggc3 = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/egg_c3.png')
28
+eggc4 = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/egg_c4.png')
29
+eggc5 = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/egg_c5.png')
30
+eggc7 = PygameImage.from_filepath(getcwd()+'/intelligine/display/pygame/image/egg_c7.png')
26 31
 
27 32
 directions_ant = DirectionnedImage(ant)
28 33
 directions_red_ant = DirectionnedImage(red_ant)
@@ -67,8 +72,28 @@ def green_ant_direction(bug, context):
67 72
         previous_direction = 14
68 73
     return directions_green_ant.get_for_direction(previous_direction)
69 74
 
75
+
76
+def for_position(position, objects, context):
77
+    # TODO: DEV TMP: refact, etc
78
+    eggs = []
79
+    for obj in objects:
80
+        if isinstance(obj, Egg):
81
+            eggs.append(obj)
82
+    if len(eggs) == 2:
83
+        return (eggc2, eggs)
84
+    if len(eggs) == 3:
85
+        return (eggc3, eggs)
86
+    if len(eggs) == 4:
87
+        return (eggc4, eggs)
88
+    if len(eggs) > 4:
89
+        return (eggc7, eggs)
90
+    return (None, [])
91
+
70 92
 visualisation = {
71 93
     'window': {},
94
+    'callbacks': {
95
+        'position': for_position
96
+    },
72 97
     'objects': {
73 98
         RedAnt: {
74 99
             'default': red_ant,