summaryrefslogtreecommitdiffstats
path: root/src/view/MapView.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/view/MapView.cpp')
-rw-r--r--src/view/MapView.cpp10
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());
}