Nimbin[12]?SDL & Graphics / mapcreator / commits / 2d5de22

mapcreator git · master

SDL3 2.5D game and engine using assets, with map editor

sdl3 c++ game engine map-editor cmake · first commit 2025-10-31 · last commit 2026-09-07 (1 month ago) · synced 3 days ago · upstream: git.ide3.de/hsnr/sdl-spieleentwicklung/map_creator

C++ 99.3%
git clone https://git.christianimmanuel.de/sdl-graphics/mapcreator.gitwget https://git.christianimmanuel.de/sdl-graphics/mapcreator/archive/mapcreator.tar.gz

Fix add obj wrong id

Christian Immanuel · 2026-02-20 12:48 · 2d5de22a14f31d71e01ac41300eda4c1630e37c6

 src/game/state_modify.cpp |  4 ++++
 src/map/path_finding.hpp  | 10 ++++++++++
 src/map/tile.cpp          |  3 ++-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/game/state_modify.cpp b/src/game/state_modify.cpp
index d940527..cd15e73 100644
--- a/src/game/state_modify.cpp
+++ b/src/game/state_modify.cpp
@@ -108,6 +108,10 @@ void StateModify::handle_Events(SDL_Event& event, Game* game) {
                         Tile::selection_tile_dimension.x = Tile::selection_tile_dimension.x > 1
                             ? Tile::selection_tile_dimension.x -1 : 1;
                     break;
+                case SDL_SCANCODE_0:
+                    if (game->input.pressed_ctrl)
+                        Tile::selection_tile_dimension = {1,1};
+                    break;
                 case SDL_SCANCODE_S:
                     if (game->input.pressed_ctrl) {
                         Map::save_MapTiles(Map::tile_map, Map::save_path);
diff --git a/src/map/path_finding.hpp b/src/map/path_finding.hpp
index f13cbd7..febbafb 100644
--- a/src/map/path_finding.hpp
+++ b/src/map/path_finding.hpp
@@ -137,8 +137,11 @@ std::vector<SDL_FPoint> find_Path(const SDL_FRect& object_rect, const SDL_FPoint
     float max_dist_sq = static_cast<float>(max_dist) * max_dist;
 
 
+    int iii = 0;
+
     // --- A* Main Loop ---
     while (!open_set.empty()) {
+        iii++;
         Node* current_node = open_set.top();
         open_set.pop();
 
@@ -161,12 +164,17 @@ std::vector<SDL_FPoint> find_Path(const SDL_FRect& object_rect, const SDL_FPoint
 
             // Reconstruct path from the current valid node back to start
             while (runner) {
+                iii++;
                 // Convert tile coordinates back to the center of the tile in pixel coordinates
                 SDL_FPoint point;
                 point.x = (runner->x + 0.5f) * collider_size;
                 point.y = (runner->y + 0.5f) * collider_size;
                 path.push_back(point);
                 runner = runner->parent;
+                if (iii > 3500) {
+                    path.clear();
+                    break;
+                }
             }
 
             // Path is currently: [Goal Tile Center, ..., Start Tile Center]
@@ -194,6 +202,7 @@ std::vector<SDL_FPoint> find_Path(const SDL_FRect& object_rect, const SDL_FPoint
         // 2. Explore Neighbors (8 directions for diagonal movement)
         for (int dx = -1; dx <= 1; ++dx) {
             for (int dy = -1; dy <= 1; ++dy) {
+        iii++;
                 if (dx == 0 && dy == 0) continue;
 
                 int neighbor_x = current_node->x + dx;
@@ -232,6 +241,7 @@ std::vector<SDL_FPoint> find_Path(const SDL_FRect& object_rect, const SDL_FPoint
         }
     }
 
+
     // Path not found
     return {};
 }
diff --git a/src/map/tile.cpp b/src/map/tile.cpp
index 85a694c..9e89b70 100644
--- a/src/map/tile.cpp
+++ b/src/map/tile.cpp
@@ -909,6 +909,7 @@ namespace Tile {
                 }
             }
         }
+        std::cout<< "NEW OBJ ID " << object_id << " " << selected_object_id << std::endl;
         if (removed_object) return;
 
         // add objecz to map
@@ -920,7 +921,7 @@ namespace Tile {
         objects[object_id].collectable = false;
         //objects[object_id].building_status = TileBuildingStatus::NONE;
         Tile_s tileset_info = {Tile::active_tileset_id,
-                        selected_object_id,
+                        object_id,
                         Tile::tilesets[Tile::active_tileset_type][Tile::active_tileset_id].category ,
                         {static_cast<int>(objects[object_id].position.x),
                          static_cast<int>(objects[object_id].position.y)}};