hedgewars/uWorld.pas
changeset 5 0dafbd19a04c
parent 4 bcbd7adb4e4b
child 6 9c1f00e7b43e
equal deleted inserted replaced
4:bcbd7adb4e4b 5:0dafbd19a04c
    76 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
    76 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
    77 var i, t: integer;
    77 var i, t: integer;
    78     r: TSDL_Rect;
    78     r: TSDL_Rect;
    79     team: PTeam;
    79     team: PTeam;
    80 begin
    80 begin
    81 // синее небо
    81 // Sky
    82 inc(RealTicks, Lag);
    82 inc(RealTicks, Lag);
    83 r.h:= WorldDy;
    83 r.h:= WorldDy;
    84 if r.h > 0 then
    84 if r.h > 0 then
    85    begin
    85    begin
    86    if r.h > cScreenHeight then r.h:= cScreenHeight;
    86    if r.h > cScreenHeight then r.h:= cScreenHeight;
    87    r.x:= 0;
    87    r.x:= 0;
    88    r.y:= 0;
    88    r.y:= 0;
    89    r.w:= cScreenWidth;
    89    r.w:= cScreenWidth;
    90    SDL_FillRect(Surface, @r, cSkyColor)
    90    SDL_FillRect(Surface, @r, cSkyColor)
    91    end;
    91    end;
    92 // задний фон
    92 // background
    93 for i:= 0 to (cScreenWidth shr 6) do
    93 for i:= 0 to (cScreenWidth shr 6) do
    94     DrawGear(sSky, i*64, WorldDy, Surface);
    94     DrawGear(sSky, i*64, WorldDy, Surface);
    95 
    95 
    96 for i:= -1 to 3 do // горизонт
    96 for i:= -1 to 3 do
    97     DrawGear(sHorizont, i * 512 + (((WorldDx * 3) div 5) and $1FF), cWaterLine - 256 + WorldDy, Surface);
    97     DrawGear(sHorizont, i * 512 + (((WorldDx * 3) div 5) and $1FF), cWaterLine - 256 + WorldDy, Surface);
    98 
    98 
    99 // волны
    99 // Waves
   100 {$WARNINGS OFF}
   100 {$WARNINGS OFF}
   101 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6)      ) and $FF), cWaterLine + WorldDy - 40, (((GameTicks shr 7) + 2) mod 12), Surface);
   101 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6)      ) and $FF), cWaterLine + WorldDy - 40, (((GameTicks shr 7) + 2) mod 12), Surface);
   102 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx - (RealTicks shr 6) + 192) and $FF), cWaterLine + WorldDy - 30, (((GameTicks shr 7) + 8) mod 12), Surface);
   102 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx - (RealTicks shr 6) + 192) and $FF), cWaterLine + WorldDy - 30, (((GameTicks shr 7) + 8) mod 12), Surface);
   103 {$WARNINGS ON}
   103 {$WARNINGS ON}
   104 
   104 
   105 // поле
       
   106 DrawLand(WorldDx, WorldDy, Surface);
   105 DrawLand(WorldDx, WorldDy, Surface);
   107 // вода
   106 // Water
   108 r.y:= WorldDy + cWaterLine + 32;
   107 r.y:= WorldDy + cWaterLine + 32;
   109 if r.y < cScreenHeight then
   108 if r.y < cScreenHeight then
   110    begin
   109    begin
   111    r.h:= cScreenHeight - r.y;
   110    r.h:= cScreenHeight - r.y;
   112    r.x:= 0;
   111    r.x:= 0;
   121       begin
   120       begin
   122       for i:= 0 to 7 do
   121       for i:= 0 to 7 do
   123           with team.Hedgehogs[i] do
   122           with team.Hedgehogs[i] do
   124                if Gear<>nil then
   123                if Gear<>nil then
   125                   if Gear.State = 0 then
   124                   if Gear.State = 0 then
   126                      begin // ёжик не находится под управлением
   125                      begin
   127                      DrawCaption( round(Gear.X) + WorldDx,
   126                      DrawCaption( round(Gear.X) + WorldDx,
   128                                   round(Gear.Y) - cHHHalfHeight - 30 + WorldDy,
   127                                   round(Gear.Y) - cHHHalfHeight - 30 + WorldDy,
   129                                   HealthRect, Surface, true);
   128                                   HealthRect, Surface, true);
   130                      DrawCaption( round(Gear.X) + WorldDx,
   129                      DrawCaption( round(Gear.X) + WorldDx,
   131                                   round(Gear.Y) - cHHHalfHeight - 54 + WorldDy,
   130                                   round(Gear.Y) - cHHHalfHeight - 54 + WorldDy,
   132                                   NameRect, Surface);
   131                                   NameRect, Surface);
   133 //                     DrawCaption( round(Gear.X) + WorldDx,
   132 //                     DrawCaption( round(Gear.X) + WorldDx,
   134 //                                  round(Gear.Y) - Gear.HalfHeight - 60 + WorldDy,
   133 //                                  round(Gear.Y) - Gear.HalfHeight - 60 + WorldDy,
   135 //                                  Team.NameRect, Surface);
   134 //                                  Team.NameRect, Surface);
   136                      end else // ёжик, которым счас управляем
   135                      end else // Current hedgehog
   137                      begin
   136                      begin
   138                      if (Gear.State and (gstMoving or gstAttacked or gstDrowning or gstFalling))=0 then // рисуем прицел и, если бот думает, знак вопроса
   137                      if (Gear.State and (gstMoving or gstAttacked or gstDrowning or gstFalling))=0 then
   139                         if (Gear.State and gstHHThinking) <> 0 then
   138                         if (Gear.State and gstHHThinking) <> 0 then
   140                            DrawGear(sQuestion, Round(Gear.X)  - 10 + WorldDx, Round(Gear.Y) - cHHHalfHeight - 34 + WorldDy, Surface)
   139                            DrawGear(sQuestion, Round(Gear.X)  - 10 + WorldDx, Round(Gear.Y) - cHHHalfHeight - 34 + WorldDy, Surface)
   141                         else
   140                         else
   142                            DrawCaption(Round(Gear.X + Sign(Gear.dX) * Sin(Gear.Angle*pi/cMaxAngle)*60) + WorldDx,
   141                            DrawCaption(Round(Gear.X + Sign(Gear.dX) * Sin(Gear.Angle*pi/cMaxAngle)*60) + WorldDx,
   143                                        Round(Gear.Y - Cos(Gear.Angle*pi/cMaxAngle)*60) + WorldDy - 5,
   142                                        Round(Gear.Y - Cos(Gear.Angle*pi/cMaxAngle)*60) + WorldDy - 5,
   144                                        Team.CrossHairRect, Surface)
   143                                        Team.CrossHairRect, Surface)
   145                      end;
   144                      end;
   146       team:= team.Next
   145       team:= team.Next
   147       end;
   146       end;
   148 
   147 
   149 // волны
   148 // Waves
   150 {$WARNINGS OFF}
   149 {$WARNINGS OFF}
   151 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6) +  64) and $FF), cWaterLine + WorldDy - 20, (((GameTicks shr 7) + 4 ) mod 12), Surface);
   150 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6) +  64) and $FF), cWaterLine + WorldDy - 20, (((GameTicks shr 7) + 4 ) mod 12), Surface);
   152 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx - (RealTicks shr 6) + 128) and $FF), cWaterLine + WorldDy - 10, (((GameTicks shr 7) + 10) mod 12), Surface);
   151 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx - (RealTicks shr 6) + 128) and $FF), cWaterLine + WorldDy - 10, (((GameTicks shr 7) + 10) mod 12), Surface);
   153 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6)      ) and $FF), cWaterLine + WorldDy     , (((GameTicks shr 7) + 6 ) mod 12), Surface);
   152 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6)      ) and $FF), cWaterLine + WorldDy     , (((GameTicks shr 7) + 6 ) mod 12), Surface);
   154 {$WARNINGS ON}
   153 {$WARNINGS ON}
   177            {$WARNINGS ON}
   176            {$WARNINGS ON}
   178            DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface);
   177            DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface);
   179            end;
   178            end;
   180         end;
   179         end;
   181 
   180 
   182 // Указатель на цель
   181 // Target
   183 if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0, Surface);
   182 if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0, Surface);
   184 
   183 
   185 // Captions
   184 // Captions
   186 i:= 0;
   185 i:= 0;
   187 while (i < cMaxCaptions) do
   186 while (i < cMaxCaptions) do
   195     for i:= 1 to Pred(cMaxCaptions) do
   194     for i:= 1 to Pred(cMaxCaptions) do
   196         Captions[Pred(i)]:= Captions[i];
   195         Captions[Pred(i)]:= Captions[i];
   197     Captions[Pred(cMaxCaptions)].EndTime:= 0
   196     Captions[Pred(cMaxCaptions)].EndTime:= 0
   198     end;
   197     end;
   199 
   198 
   200 // Указание на лаг
   199 // Lag alert
   201 if isInLag then DrawSprite(sprLag, 32, 32  + cConsoleYAdd, (RealTicks shr 7) mod 7, Surface);
   200 if isInLag then DrawSprite(sprLag, 32, 32  + cConsoleYAdd, (RealTicks shr 7) mod 7, Surface);
   202 
   201 
   203 // Курсор
   202 // Wind bar
       
   203 DrawGear(sWindBar, cScreenWidth - 180, cScreenHeight - 30, Surface);
       
   204 if cWindSpeed > 0 then
       
   205    begin
       
   206    t:= round(72 * cWindSpeed / cMaxWindSpeed);
       
   207    with StuffPoz[sWindR] do
       
   208         begin
       
   209         r.x:= x + 8 - (RealTicks shr 6) mod 8;
       
   210         r.y:= y;
       
   211         r.w:= t;
       
   212         r.h:= 13;
       
   213         end;
       
   214    DrawSpriteFromRect(r, cScreenWidth - 103, cScreenHeight - 28, 13, 0, Surface);
       
   215    end else
       
   216    begin
       
   217    t:= - round(72 * cWindSpeed / cMaxWindSpeed);
       
   218    with StuffPoz[sWindL] do
       
   219         begin
       
   220         r.x:= x + (RealTicks shr 6) mod 8;
       
   221         r.y:= y;
       
   222         r.w:= t;
       
   223         r.h:= 13;
       
   224         end;
       
   225    DrawSpriteFromRect(r, cScreenWidth - 106 - t, cScreenHeight - 28, 13, 0, Surface);
       
   226    end;
       
   227 
       
   228 // Cursor
   204 if isCursorVisible then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8, Surface);
   229 if isCursorVisible then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8, Surface);
   205 
   230 
   206 {$IFDEF COUNTTICKS}
   231 {$IFDEF COUNTTICKS}
   207 DXOutText(10, 10, fnt16, inttostr(cntTicks), Surface);
   232 DXOutText(10, 10, fnt16, inttostr(cntTicks), Surface);
   208 {$ENDIF}
   233 {$ENDIF}