Browse Source

animation

Bastien Sevajol 7 years ago
parent
commit
03a21b1dbc

+ 7 - 8
sandbox/tile/gui/actor.py View File

1
 # coding: utf-8
1
 # coding: utf-8
2
 import pyglet
2
 import pyglet
3
 
3
 
4
-from sandbox.tile.gui.animation import ANIMATION_WALK
5
-from sandbox.tile.gui.animation import ANIMATION_CRAWL
6
 from synergine2.simulation import Subject
4
 from synergine2.simulation import Subject
7
 from synergine2_cocos2d.actor import Actor
5
 from synergine2_cocos2d.actor import Actor
6
+from synergine2_cocos2d.animation import ANIMATION_WALK
8
 
7
 
9
 
8
 
10
 class Man(Actor):
9
 class Man(Actor):
22
             'actors/man_w9.png',
21
             'actors/man_w9.png',
23
             'actors/man_w10.png',
22
             'actors/man_w10.png',
24
         ],
23
         ],
25
-        ANIMATION_CRAWL: [
26
-            'actors/man_c1.png',
27
-            'actors/man_c2.png',
28
-            'actors/man_c3.png',
29
-            'actors/man_c4.png',
30
-        ]
24
+        # ANIMATION_CRAWL: [
25
+        #     'actors/man_c1.png',
26
+        #     'actors/man_c2.png',
27
+        #     'actors/man_c3.png',
28
+        #     'actors/man_c4.png',
29
+        # ]
31
     }
30
     }
32
 
31
 
33
     def __init__(self, subject: Subject) -> None:
32
     def __init__(self, subject: Subject) -> None:

+ 0 - 5
sandbox/tile/gui/animation.py View File

1
-# coding: utf-8
2
-
3
-
4
-ANIMATION_WALK = 'WALK'
5
-ANIMATION_CRAWL = 'CRAWL'

+ 0 - 5
sandbox/tile/gui/base.py View File

1
 # coding: utf-8
1
 # coding: utf-8
2
-import random
3
-
4
-from sandbox.tile.gui.animation import ANIMATION_WALK
5
-from sandbox.tile.gui.animation import ANIMATION_CRAWL
6
-from synergine2_cocos2d.animation import Animate
7
 from synergine2_cocos2d.gui import TMXGui
2
 from synergine2_cocos2d.gui import TMXGui
8
 from synergine2_cocos2d.interaction import MoveActorInteraction
3
 from synergine2_cocos2d.interaction import MoveActorInteraction
9
 
4
 

+ 3 - 0
synergine2_cocos2d/animation.py View File

4
 import pyglet
4
 import pyglet
5
 import cocos
5
 import cocos
6
 
6
 
7
+ANIMATION_WALK = 'WALK'
8
+ANIMATION_CRAWL = 'CRAWL'
9
+
7
 
10
 
8
 class AnimatedInterface(object):
11
 class AnimatedInterface(object):
9
     def get_images_for_animation(self, animation_name: str) -> typing.List[pyglet.image.TextureRegion]:
12
     def get_images_for_animation(self, animation_name: str) -> typing.List[pyglet.image.TextureRegion]:

+ 4 - 0
synergine2_cocos2d/gui.py View File

17
 from synergine2.terminals import TerminalPackage
17
 from synergine2.terminals import TerminalPackage
18
 from synergine2_cocos2d.actions import MoveTo
18
 from synergine2_cocos2d.actions import MoveTo
19
 from synergine2_cocos2d.actor import Actor
19
 from synergine2_cocos2d.actor import Actor
20
+from synergine2_cocos2d.animation import Animate
21
+from synergine2_cocos2d.animation import ANIMATION_WALK
20
 from synergine2_cocos2d.exception import InteractionNotFound
22
 from synergine2_cocos2d.exception import InteractionNotFound
21
 from synergine2_cocos2d.exception import OuterWorldPosition
23
 from synergine2_cocos2d.exception import OuterWorldPosition
22
 from synergine2_cocos2d.gl import draw_rectangle
24
 from synergine2_cocos2d.gl import draw_rectangle
774
 
776
 
775
         move_action = MoveTo(new_window_position, 0.5)
777
         move_action = MoveTo(new_window_position, 0.5)
776
         actor.do(move_action)
778
         actor.do(move_action)
779
+        # TODO: values
780
+        actor.do(Animate(ANIMATION_WALK, 0.5, 1))

+ 2 - 1
synergine2_xyz/simulation.py View File

43
                 for neighbor in neighbors:
43
                 for neighbor in neighbors:
44
                     neighbor_x, neighbor_y = map(int, neighbor.split('.'))
44
                     neighbor_x, neighbor_y = map(int, neighbor.split('.'))
45
 
45
 
46
-                    if neighbor_x > 39 or neighbor_x < 0:
46
+                    if neighbor_x > 69 or neighbor_x < 0:
47
                         continue
47
                         continue
48
 
48
 
49
                     if neighbor_y > 69 or neighbor_y < 0:
49
                     if neighbor_y > 69 or neighbor_y < 0:
51
 
51
 
52
                     # TODO: Voir https://pypi.python.org/pypi/Dijkstar/2.2
52
                     # TODO: Voir https://pypi.python.org/pypi/Dijkstar/2.2
53
                     self.graph.add_edge(position, neighbor, 1)
53
                     self.graph.add_edge(position, neighbor, 1)
54
+        pass
54
 
55
 
55
     def is_possible_subject_position(self, subject: XYZSubject, position: tuple) -> bool:
56
     def is_possible_subject_position(self, subject: XYZSubject, position: tuple) -> bool:
56
         return self.is_possible_position(position)
57
         return self.is_possible_position(position)