Kaynağa Gözat

Tileset: remove unnecessary spritesheet dimensions

Streetwalrus Einstein 10 yıl önce
ebeveyn
işleme
a3b40e0089
3 değiştirilmiş dosya ile 5 ekleme ve 7 silme
  1. 1 3
      include/Tileset.h
  2. 1 1
      src/Map.cpp
  3. 3 3
      src/Tileset.cpp

+ 1 - 3
include/Tileset.h

@@ -15,14 +15,12 @@ namespace WalrusRPG
     {
       protected:
         const unsigned short *sheet;
-        unsigned sheet_width;
-        unsigned sheet_height;
         unsigned tile_width;
         unsigned tile_height;
         tinystl::unordered_map<unsigned, tinystl::vector<Frame>> animations;
 
       public:
-        Tileset(unsigned short *sheet, unsigned sheet_width, unsigned sheet_height, unsigned tile_width, unsigned tile_heihgt);
+        Tileset(unsigned short *sheet, unsigned tile_width, unsigned tile_heihgt);
         void add_animation(int index, tinystl::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);

+ 1 - 1
src/Map.cpp

@@ -7,7 +7,7 @@
 #define MAP WalrusRPG::Map
 
 MAP::Map(int width, int height, unsigned *layer0, unsigned *layer1)
-    : tset(overworld, 336, 144, 16, 16), time_render(0)
+    : tset(overworld, 16, 16), time_render(0)
 {
     this->width = width;
     this->height = height;

+ 3 - 3
src/Tileset.cpp

@@ -21,8 +21,8 @@ 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)
+TILESET::Tileset(unsigned short *sheet, unsigned tile_width, unsigned tile_height)
+    : sheet(sheet), tile_width(tile_width), tile_height(tile_height)
 {
 }
 
@@ -33,7 +33,7 @@ void TILESET::add_animation(int index, tinystl::vector<WalrusRPG::Frame> anim)
 
 void TILESET::render_tile(unsigned int index, unsigned x, unsigned y) const
 {
-    unsigned num_tiles_x = sheet_width / tile_width;
+    unsigned num_tiles_x = sheet[0] / tile_width;
     //unsigned num_tiles_y = sheet_height / tile_height;
     GRAPHICS::draw_sprite_sheet(sheet, x, y, UTILS::Rect(tile_width * (index % num_tiles_x), tile_height * (index / num_tiles_x), tile_width, tile_height));
 }