Nimbin[12]?SDL & Graphics / mapcreator / commits / 2949309

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 bugs load inventory discoverstuff AND close buildinv

Christian Immanuel · 2025-12-18 15:29 · 2949309d2977f18e9fdf9ba40ab87f95db7de83d

 src/character/character.cpp | 8 ++++++++
 src/game/state_playing.cpp  | 1 -
 src/map/map.cpp             | 8 ++++----
 src/objects/object.cpp      | 6 ++++--
 4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/character/character.cpp b/src/character/character.cpp
index 7ec1c02..9537a0e 100644
--- a/src/character/character.cpp
+++ b/src/character/character.cpp
@@ -1207,6 +1207,8 @@ Character::handle_Input(Input& input, SDL_Rect win_size) {
     } else
     // WORKBENCH
     if (active_menu == CharacterMenuType::WORKBENCH) {
+        if (input.pressed_c_released )
+            active_menu = CharacterMenuType::NONE;
         Building::draw_menu_curser_grid = Research::cursor_ResearchGridTileIndex(input.mouse_state_raw, win_size);
         // CRAFT
         if (input.click_left_released) {
@@ -1234,6 +1236,8 @@ Character::handle_Input(Input& input, SDL_Rect win_size) {
     } else
     // RESEARCH
     if (active_menu == CharacterMenuType::RESEARCH) {
+        if (input.pressed_c_released )
+            active_menu = CharacterMenuType::NONE;
         Building::draw_menu_curser_grid = Research::cursor_ResearchGridTileIndex(input.mouse_state_raw, win_size);
         if (input.click_left_released) {
             Research::research_Stop();
@@ -1815,5 +1819,9 @@ Character::Load(const std::string &path) {
 
     selected_item = inventory->get_SelectedHotbarItem();
 
+    for (auto rs : inventory->resources)
+        set_ResourceDiscovery(rs.first);
+    set_BuildingDiscovery();
+
     return file.good();
 }
diff --git a/src/game/state_playing.cpp b/src/game/state_playing.cpp
index 37b71e5..02c8c57 100644
--- a/src/game/state_playing.cpp
+++ b/src/game/state_playing.cpp
@@ -25,7 +25,6 @@ bool StatePlaying::Init(Game* game) {
 
     player = std::make_unique<Character>();
     player->Init(game->renderer);
-    std::cout << "JOOOOOO\n";
     player->researched_items[static_cast<size_t>(ItemType::BUILDING_TOOL)] = true;
 
     // INIT Weapons
diff --git a/src/map/map.cpp b/src/map/map.cpp
index 287b9cb..08e8881 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -910,14 +910,14 @@ namespace Map {
                                             player.collider.h})) {
                         player_behind = true;
                         if (!character_drawn) {
-                            std::cout << "DRAW BEHIND\n";
+                            //std::cout << "DRAW BEHIND\n";
                             player.Draw(renderer);
                             character_drawn = true;
                         }
                     }
-                    std::cout <<  player_behind << std::endl;
-                    std::cout << "CHA: " << character_collider_x << " " << character_collider_y << " " << player.collider.w << " " << player.collider.h << std::endl;
-                    std::cout << "OJJ: " << m_xf << " " << m_yf << " " << m_point.x << " " << m_point.y << std::endl;
+                    //std::cout <<  player_behind << std::endl;
+                    //std::cout << "CHA: " << character_collider_x << " " << character_collider_y << " " << player.collider.w << " " << player.collider.h << std::endl;
+                    //std::cout << "OJJ: " << m_xf << " " << m_yf << " " << m_point.x << " " << m_point.y << std::endl;
 
 
 
diff --git a/src/objects/object.cpp b/src/objects/object.cpp
index 7b24036..8ae6e2f 100644
--- a/src/objects/object.cpp
+++ b/src/objects/object.cpp
@@ -76,9 +76,11 @@ Object::is_InFrontOf(SDL_FPoint world_position, SDL_FRect rect) {
     const int rect_w = (rect.w + Tile::tile_collider_size - 1) / Tile::tile_collider_size;
     const int rect_h = (rect.h + Tile::tile_collider_size - 1) / Tile::tile_collider_size;
 
+    /*
     std::cout << "WP: " << world_position.x << " " << world_position.y << std::endl;
     std::cout << "OB " << obj_x << " " << obj_y << " " << obj_w << " " << obj_h << std::endl;
     std::cout << "RE " << rect_x << " " << rect_y << " " << rect_w << std::endl;
+    */
     const int row_width = obj_w;
 
     // object is left or right of rect
@@ -130,7 +132,7 @@ Object::is_InFrontOf(SDL_FPoint world_position, SDL_FRect rect) {
         }
     }
     if ( !has_collision ) {
-        std::cout << "NO COLL\n";
+        //std::cout << "NO COLL\n";
         SDL_FRect temp_rect = { world_position.x, world_position.y, static_cast<float>(dimension.x*Tile::tile_size), static_cast<float>(dimension.y*Tile::tile_size) };
         //std::cout << "COLL " << SDL_HasRectIntersectionFloat(&temp_rect, &rect) <<  " " << world_position.x << " " << world_position.y << " " << rect.x << " " << rect.y <<std::endl;
         //std::cout << "WIDH " << dimension.x *Tile::tile_size<< " " << dimension.y *Tile::tile_size<< " RE " << rect.w << " " << rect.h << std::endl;
@@ -138,7 +140,7 @@ Object::is_InFrontOf(SDL_FPoint world_position, SDL_FRect rect) {
         return !SDL_HasRectIntersectionFloat(&temp_rect, &rect);
     }
 
-    std::cout << "COL " << collission_below << " " << anywhere_below << " " << anywhere_above << std::endl;
+    //std::cout << "COL " << collission_below << " " << anywhere_below << " " << anywhere_above << std::endl;
     if ((collission_below || anywhere_below) && !anywhere_above)
         return true;
     if (!anywhere_above && !collission_below)