diff options
| author | fschildt <florian.schildt@protonmail.com> | 2025-10-01 14:08:24 +0200 | 
|---|---|---|
| committer | fschildt <florian.schildt@protonmail.com> | 2025-10-01 14:09:13 +0200 | 
| commit | c775ca6133d93ed97359a6a50bd94a5563c740de (patch) | |
| tree | 9d3efb1c7e7538ff9d5cae408d2c29f9dd3daeab /src/games/tetris | |
| parent | 41c2e2ecfcccf62b3c646980dd283848e33a8134 (diff) | |
general refactoring, prepare breakout game
Diffstat (limited to 'src/games/tetris')
| -rw-r--r-- | src/games/tetris/Board.cpp | 4 | ||||
| -rw-r--r-- | src/games/tetris/Board.hpp | 4 | ||||
| -rw-r--r-- | src/games/tetris/Tetris.cpp | 6 | ||||
| -rw-r--r-- | src/games/tetris/Tetris.hpp | 1 | ||||
| -rw-r--r-- | src/games/tetris/Tetromino.cpp | 32 | ||||
| -rw-r--r-- | src/games/tetris/Tetromino.hpp | 4 | 
6 files changed, 28 insertions, 23 deletions
diff --git a/src/games/tetris/Board.cpp b/src/games/tetris/Board.cpp index dd83cb1..1e57b2f 100644 --- a/src/games/tetris/Board.cpp +++ b/src/games/tetris/Board.cpp @@ -100,7 +100,7 @@ void Board::Draw(int32_t level) {          tetromino_size_with_border * 10,          tetromino_size_with_border * 20      }; -    RectF32 bg_world_rect = { +    Rectangle bg_world_rect = {          bg_world_pos.x,          bg_world_pos.y,          bg_world_pos.x + bg_world_dim.x, @@ -128,7 +128,7 @@ void Board::Draw(int32_t level) {                      1.0f                  };                  V2F32 world_dim = local_dim; -                RectF32 world_rect = { +                Rectangle world_rect = {                      world_pos.x,                      world_pos.y,                      world_pos.x + world_dim.x, diff --git a/src/games/tetris/Board.hpp b/src/games/tetris/Board.hpp index f841e2f..2e2edb2 100644 --- a/src/games/tetris/Board.hpp +++ b/src/games/tetris/Board.hpp @@ -1,6 +1,7 @@  #pragma once -#include <basic/defs.hpp> +#include <common/defs.hpp> +  class Tetromino; @@ -9,6 +10,7 @@ struct BoardPos {      int32_t y;  }; +  class Board {  public:      Board(); diff --git a/src/games/tetris/Tetris.cpp b/src/games/tetris/Tetris.cpp index a8004f3..d26649f 100644 --- a/src/games/tetris/Tetris.cpp +++ b/src/games/tetris/Tetris.cpp @@ -67,9 +67,9 @@ bool Tetris::Update(std::vector<SDL_Event> &events) {      for (auto &event : events) {          using enum TetrisRunningState;          switch (m_RunningState) { -            case Resume: UpdateResumeState(event); break; -            case Pause: UpdatePauseState(event); break; -            default:; +        case Resume: UpdateResumeState(event); break; +        case Pause: UpdatePauseState(event); break; +        default:;          }      } diff --git a/src/games/tetris/Tetris.hpp b/src/games/tetris/Tetris.hpp index 828f2e5..e517f1c 100644 --- a/src/games/tetris/Tetris.hpp +++ b/src/games/tetris/Tetris.hpp @@ -5,6 +5,7 @@  #include <games/tetris/Tetromino.hpp>  #include <games/tetris/Board.hpp> +  enum class TetrisRunningState {      Resume,      Pause, diff --git a/src/games/tetris/Tetromino.cpp b/src/games/tetris/Tetromino.cpp index 94343c0..9179d6d 100644 --- a/src/games/tetris/Tetromino.cpp +++ b/src/games/tetris/Tetromino.cpp @@ -158,22 +158,24 @@ Color Tetromino::GetColor(TetrominoId id) {      using enum TetrominoId;      Color color; +      switch (id) { -        case i_piece: -        case o_piece: -        case t_piece: { -            color = {0.8f, 0.8f, 0.8f, 1.0f}; -        } break; - -        case j_piece: -        case s_piece: { -            color = {0.8f, 0.2f, 0.2f, 1.0f}; -        } break; - -        default: { -            color = {0.2f, 0.4f, 0.2f, 1.0f}; -        } +    case i_piece: +    case o_piece: +    case t_piece: { +        color = {0.8f, 0.8f, 0.8f, 1.0f}; +    } break; + +    case j_piece: +    case s_piece: { +        color = {0.8f, 0.2f, 0.2f, 1.0f}; +    } break; + +    default: { +        color = {0.2f, 0.4f, 0.2f, 1.0f};      } +    } +      return color;  } @@ -202,7 +204,7 @@ void Tetromino::Draw(TetrominoId id, int32_t ori, V2F32 pos, float scale) {                      1.0f                  };                  V2F32 world_dim = local_dim; -                RectF32 world_rect = { +                Rectangle world_rect = {                      world_pos.x,                      world_pos.y,                      world_pos.x + world_dim.x, diff --git a/src/games/tetris/Tetromino.hpp b/src/games/tetris/Tetromino.hpp index ecc986b..88f71f5 100644 --- a/src/games/tetris/Tetromino.hpp +++ b/src/games/tetris/Tetromino.hpp @@ -1,7 +1,7 @@  #pragma once -#include <basic/defs.hpp> -#include <basic/math.hpp> +#include <common/defs.hpp> +#include <common/math.hpp>  #include <games/tetris/Board.hpp>  | 
