summaryrefslogtreecommitdiffstats
path: root/src/view
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-09-23 15:46:21 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-09-23 15:46:21 +0200
commited55551853448ef2e245c6b71f370dfe70b12094 (patch)
treedf5c1206e2af07b3476b52081a55538428ca2823 /src/view
parentd41e2dae45e08059e23041f0146b91add0c2cace (diff)
downloadrpgedit-ed55551853448ef2e245c6b71f370dfe70b12094.tar
rpgedit-ed55551853448ef2e245c6b71f370dfe70b12094.zip
Some work to allow more dynamic tile sizes
Diffstat (limited to 'src/view')
-rw-r--r--src/view/MapView.cpp18
-rw-r--r--src/view/MapView.hpp4
2 files changed, 13 insertions, 9 deletions
diff --git a/src/view/MapView.cpp b/src/view/MapView.cpp
index 8a0bdbf..3eb3248 100644
--- a/src/view/MapView.cpp
+++ b/src/view/MapView.cpp
@@ -50,12 +50,12 @@ MapView::MapView(const std::shared_ptr<Window> &window0,
amask = 0xff000000;
#endif
- SDL_Surface *surface = SDL_CreateRGBSurface(0, 16*tiles.size(), 16, 32, rmask, gmask, bmask, amask);
+ SDL_Surface *surface = SDL_CreateRGBSurface(0, getTileSize()*tiles.size(), getTileSize(), 32, rmask, gmask, bmask, amask);
SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);
for (size_t i = 0; i < tiles.size(); i++) {
SDL_Rect rect = {
- .x = int(16*i),
+ .x = int(getTileSize()*i),
.y = 0,
.w = 0,
.h = 0,
@@ -85,7 +85,7 @@ void MapView::render(float centerX, float centerY) {
std::pair<int, int> viewport = window->getViewport();
float pixels = std::max(viewport.first/16.0f, viewport.second/12.0f);
- int tilePixels = 16 * std::ceil(pixels / 16);
+ int tilePixels = getTileSize() * std::ceil(pixels / getTileSize());
float tilesW = viewport.first / tilePixels;
float tilesH = viewport.second / tilePixels;
@@ -102,10 +102,10 @@ void MapView::render(float centerX, float centerY) {
continue;
SDL_Rect src = {
- .x = int(16*(tile-1)),
+ .x = int(getTileSize()*(tile-1)),
.y = 0,
- .w = 16,
- .h = 16,
+ .w = getTileSize(),
+ .h = getTileSize(),
};
SDL_Rect dst = {
@@ -124,10 +124,10 @@ void MapView::render(float centerX, float centerY) {
Model::Direction dir = entity->getDirection();
SDL_Rect src = {
- .x = 16*dir,
+ .x = getTileSize()*dir,
.y = 0,
- .w = 16,
- .h = 16,
+ .w = getTileSize(),
+ .h = getTileSize(),
};
SDL_Rect dst = {
diff --git a/src/view/MapView.hpp b/src/view/MapView.hpp
index e5f0e50..373c714 100644
--- a/src/view/MapView.hpp
+++ b/src/view/MapView.hpp
@@ -44,6 +44,10 @@ private:
SDL_Texture *tileTexture;
std::map<std::string, SDL_Texture *> entityTextures;
+ int getTileSize() {
+ return 16;
+ }
+
public:
MapView(const std::shared_ptr<Window> &window0,
const std::shared_ptr<const Model::Map> &map0,