Contact me to be added to this repository. Push the creations you make for D&D, and they will be displayed in a nice website. See the website for how to contribute.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.0 KiB

  1. #pragma once
  2. #include <string>
  3. #include <iostream>
  4. #include <SDL2/SDL.h>
  5. #include <opencv2/opencv.hpp>
  6. #include "Texture.h"
  7. extern const int S_W; //screen dimensions
  8. extern const int S_H;
  9. extern int L_W; //level dimensions
  10. extern int L_H;
  11. extern const int TILE_SIZE;
  12. static const int NUM_TILE_IDs = 3;
  13. enum Tile {
  14. WALL,
  15. STONE,
  16. GRASS,
  17. WATER,
  18. PIT,
  19. UNUSED1,
  20. UNUSED2,
  21. UNUSED3
  22. };
  23. class Quad {
  24. private:
  25. SDL_Rect bound;
  26. Tile data;
  27. inline bool inbounds(int,int);
  28. void boundstring();
  29. Quad *tl,*tr,*bl,*br;
  30. public:
  31. Quad();
  32. void init(int,int);
  33. //~Quad(){free();}
  34. void free();
  35. void insert(int,int,Tile);
  36. Tile lookup(int,int); //defaults to wall
  37. void print(int);
  38. };
  39. class Map {
  40. private:
  41. int numTilesX,numTilesY;
  42. Quad* tiles;
  43. Texture textures[NUM_TILE_IDs];
  44. public:
  45. Map();
  46. ~Map();
  47. void loadFromFile(std::string fpath);
  48. void render(SDL_Rect camera);
  49. //DEBUG
  50. void print();
  51. int getW(){ return numTilesX; }
  52. int getH(){ return numTilesY; }
  53. };