瀏覽代碼

:recycle: added a little more spacing to credits

Felix Bytow 1 年之前
父節點
當前提交
ed8c2be4ce
共有 2 個文件被更改,包括 11 次插入6 次删除
  1. 8 6
      game/CreditsState.cxx
  2. 3 0
      game/CreditsState.hxx

+ 8 - 6
game/CreditsState.cxx

@@ -2,6 +2,8 @@
 
 
 #include "GameStateManager.hxx"
 #include "GameStateManager.hxx"
 
 
+#include <algorithm>
+#include <numeric>
 #include <type_traits>
 #include <type_traits>
 
 
 CreditsState::CreditsState()
 CreditsState::CreditsState()
@@ -24,7 +26,7 @@ void CreditsState::on_enter(GameStateManager& gsm)
       boost_logo_,
       boost_logo_,
   };
   };
 
 
-  int summed_size = -50;
+  int summed_size = -ITEM_PADDING;
   for (auto const& item: scroll_items_) {
   for (auto const& item: scroll_items_) {
     summed_size += std::visit([font]<typename T>(T const& it) {
     summed_size += std::visit([font]<typename T>(T const& it) {
       int w, h = 0;
       int w, h = 0;
@@ -35,14 +37,14 @@ void CreditsState::on_enter(GameStateManager& gsm)
         int logo_h, text_h;
         int logo_h, text_h;
         TTF_SizeUTF8(font, it.text_, &w, &text_h);
         TTF_SizeUTF8(font, it.text_, &w, &text_h);
         SDL_QueryTexture(it.texture_, nullptr, nullptr, &w, &logo_h);
         SDL_QueryTexture(it.texture_, nullptr, nullptr, &w, &logo_h);
-        h = logo_h+10+text_h;
+        h = logo_h+INNER_ITEM_PADDING+text_h;
       }
       }
       else if constexpr (std::is_same_v<T, SDL_Texture*>) {
       else if constexpr (std::is_same_v<T, SDL_Texture*>) {
         SDL_QueryTexture(it, nullptr, nullptr, &w, &h);
         SDL_QueryTexture(it, nullptr, nullptr, &w, &h);
       }
       }
       return h;
       return h;
     }, item);
     }, item);
-    summed_size += 50;
+    summed_size += ITEM_PADDING;
   }
   }
   scroll_size_ = static_cast<double>(summed_size);
   scroll_size_ = static_cast<double>(summed_size);
 }
 }
@@ -116,12 +118,12 @@ void CreditsState::render(SDLRenderer& renderer)
         SDL_FreeSurface(surface);
         SDL_FreeSurface(surface);
 
 
         SDL_QueryTexture(texture, nullptr, nullptr, &w, &text_h);
         SDL_QueryTexture(texture, nullptr, nullptr, &w, &text_h);
-        SDL_Rect const text_rect{.x = (window_width-w)/2, .y = y+logo_h+10, .w = w, .h = text_h};
+        SDL_Rect const text_rect{.x = (window_width-w)/2, .y = y+logo_h+INNER_ITEM_PADDING, .w = w, .h = text_h};
         SDL_RenderCopy(renderer, texture, nullptr, &text_rect);
         SDL_RenderCopy(renderer, texture, nullptr, &text_rect);
 
 
         SDL_DestroyTexture(texture);
         SDL_DestroyTexture(texture);
 
 
-        h = logo_h+10+text_h;
+        h = logo_h+INNER_ITEM_PADDING+text_h;
       }
       }
       else if constexpr (std::is_same_v<T, SDL_Texture*>) {
       else if constexpr (std::is_same_v<T, SDL_Texture*>) {
         int w;
         int w;
@@ -130,7 +132,7 @@ void CreditsState::render(SDLRenderer& renderer)
         SDL_RenderCopy(renderer, it, nullptr, &rect);
         SDL_RenderCopy(renderer, it, nullptr, &rect);
       }
       }
 
 
-      y += h+50;
+      y += h+ITEM_PADDING;
     }, item);
     }, item);
   }
   }
 
 

+ 3 - 0
game/CreditsState.hxx

@@ -17,6 +17,9 @@ struct External final {
 
 
 class CreditsState final : public GameState {
 class CreditsState final : public GameState {
 public:
 public:
+  static int constexpr ITEM_PADDING = 80;
+  static int constexpr INNER_ITEM_PADDING = 10;
+
   CreditsState();
   CreditsState();
 
 
   void on_enter(GameStateManager& gsm) override;
   void on_enter(GameStateManager& gsm) override;