소스 검색

Added a frame fallback to Animator and added tile animation back to Map

Florian DORMONT 10 년 전
부모
커밋
761c96a0db
2개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 2 0
      src/Animator.cpp
  2. 3 3
      src/Map.cpp

+ 2 - 0
src/Animator.cpp

@@ -31,6 +31,8 @@ void ANIMATOR::add_animation(int index, Animation anim)
 
 unsigned ANIMATOR::get_animation_frame(unsigned id)
 {
+    if (animations[id].stripe.empty())
+        return id;
     return find_frame(animations[id].stripe, elapsed_time);
 }
 

+ 3 - 3
src/Map.cpp

@@ -27,7 +27,7 @@ MAP::~Map()
 
 void MAP::update(unsigned dt)
 {
-    UNUSED(dt);
+    anim.update(dt);
     // TODO update map's data according to elasped time
 }
 
@@ -82,13 +82,13 @@ void MAP::render(WalrusRPG::Camera &camera, unsigned dt)
             unsigned index = (start_x + i) + (start_y + j) * this->width;
             unsigned tile_over = this->layer0[index];
             if (tile_over != 0)
-                renderer->render(this->layer0[index], RECT(offset_x + i * t_width, offset_y + j * t_height));
+                renderer->render(anim.get_animation_frame(this->layer0[index]), RECT(offset_x + i * t_width, offset_y + j * t_height));
             // layer1 : Over-layer
             if (this->layer1 == NULL)
                 continue;
             tile_over = this->layer1[index];
             if (tile_over != 0)
-                renderer->render(tile_over, RECT(offset_x + i * t_width, offset_y + j * t_height));
+                renderer->render(anim.get_animation_frame(tile_over), RECT(offset_x + i * t_width, offset_y + j * t_height));
         }
     }
 }