Selaa lähdekoodia

Using a Map was too heavy. Now the source has to keep track of the animations' index.

Eiyeron Fulmincendii 10 vuotta sitten
vanhempi
commit
17b7589fcf
2 muutettua tiedostoa jossa 7 lisäystä ja 3 poistoa
  1. 5 1
      src/render/Animator.cpp
  2. 2 2
      src/render/Animator.h

+ 5 - 1
src/render/Animator.cpp

@@ -1,4 +1,5 @@
 #include "Animator.h"
+#include <stdio.h>
 
 #define ANIMATOR WalrusRPG::Animator
 
@@ -48,10 +49,13 @@ ANIMATOR::Animator()
     elapsed_time = 0;
 }
 
-void ANIMATOR::add_animation(int index, Animation anim)
+unsigned ANIMATOR::add_animation(Animation anim)
 {
+    animations.push_back(anim);
+    unsigned index = animations.size()-1;
     animations[index] = anim;
     animations[index].duration = get_animation_duration(anim);
+    return animations.size();
 }
 
 unsigned ANIMATOR::get_animation_frame(unsigned id)

+ 2 - 2
src/render/Animator.h

@@ -21,7 +21,7 @@ namespace WalrusRPG
     class Animator
     {
       public:
-        tinystl::unordered_map<unsigned, Animation> animations;
+        tinystl::vector<Animation> animations;
 
 
       protected:
@@ -29,7 +29,7 @@ namespace WalrusRPG
 
       public:
         Animator();
-        void add_animation(int index, Animation anim);
+        unsigned add_animation(Animation anim);
         void update(unsigned dt);
         unsigned get_animation_frame(unsigned id);
     };