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

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

Maybe sound stuff?

Christian Immanuel · 2026-02-13 07:08 · 12bf186201c548afc3696236db51685a48863f18

 src/bird/bird.cpp           | 56 ++++++++++++++++++++++++++-------------------
 src/bird/bird.hpp           |  1 +
 src/character/character.cpp |  7 +++---
 src/map/map.cpp             | 25 +++++++++++---------
 4 files changed, 51 insertions(+), 38 deletions(-)

diff --git a/src/bird/bird.cpp b/src/bird/bird.cpp
index 207d020..c07b793 100644
--- a/src/bird/bird.cpp
+++ b/src/bird/bird.cpp
@@ -38,6 +38,18 @@ bool Bird::Init(SDL_Renderer* renderer) {
     return texture != nullptr;
 }
 
+void Bird::init_Landing() {
+    //std::cout << "BIRD INIT LANDING!\n";
+    is_landing = true;
+    landing_progress = 0.0f;
+    landing_start_x = pos_x;
+    landing_start_y = pos_y;
+    landing_direction = facing_left ? -1.0f : 1.0f;  // Store current flight direction
+    landing_prev_x_offset = 0.0f;
+    landing_prev_y_offset = 0.0f;
+}
+
+
 void Bird::Update(double delta_s, const SDL_FPoint& player_pos) {
     // std::cout << "ALT: " << altitude << std::endl;
     // std::cout << (int)state << " ISTART " << is_starting_to_fly << " ILAND " << is_landing << " XY: "  << pos_x << " " << pos_y << " DC " << decision_timer << " STT: " << state_timer << std::endl;
@@ -76,30 +88,6 @@ void Bird::Update(double delta_s, const SDL_FPoint& player_pos) {
     float dy = target_pos.y - pos_y;
     float dist = sqrtf(dx * dx + dy * dy);
 
-    // Handle flying movement
-    if (state == BirdState::FLYING && !is_landing && !is_starting_to_fly) {
-        if (dist > 2.0f) {
-            pos_x += (dx / dist) * speed * delta_s;
-            pos_y += (dy / dist) * speed * delta_s;
-            
-            // Update facing direction
-            if (fabsf(dx) > 0.01f) {
-                facing_left = (dx < 0.0f);
-            }
-        } else {
-            // Reached target - begin landing
-            //std::cout << "BIRD INIT LANDING!\n";
-            is_landing = true;
-            landing_progress = 0.0f;
-            landing_start_x = pos_x;
-            landing_start_y = pos_y;
-            landing_direction = facing_left ? -1.0f : 1.0f;  // Store current flight direction
-            landing_prev_x_offset = 0.0f;
-            landing_prev_y_offset = 0.0f;
-        }
-    }
-    // Handle walking movement
-    else
     if (state == BirdState::WALKING) {
         if (dist > 0.4) {
             float move = speed * delta_s;
@@ -136,6 +124,23 @@ void Bird::Update(double delta_s, const SDL_FPoint& player_pos) {
         }
     }
     else
+    // Handle flying movement
+    if (state == BirdState::FLYING && !is_landing && !is_starting_to_fly) {
+        if (dist > 2.0f) {
+            pos_x += (dx / dist) * speed * delta_s;
+            pos_y += (dy / dist) * speed * delta_s;
+            
+            // Update facing direction
+            if (fabsf(dx) > 0.01f) {
+                facing_left = (dx < 0.0f);
+            }
+        } else {
+            // Reached target - begin landing
+            init_Landing();
+        }
+    }
+    // Handle walking movement
+    else
     if (is_starting_to_fly) {
 
         float overall_dx = target_pos.x - pos_x;
@@ -281,6 +286,7 @@ void Bird::set_State(BirdState new_state, double dec_timer) {
     reverse_animation = false;
     frame_step = 1;
 
+
     switch (state) {
         case BirdState::IDLE:
             current_frame = 0;
@@ -298,6 +304,8 @@ void Bird::set_State(BirdState new_state, double dec_timer) {
             break;
 
         case BirdState::EATING:
+            if (!Animation::audio->is_Playing("bird.sing"))
+                Animation::audio->Play("bird.sing");
             current_frame = 0;
             set_Animation(3, 3, 0.15);
             break;
diff --git a/src/bird/bird.hpp b/src/bird/bird.hpp
index e5456c6..fbeb9b7 100644
--- a/src/bird/bird.hpp
+++ b/src/bird/bird.hpp
@@ -42,6 +42,7 @@ public:
 
     void Render(SDL_Renderer* renderer);
 
+    void init_Landing();
     void set_State(BirdState new_state, double decision_timer);
     void set_Position(SDL_FPoint);
 
diff --git a/src/character/character.cpp b/src/character/character.cpp
index c3e4287..ac2fcf7 100644
--- a/src/character/character.cpp
+++ b/src/character/character.cpp
@@ -74,6 +74,7 @@ Character::Init(SDL_Renderer* renderer) {
     selected_item = inventory->hotbar_hands;
 
     bird = new Bird(x, y);
+    bird->Init(renderer);
     bird->set_State(BirdState::WALKING, 1.4);
 
 
@@ -130,9 +131,9 @@ Character::Init(SDL_Renderer* renderer) {
     animation.block[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Side.png", tile_size, tile_size, "None", false, false);
     animation.block[WalkDirection::UP]   = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Pierce_Blocking/Up.png",   tile_size, tile_size, "None", false, false);
 
-    animation.drinking_river[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Down-Sheet.png", tile_size, tile_size, "None", false, false);
-    animation.drinking_river[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Side-Sheet.png", tile_size, tile_size, "None", false, false);
-    animation.drinking_river[WalkDirection::UP]   = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Up-Sheet.png",   tile_size, tile_size, "None", false, false);
+    animation.drinking_river[WalkDirection::DOWN] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Down-Sheet.png", tile_size, tile_size, "character.drink", false, false);
+    animation.drinking_river[WalkDirection::SIDE] = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Side-Sheet.png", tile_size, tile_size, "character.drink", false, false);
+    animation.drinking_river[WalkDirection::UP]   = Animation::load(renderer, "Pixel_Crawler/Entities/Characters/Body_A/Animations/Collect_Base/Collect_Up-Sheet.png",   tile_size, tile_size, "character.drink", false, false);
 
     Animation::audio->RegisterSound("character.dead", "music/character.dead.wav");
 
diff --git a/src/map/map.cpp b/src/map/map.cpp
index 21c9a48..04bf62b 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -923,6 +923,17 @@ namespace Map {
                         character_drawn = true;
                     }
                 }
+                for (Bird* bird : Bird::birds) {
+                    if (bird->drawn)
+                        continue;
+                    if ( static_cast<int>(bird->pos_x/Tile::tile_size) != x_i ||
+                            static_cast<int>((bird->pos_y-bird->altitude)/Tile::tile_size) != y_i)
+                        continue;
+
+                    bird->Render(renderer);
+                    std::cout << "I AM NOT GETTING CALLED BIRD AMP " << bird->pos_y << " " << bird->altitude << std::endl;
+                    bird->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;
@@ -956,20 +967,12 @@ namespace Map {
                 }
                 j++;
             }
-            for (Bird* bird : Bird::birds) {
-                if (bird->drawn)
-                    continue;
-                if ( static_cast<int>(bird->pos_x/Tile::tile_size) != x_i ||
-                        static_cast<int>((bird->pos_y-bird->altitude)/Tile::tile_size) != y_i)
-                    continue;
-
-                bird->Render(renderer);
-                bird->drawn = true;
-            }
         }
         for (Bird* bird : Bird::birds)
-            if (!bird->drawn)
+            if (!bird->drawn) {
+                    std::cout << "BIRD AMP " << bird->pos_y << " " << bird->altitude << std::endl;
                 bird->Render(renderer);
+            }
     }