commit cc34d180
Add protected fields around the region openings
Changed files
| M | src/saland/Game.cpp before |
diff --git a/src/saland/Game.cpp b/src/saland/Game.cpp
index da0cfdd..e0ccf1d 100644
--- a/src/saland/Game.cpp
+++ b/src/saland/Game.cpp
@@ -241,6 +241,22 @@ void Game::Draw(SDL_Renderer* target) {
//#endif
}
+static bool reservedField(const sago::tiled::TileMap& tm, int x, int y) {
+ if (x < 2 && y > tm.layers.at(0).height/2-6 && y < tm.layers.at(0).height/2+5) {
+ return true;
+ }
+ if (x > tm.layers.at(0).width-3 && y > tm.layers.at(0).height/2-6 && y < tm.layers.at(0).height/2+5) {
+ return true;
+ }
+ if (y < 2 && x > tm.layers.at(0).width/2-6 && x < tm.layers.at(0).width/2+5) {
+ return true;
+ }
+ if (y > tm.layers.at(0).height-3 && x > tm.layers.at(0).width/2-6 && x < tm.layers.at(0).width/2+5) {
+ return true;
+ }
+ return false;
+}
+
void Game::ProcessInput(const SDL_Event& event, bool& processed) {
if (data->console) {
data->console->ProcessInput(event, processed);
@@ -252,7 +268,8 @@ void Game::ProcessInput(const SDL_Event& event, bool& processed) {
int tile_x = data->world_mouse_x/32;
int tile_y = data->world_mouse_y/32;
if (event.key.keysym.sym == globalData.playerControls.block_create
- && sago::tiled::tileInBound(data->gameRegion.world.tm, tile_x, tile_y)) {
+ && sago::tiled::tileInBound(data->gameRegion.world.tm, tile_x, tile_y)
+ && !reservedField(data->gameRegion.world.tm, tile_x, tile_y)) {
int layer_number = 2; // Do not hardcode
uint32_t tile = 607;
sago::tiled::setTileOnLayerNumber(data->gameRegion.world.tm, layer_number, tile_x, tile_y, tile);