diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-09-23 02:11:11 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-09-23 02:11:11 +0200 |
commit | d41e2dae45e08059e23041f0146b91add0c2cace (patch) | |
tree | 780888633b8a051be868df29fd29c369605ee5e4 /src/view/MapView.cpp | |
parent | 0c3dbabb920f2957ca8c36194ebdeec9f80fefe7 (diff) | |
download | rpgedit-d41e2dae45e08059e23041f0146b91add0c2cace.tar rpgedit-d41e2dae45e08059e23041f0146b91add0c2cace.zip |
Add transitions for entity movement
Diffstat (limited to 'src/view/MapView.cpp')
-rw-r--r-- | src/view/MapView.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/view/MapView.cpp b/src/view/MapView.cpp index 33414ce..8a0bdbf 100644 --- a/src/view/MapView.cpp +++ b/src/view/MapView.cpp @@ -93,7 +93,7 @@ void MapView::render(float centerX, float centerY) { int minX = std::floor(centerX - tilesW/2 - 0.5f), maxX = std::ceil(centerX + tilesW/2 + 0.5f); int minY = std::floor(centerY - tilesH/2 - 0.5f), maxY = std::ceil(centerY + tilesH/2 + 0.5f); - int baseX = viewport.first/2 - (centerX + 0.5f)*tilePixels, baseY = viewport.second/2 - (centerY + 0.5f)*tilePixels; + int baseX = viewport.first/2 - int(centerX * tilePixels) - tilePixels/2, baseY = viewport.second/2 - int(centerY * tilePixels) - tilePixels/2; for (int x = minX; x <= maxX; x++) { for (int y = minY; y <= maxY; y++) { @@ -120,7 +120,7 @@ void MapView::render(float centerX, float centerY) { } for (const std::shared_ptr<Model::Entity> &entity : map->getEntities()) { - std::pair<float, float> pos = entity->getPosition(); + Model::Position pos = entity->getPosition(); Model::Direction dir = entity->getDirection(); SDL_Rect src = { @@ -131,14 +131,14 @@ void MapView::render(float centerX, float centerY) { }; SDL_Rect dst = { - .x = baseX + int(pos.first*tilePixels), - .y = baseY + int(pos.second*tilePixels), + .x = baseX + int(pos.x * tilePixels), + .y = baseY + int(pos.y * tilePixels), .w = tilePixels, .h = tilePixels, }; SDL_RenderCopy(window->getRenderer(), entityTextures[entity->getName()], &src, &dst); - } + } SDL_RenderPresent(window->getRenderer()); } |