瀏覽代碼

Map: use 16 bit unsigned integers for map storage

Streetwalrus Einstein 10 年之前
父節點
當前提交
6754cc5db4
共有 3 個文件被更改,包括 7 次插入6 次删除
  1. 4 3
      include/Map.h
  2. 1 1
      src/Map.cpp
  3. 2 2
      src/main.cpp

+ 4 - 3
include/Map.h

@@ -1,6 +1,7 @@
 #ifndef INCLUDE_MAP_H
 #define INCLUDE_MAP_H
 
+#include <stdint.h>
 #include "Camera.h"
 #include "Entity.h"
 #include "TileRenderer.h"
@@ -18,12 +19,12 @@ namespace WalrusRPG
         // <Tileset> tileset;
         unsigned int width;
         unsigned int height;
-        unsigned *layer0;
-        unsigned *layer1;
+        uint16_t *layer0;
+        uint16_t *layer1;
         TileRenderer *renderer;
         // TODO?: add a boolean/getter to know if a second layer exist?
       public:
-        Map(int width, int height, unsigned *layer0, unsigned *layer1);
+        Map(int width, int height, uint16_t *layer0, uint16_t *layer1);
         ~Map();
         void render(Camera &camera, unsigned dt);
         void update(unsigned dt);

+ 1 - 1
src/Map.cpp

@@ -10,7 +10,7 @@
 #define RECT WalrusRPG::Utils::Rect
 #define TILERENDERER WalrusRPG::TileRenderer
 
-MAP::Map(int width, int height, unsigned *layer0, unsigned *layer1) : anim()
+MAP::Map(int width, int height, uint16_t *layer0, uint16_t *layer1) : anim()
 {
     this->renderer = new TileRenderer(overworld, 16, 16);
     this->width = width;

+ 2 - 2
src/main.cpp

@@ -83,7 +83,7 @@ int main(int argc, char *argv[])
     WalrusRPG::Timers::init(0);
     WalrusRPG::Interrupts::init();
 
-    unsigned dungeonTest[] = {
+    uint16_t dungeonTest[] = {
         21, 21,  1,   1,   1,   1,   21,  22,  21,  22, 21,  22,  21,  21,  1,   22,  21,
         1,  22,  22,  22,  1,   21,  2,   3,   3,   3,  3,   3,   4,   21,  1,   22,  21,
         22, 22,  21,  21,  21,  1,   22,  22,  22,  23, 108, 109, 109, 109, 24,  87,  4,
@@ -109,7 +109,7 @@ int main(int argc, char *argv[])
         21, 1,   1,   22,  21,  1,   1,   21,  1,   1,  21,  21,  21,  1,   22,  22,  1,
         21, 22,  21,  22,  1,   22,  21,  21,  21,
     };
-    unsigned dungeonTest2[] = {
+    uint16_t dungeonTest2[] = {
         0, 0, 0, 0, 0,   0,   0,   0,   0,   0,  0,  0,  0,  0,  0,   0,   0,   0,   0, 0,
         0, 0, 0, 0, 0,   0,   0,   0,   0,   0,  0,  0,  0,  0,  0,   0,   0,   0,   0, 0,
         0, 0, 0, 0, 0,   52,  53,  54,  55,  0,  0,  0,  0,  0,  0,   0,   0,   0,   0, 0,