MINI DOOM  C++    4    
 


   MINI DOOM.  C++  :    .      ,       Z-.    ,       .          ,    ,            ,  .    ,   ,          .     ,    . C++20,    . 18+.





 

MINI DOOM  C++    4    





 



    MINI DOOM.  C++  .        :  DDA,       ,   ,    ,    E.

    .  ,      ,   .  12   ,    .




 


  1.      18:  C++  ,       .

  2.      913:   Windows, ,  ,   , .

  3.     1419: , , ,   , .

  4.  -    2025: , , ,  , .

  5. ,       2629: , , , CMake  .

     GitHub: https://github.com/RushSex/MiniDoom.  examples/chNN   ,    examples/ch29/doom.   README      Visual Studio 2026.      ,       ,       .




 IV.  - 



 : , , , .             : ,    . Doom     ,     , , ,     .

    .            ,     .      ,     ,    ,         .           ,   .











 20. 



    ,          . ,  , ,     .   ,     :    ,         .       ,   .    , Z-.

         ,    ,   ,   Doom,   PICKED UP A MEDIKIT.




  


,     ,    : h   (health), a   (ammo). Map::isWall    ,       .     ,  20.1.








 20.1  :   ,  ,  



enum class    : std::uint8_t     ,   ,  int.     ,   :  Doom ,    .

  Game        h  a     .      ,    taken:  ,  ,   25,            .




  


  ,    .     :     ,  . ,       .          .        0x00RRGGBB,      .  :      , . 0xFF   , 0x00   ,    .  20.2  20.3.








 20.2      








 20.3      








 20.3 ()      



  Image       .  box    .            64 ? 64: ,   ,     ,       ,    .











   


    (sx, sy).  ,   ,       :         , .            ,         14,  20.1.








 20.1     : depth    , side  



   . depth       ,        16,       : h / depth.       :    1   0,8,   depth  0,8 ? depth,  ,    side,    side / (0,8 ? depth)  ?1  +1.     ,     depth   (h/2) / depth  ,     18.

     drawSprites,  20.4  20.5.








 20.4    








 20.5  drawSprites: , , Z-, 








 20.5 ()  drawSprites: , , Z-, 



 1921  depth   .  3139     20.1: side,   , ,    ,       ,   .

 4146     ,   .  px      static_cast<int>,     .

 4759  .    ,   .   ,      .    48     .




Z-:   


    .     ,              .  ,    ,   .       :         .    ,   drawView    ,  20.6.








 20.6  drawView   zbuf



         640     Z-,  : z     .    col ,        : depth < zbuf[col].  20.2.








 20.2  Z-:    3    ,   



,     .   4850   20.5   20.7       ,  20.3.








 20.7  : Z-  








 20.3   Z-:           



        :             .  ,    ,       .    .











   


   .      :    . Z-   ,    .       18:     ,    .      depth     23  20.5:

std::ranges::sort(sprites, std::greater{}, &Sprite::depth);

   C++20    .   : std::greater{}  , ,  .   :    &Sprite::depth ,      ,    .       [](const Sprite& a, const Sprite& b) { return a.depth > b.depth; }    ,       .

 : drawSprites    ,   .   ,       .       ,    :     .







  .   ,          ,  20.8.








 20.8        








 20.8 ()        



 161165.    : dx? + dy? > 0,5?.       ,     . ,   :            .

 166169    Doom:    100%,   . Ÿ     ,  .   .

 181197   . Z-   : render       Game,         .           .    static- itemImage   ,     .

HUD   ,       Doom,      .     20.9.








 20.9  :     








 20.9 ()  :     



 start    8 ,  80%.

 forward 0.9 s      :  80 + 25 = 105,    100.   7,  .

 forward 0.7 s     ,   100%,    :   7.    ,    .

 waited 2 s   .








 20.4    :  ,   



  20.4        .      :        20.5.








 20.5   :  ,  ,  100%











 


    ,    .

    : depth    , side    .

  : x = w/2 ? (1 + side / (0,8 ? depth)),  h / depth,   .

       : 0   .

 Z-       ;  ,    .

        : std::ranges::sort(v, std::greater{}, &Sprite::depth).

 :        .       .         :  ,   .







 20.1. ?  20.10    .








 20.10    ?



 20.2. .   20.11        .   A     . ?








 20.11    



 20.3. .       b.   ,   .   :     .

 20.4..             ?    ,  ,    h / depth?







 20.1.   .       ,    .   :     .

 20.2.   . ,     20.3  ,  . :   ,    .

 20.3. .  Doom        .   Sprite  fullbright       256  lightAt.




 21.   



     .     :       .     , ,   ,    .    ,     :   , , .

     C++,      .       ,      .     ,      .    ,  : std::ranges::sort   20  ,  [](int x, int y) {}   14  .   -.




    


    :         ,      .     ,   . ,     ,    .         21.1.








 21.1     :    








 21.1 ()     :    



 614   .  template <typename F> : F  - ,   ,   .   f    : f(x, y).   ,    .            forEachCell          ,       .

 2124  .     :     . [&pic]    pic  ,     .    ,    .    .      (    ,   auto)    : put(x, y, '@').

 2735     [&]: ,  ,   .   cx, cy, rx, ry  put.    :  ,  (x ? cx)? / rx? + (y ? cy)? / ry? ? 1.   :      ,  ,    .  @, #  +    .

 3656  .  ,   ?   AB  ,       .          cross.              ,   .      ,       .  21.1.








 21.1            











  


  ,     Image  .     21.2  21.3.








 21.2  : , , , , 








 21.2 ()  : , , , , 



forEachPixel    ,    21.1,   Image.     :        ,   ,    .    ,    paint.cpp.








 21.3  : 








 21.3 ()  : 








 21.3 ()  : 



lit ( 1120)       k    0255  ,    shade   18,   , k  .   ch  k  : [k]      .

fillEllipse ( 2236)     21.1,       .

fillPolygon ( 3857)         .    std::span<const Point>     ,    14  Map.  std::array, std::vector   .        (i + 1) % size:      .

outline ( 5974)  :  ,     ,  .     60:     ,   ,    .   ,   21.2.

tint ( 7689)       ,      .




  


  .      21.4.      ,   :  ,  ,  ,  . , , , , , .








 21.4      








 21.4 ()      








 21.4 ()      



 1324      fillPolygon:   .    std::array<Point, 4> p{{{x0, y0}, }}:       ,      ,     .     ,       .

 2629  .       3    ,     .          .  Doom        ,     .

 7889       ,   .     : ,    ,  [] {  }().       ,  static  . ,       ,    .




  .


   .

   ,     (https://www.litres.ru/book/aleksey-primak/mini-doom-sovremennyi-c-cherez-igru-tom-4-zdes-kto-to-est-74670707/)  .

      Visa, MasterCard, Maestro,    ,   ,     ,  PayPal, WebMoney, ., QIWI ,       .


