WorldSim  inDev
2D tile-based sandbox RPG with procedurally generated fantasy world simulator 🌏
TileViewer.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef TILEVIEWER_HPP
3 #define TILEVIEWER_HPP
4 
5 /* TileViewer
6 
7 Each layer has its own tileset. Each tileset uses a single texture atlas.
8 
9 Documentation here. */
10 
11 //#include <Device/Display/OpenGLTools.hpp>
12 #include <Render/Renderer.hpp>
13 #include <Container/ArrayS3/ArrayS3.hpp>
14 #include <Graphics/Texture/Texture.hpp>
15 #include <Container/Vector/Vector.hpp>
16 
17 
19 {
20  private:
21  int tilesPerAtlas;
22 
23 
24  //ArrayS3 <int> textureAtlasPixels;
25 
26  public:
27 
28 
29  ArrayS3 <int> aBoard; /* z is layers. Each layer gets it's own texture atlas. Value is texture ID. */
30 
31 
32  int tileSizePixels; /* 64 is the default tile size, but can be modified to another pow2 size. */
33  int atlasSizePixels; /* Note that graphics cards have a maximum texture size, so the atlas needs to be small enough for these cards. */
34 
35 
36 
37 
39  {
40 
41  tileSizePixels=0;
42  atlasSizePixels=0;
43  tilesPerAtlas=0;
44  }
45  void init(const int _worldSizeXY, const int _nAtlas, const int _tileSizePixels, const int _atlasSizePixels)
46  {
47  aBoard.init(_worldSizeXY,_worldSizeXY,_nAtlas,0);
48  tileSizePixels=_tileSizePixels;
49  atlasSizePixels=_atlasSizePixels;
50  }
51 
52 
53  inline int & operator() (const unsigned int x, const unsigned int y, const unsigned int z)
54  {
55  return aBoard(x,y,z);
56  }
57 
58  // void setDimensions(const int _sizeXY, const int _nLayers)
59  // {
60  // aWorld.init(_sizeXY,_sizeXY,_nLayers,0);
61  // }
62 
63 
64  /* Render the board with the center tiles in the center of the screen, at the given screen coordinates. */
65  void render(const int _screenX1, const int _screenY1, const int _screenX2, const int _screenY2, const double _centerTileX, const double _centerTileY)
66  {
67  //OpenGLTools::placeTexture4(_screenX1,_screenY1,_screenX2,_screenY2,TEX_MENU_MAIN_MENU);
68 
69  }
70 
71  /* Loads the texture into the atlas and return the ID. */
72  short int pushTexture(Texture* t, short int layer)
73  {
74 
75 
76 
77  return 0; /* 0 is default value and is a blank texture. */
78  }
79 
80 
81  /* Load a pre-made atlas. */
82  void loadAtlas(Texture* t, short int layer)
83  {
84  }
85 
86  void putTile(const int _x, const int _y, const int _z, const int _tileID)
87  {
88  }
89 
90 
91 };
92 
93 #endif
void putTile(const int _x, const int _y, const int _z, const int _tileID)
Definition: TileViewer.hpp:86
short int pushTexture(Texture *t, short int layer)
Definition: TileViewer.hpp:72
Definition: TileViewer.hpp:18
int tileSizePixels
Definition: TileViewer.hpp:32
TileViewer()
Definition: TileViewer.hpp:38
int & operator()(const unsigned int x, const unsigned int y, const unsigned int z)
Definition: TileViewer.hpp:53
int atlasSizePixels
Definition: TileViewer.hpp:33
void loadAtlas(Texture *t, short int layer)
Definition: TileViewer.hpp:82
ArrayS3< int > aBoard
Definition: TileViewer.hpp:29
void render(const int _screenX1, const int _screenY1, const int _screenX2, const int _screenY2, const double _centerTileX, const double _centerTileY)
Definition: TileViewer.hpp:65
void init(const int _worldSizeXY, const int _nAtlas, const int _tileSizePixels, const int _atlasSizePixels)
Definition: TileViewer.hpp:45