Nimbin[12]?SDL & Graphics / mapcreator / commits / 9d5d08f

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

Add intro music?

Christian Immanuel · 2026-02-10 13:58 · 9d5d08f4fb3dda93dd3360ae07a1c7706ab93c65

 music/intro.wav                   | Bin 0 -> 2519630 bytes
 src/map/map.cpp                   |  21 +++++++++------------
 src/start_screen/start_screen.cpp |  38 +++++++++++++++++++++-----------------
 3 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/music/intro.wav b/music/intro.wav
new file mode 100644
index 0000000..8981b73
Binary files /dev/null and b/music/intro.wav differ
diff --git a/src/map/map.cpp b/src/map/map.cpp
index b2edf11..c8abba2 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -936,6 +936,14 @@ namespace Map {
 
             }
             size_t j = 0;
+            if ( !character_drawn &&
+                     player.collider_world.x >= xf &&
+                     player.collider_world.x <= xy_point.x &&
+                     player.collider_world.y >= yf &&
+                     player.collider_world.y <= xy_point.y) {
+                player.Draw(renderer);
+                character_drawn = true;
+            }
             for (Enemy* enemy : Enemy::enemies) {
                 if ( !enemies_drawn[j] &&
                      enemy->stats.health > 0 &&
@@ -952,24 +960,13 @@ namespace Map {
                 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)
+                        static_cast<int>((bird->pos_y-bird->altitude)/Tile::tile_size) != y_i)
                     continue;
 
                 bird->Render(renderer);
                 bird->drawn = true;
             }
         }
-        if ( !character_drawn ) {
-            player.Draw(renderer);
-            character_drawn = true;
-        }
-        for (Bird* bird : Bird::birds) {
-            if (bird->drawn)
-                continue;
-
-            bird->Render(renderer);
-            bird->drawn = true;
-        }
     }
 
 
diff --git a/src/start_screen/start_screen.cpp b/src/start_screen/start_screen.cpp
index a5d05e5..76bfb14 100644
--- a/src/start_screen/start_screen.cpp
+++ b/src/start_screen/start_screen.cpp
@@ -1,4 +1,5 @@
 #include "start_screen.hpp"
+#include "audio/audio.hpp"
 
 StartScreen::StartScreen(SDL_Renderer* r) : renderer(r) { Init(); }
 StartScreen::~StartScreen() {
@@ -302,26 +303,29 @@ float StartScreen::Lerp(float a, float b, float t) {
 
 namespace StartScreen_Event {
     void event_Loop(SDL_Renderer* renderer) {
-    StartScreen* scene = new StartScreen(renderer);
-    while (scene->running) {
-        SDL_Event e;
-        while (SDL_PollEvent(&e)) {
-            if (e.type == SDL_EVENT_QUIT) scene->running = false;
-
-            if (e.type == SDL_EVENT_KEY_DOWN && e.key.key == SDLK_SPACE) {
-                scene->~StartScreen();
-                scene = new StartScreen(renderer);   // restart from DOT
+        Audio audio;
+        audio.RegisterSound("intro", "music/intro.wav");
+        StartScreen* scene = new StartScreen(renderer);
+        audio.Play("intro");
+        while (scene->running) {
+            SDL_Event e;
+            while (SDL_PollEvent(&e)) {
+                if (e.type == SDL_EVENT_QUIT) scene->running = false;
+
+                if (e.type == SDL_EVENT_KEY_DOWN && e.key.key == SDLK_SPACE) {
+                    scene->~StartScreen();
+                    scene = new StartScreen(renderer);   // restart from DOT
+                }
+
+                if (e.type == SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED ||
+                    e.type == SDL_EVENT_WINDOW_RESIZED) {
+                    scene->UpdateScreen();
+                }
             }
 
-            if (e.type == SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED ||
-                e.type == SDL_EVENT_WINDOW_RESIZED) {
-                scene->UpdateScreen();
-            }
+            scene->Update();
+            scene->Render();
         }
-
-        scene->Update();
-        scene->Render();
     }
 }
-}