git repos / saland

commit a9747abf

sago007 · 2018-10-06 11:20
a9747abf7eba75d74da3cdc3b8035f0d4def95ca patch · browse files
parent e957cfbbf57120ac1f78f891d95e9324b16fc84b

Show only a few pixels outside the map on all sides. (Only two sides before)

Changed files

M src/saland/Game.cpp before
M src/saland/GameDraw.cpp before
diff --git a/src/saland/Game.cpp b/src/saland/Game.cpp index 9d2f836..632c8f4 100644 --- a/src/saland/Game.cpp +++ b/src/saland/Game.cpp
@@ -139,13 +139,22 @@ static std::string GetLayerInfoForTile(const World& w, int x, int y) {
}
void Game::Draw(SDL_Renderer* target) {
- data->topx = std::round(data->center_x - 1024.0 / 2.0);
- data->topy = std::round(data->center_y - 768.0 / 2.0);
- if (data->topx < -10) {
- data->topx = -10;
+ double screen_width = 1024.0;
+ double screen_height = 768.0;
+ int screen_boarder = 16;
+ data->topx = std::round(data->center_x - screen_width / 2.0);
+ data->topy = std::round(data->center_y - screen_height / 2.0);
+ if (data->topx < -screen_boarder) {
+ data->topx = -screen_boarder;
}
- if (data->topy < -10) {
- data->topy = -10;
+ if (data->topy < -screen_boarder) {
+ data->topy = -screen_boarder;
+ }
+ if (data->topx+screen_width > data->gameRegion.world.tm.width*32+screen_boarder) {
+ data->topx=data->gameRegion.world.tm.width*32+screen_boarder-screen_width;
+ }
+ if (data->topy+screen_height > data->gameRegion.world.tm.height*32+screen_boarder) {
+ data->topy = data->gameRegion.world.tm.height*32+screen_boarder-screen_height;
}
std::sort(data->gameRegion.placeables.begin(), data->gameRegion.placeables.end(),sort_placeable);
SDL_Texture* texture = globalData.spriteHolder->GetDataHolder().getTexturePtr("terrain");
diff --git a/src/saland/GameDraw.cpp b/src/saland/GameDraw.cpp index 8ebb39e..ead0cf0 100644 --- a/src/saland/GameDraw.cpp +++ b/src/saland/GameDraw.cpp
@@ -158,4 +158,4 @@ void DrawProjectile(SDL_Renderer* target, sago::SagoSpriteHolder* sHolder, const
entity->X - offsetX, entity->Y - offsetY, entity->Radius,
255, 255, 0, 255);
}
-}
\ No newline at end of file
+}