Bläddra i källkod

Added animation adding routine.

Florian DORMONT 10 år sedan
förälder
incheckning
4d3ea6150c
3 ändrade filer med 7 tillägg och 2 borttagningar
  1. 1 0
      include/Tileset.h
  2. 1 0
      src/Map.cpp
  3. 5 2
      src/Tileset.cpp

+ 1 - 0
include/Tileset.h

@@ -23,6 +23,7 @@ namespace WalrusRPG
 
       public:
         Tileset(unsigned short *sheet, unsigned sheet_width, unsigned sheet_height, unsigned tile_width, unsigned tile_heihgt);
+        void add_animation(int index, std::vector<WalrusRPG::Frame> anim);
         void render_tile(unsigned int index, unsigned x, unsigned y) const;
         void render_tile(unsigned int index, unsigned x, unsigned y, unsigned time) const;
     };

+ 1 - 0
src/Map.cpp

@@ -13,6 +13,7 @@ MAP::Map(int width, int height, unsigned *layer0, unsigned *layer1)
     this->height = height;
     this->layer0 = layer0;
     this->layer1 = layer1;
+    tset.add_animation(2, {{2, 20}, {3, 10}});
 }
 
 MAP::~Map()

+ 5 - 2
src/Tileset.cpp

@@ -21,8 +21,11 @@ namespace
 TILESET::Tileset(unsigned short *sheet, unsigned sheet_width, unsigned sheet_height, unsigned tile_width, unsigned tile_height)
     : sheet(sheet), sheet_width(sheet_width), sheet_height(sheet_height), tile_width(tile_width), tile_height(tile_height)
 {
-    animations[2].push_back({2, 10}); // Testing
-    animations[2].push_back({3, 10}); // Testing
+}
+
+void TILESET::add_animation(int index, std::vector<WalrusRPG::Frame> anim)
+{
+    animations[index] = anim;
 }
 
 void TILESET::render_tile(unsigned int index, unsigned x, unsigned y) const