hedgewars/uWorld.pas
changeset 753 40fc0deb388f
parent 690 e9d35e319328
child 755 edf26e9554ac
equal deleted inserted replaced
752:69f1dc50a1fa 753:40fc0deb388f
   177    if WorldDy > cScreenHeight then r.h:= cScreenHeight
   177    if WorldDy > cScreenHeight then r.h:= cScreenHeight
   178                               else r.h:= WorldDy;
   178                               else r.h:= WorldDy;
   179    r.x:= 0;
   179    r.x:= 0;
   180    r.y:= 0;
   180    r.y:= 0;
   181    r.w:= cScreenWidth;
   181    r.w:= cScreenWidth;
   182    SDL_FillRect(Surface, @r, cSkyColor)
   182 //   SDL_FillRect(Surface, @r, cSkyColor)
   183    end;
   183    end;
   184 // background
   184 // background
   185 DrawRepeated(sprSky, WorldDx * 3 div 8);
   185 //DrawRepeated(sprSky, WorldDx * 3 div 8);
   186 DrawRepeated(sprHorizont, WorldDx * 3 div 5);
   186 //DrawRepeated(sprHorizont, WorldDx * 3 div 5);
   187 
   187 
   188 // Waves
   188 // Waves
   189 {$WARNINGS OFF}
   189 {$WARNINGS OFF}
   190 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6)      ) and $FF), cWaterLine + WorldDy - 64, 0, Surface);
   190 //for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6)      ) and $FF), cWaterLine + WorldDy - 64, 0, Surface);
   191 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx - (RealTicks shr 6) + 192) and $FF), cWaterLine + WorldDy - 48, 0, Surface);
   191 //for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx - (RealTicks shr 6) + 192) and $FF), cWaterLine + WorldDy - 48, 0, Surface);
   192 {$WARNINGS ON}
   192 {$WARNINGS ON}
   193 
   193 
   194 DrawLand(WorldDx, WorldDy, Surface);
   194 DrawLand(WorldDx, WorldDy, Surface);
   195 // Water
   195 // Water
   196 r.y:= WorldDy + cWaterLine + 32;
   196 r.y:= WorldDy + cWaterLine + 32;
   198    begin
   198    begin
   199    if r.y < 0 then r.y:= 0;
   199    if r.y < 0 then r.y:= 0;
   200    r.h:= cScreenHeight - r.y;
   200    r.h:= cScreenHeight - r.y;
   201    r.x:= 0;
   201    r.x:= 0;
   202    r.w:= cScreenWidth;
   202    r.w:= cScreenWidth;
   203    SDL_FillRect(Surface, @r, cWaterColor)
   203 //   SDL_FillRect(Surface, @r, cWaterColor)
   204    end;
   204    end;
   205 
   205 
   206 DrawGears(Surface);
   206 //DrawGears(Surface);
   207 
   207 
   208 // Waves
   208 // Waves
   209 {$WARNINGS OFF}
   209 {$WARNINGS OFF}
   210 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6) +  64) and $FF), cWaterLine + WorldDy - 32, 0, Surface);
   210 //for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6) +  64) and $FF), cWaterLine + WorldDy - 32, 0, Surface);
   211 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx - (RealTicks shr 6) + 128) and $FF), cWaterLine + WorldDy - 16, 0, Surface);
   211 //for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx - (RealTicks shr 6) + 128) and $FF), cWaterLine + WorldDy - 16, 0, Surface);
   212 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6)      ) and $FF), cWaterLine + WorldDy     , 0, Surface);
   212 //for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6)      ) and $FF), cWaterLine + WorldDy     , 0, Surface);
   213 {$WARNINGS ON}
   213 {$WARNINGS ON}
   214 
   214 
   215 // Turn time
   215 // Turn time
   216 if TurnTimeLeft <> 0 then
   216 if TurnTimeLeft <> 0 then
   217    begin
   217    begin
   218    i:= Succ(Pred(TurnTimeLeft) div 1000);
   218    i:= Succ(Pred(TurnTimeLeft) div 1000);
   219    if i>99 then t:= 112
   219    if i>99 then t:= 112
   220       else if i>9 then t:= 96
   220       else if i>9 then t:= 96
   221                   else t:= 80;
   221                   else t:= 80;
   222    DrawSprite(sprFrame, t, cScreenHeight - 48, 1, Surface);
   222 //   DrawSprite(sprFrame, t, cScreenHeight - 48, 1, Surface);
   223    while i > 0 do
   223    while i > 0 do
   224          begin
   224          begin
   225          dec(t, 32);
   225          dec(t, 32);
   226          DrawSprite(sprBigDigit, t, cScreenHeight - 48, i mod 10, Surface);
   226          DrawSprite(sprBigDigit, t, cScreenHeight - 48, i mod 10, Surface);
   227          i:= i div 10
   227          i:= i div 10
   228          end;
   228          end;
   229    DrawSprite(sprFrame, t - 4, cScreenHeight - 48, 0, Surface);
   229 //   DrawSprite(sprFrame, t - 4, cScreenHeight - 48, 0, Surface);
   230    end;
   230    end;
   231 
   231 
   232 // Attack bar
   232 // Attack bar
   233 if CurrentTeam <> nil then
   233 if CurrentTeam <> nil then
   234    case AttackBar of
   234    case AttackBar of
   242 *)        2: with CurrentHedgehog^ do
   242 *)        2: with CurrentHedgehog^ do
   243                 begin
   243                 begin
   244                 tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle);
   244                 tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle);
   245                 tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle);
   245                 tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle);
   246                 for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do
   246                 for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do
   247                     DrawSprite(sprPower, hwRound(Gear^.X) + system.round(WorldDx + tdx * (24 + i * 2)) - 16,
   247 //                    DrawSprite(sprPower, hwRound(Gear^.X) + system.round(WorldDx + tdx * (24 + i * 2)) - 16,
   248                                          hwRound(Gear^.Y) + system.round(WorldDy + tdy * (24 + i * 2)) - 12,
   248 //                                         hwRound(Gear^.Y) + system.round(WorldDy + tdy * (24 + i * 2)) - 12,
   249                                          i, Surface)
   249 //                                         i, Surface)
   250                 end
   250                 end
   251         end;
   251         end;
   252 
   252 
   253 // Target
   253 // Target
   254 if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0, Surface);
   254 //if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0, Surface);
   255 
   255 
   256 // Captions
   256 // Captions
   257 i:= 8;
   257 i:= 8;
   258 for grp:= Low(TCapGroup) to High(TCapGroup) do
   258 for grp:= Low(TCapGroup) to High(TCapGroup) do
   259     with Captions[grp] do
   259     with Captions[grp] do
   260          if Surf <> nil then
   260          if Surf <> nil then
   261             begin
   261             begin
   262             DrawCentered(cScreenWidth div 2, i + cConsoleYAdd, Surf, Surface);
   262 //            DrawCentered(cScreenWidth div 2, i + cConsoleYAdd, Surf, Surface);
   263             inc(i, Surf^.h + 2);
   263             inc(i, Surf^.h + 2);
   264             if EndTime <= RealTicks then
   264             if EndTime <= RealTicks then
   265                begin
   265                begin
   266                SDL_FreeSurface(Surf);
   266                SDL_FreeSurface(Surf);
   267                Surf:= nil;
   267                Surf:= nil;
   275       begin
   275       begin
   276       r.x:= cScreenWidth div 2 - NameTag^.w - 3;
   276       r.x:= cScreenWidth div 2 - NameTag^.w - 3;
   277       r.y:= DrawHealthY;
   277       r.y:= DrawHealthY;
   278       r.w:= NameTag^.w;
   278       r.w:= NameTag^.w;
   279       r.h:= NameTag^.h;
   279       r.h:= NameTag^.h;
   280       SDL_UpperBlit(NameTag, nil, Surface, @r);
   280 //      SDL_UpperBlit(NameTag, nil, Surface, @r);
   281 
   281 
   282       r.x:= 0;
   282       r.x:= 0;
   283       r.y:= 0;
   283       r.y:= 0;
   284       r.w:= 2 + TeamHealthBarWidth;
   284       r.w:= 2 + TeamHealthBarWidth;
   285       r.h:= HealthSurf^.h;
   285       r.h:= HealthSurf^.h;
   286 
   286 
   287       DrawFromRect(cScreenWidth div 2,
   287 //      DrawFromRect(cScreenWidth div 2,
   288                         DrawHealthY,
   288 //                        DrawHealthY,
   289                         @r, HealthSurf, Surface);
   289 //                        @r, HealthSurf, Surface);
   290 
   290 
   291       inc(r.x, cTeamHealthWidth + 2);
   291       inc(r.x, cTeamHealthWidth + 2);
   292       r.w:= 3;
   292       r.w:= 3;
   293 
   293 
   294       DrawFromRect(cScreenWidth div 2 + TeamHealthBarWidth + 2,
   294 //      DrawFromRect(cScreenWidth div 2 + TeamHealthBarWidth + 2,
   295                         DrawHealthY,
   295 //                        DrawHealthY,
   296                         @r, HealthSurf, Surface);
   296 //                        @r, HealthSurf, Surface);
   297       end;
   297       end;
   298 
   298 
   299 // Lag alert
   299 // Lag alert
   300 if isInLag then DrawSprite(sprLag, 32, 32  + cConsoleYAdd, (RealTicks shr 7) mod 12, Surface);
   300 //if isInLag then DrawSprite(sprLag, 32, 32  + cConsoleYAdd, (RealTicks shr 7) mod 12, Surface);
   301 
   301 
   302 // Wind bar
   302 // Wind bar
   303 DrawSprite(sprWindBar, cScreenWidth - 180, cScreenHeight - 30, 0, Surface);
   303 //DrawSprite(sprWindBar, cScreenWidth - 180, cScreenHeight - 30, 0, Surface);
   304 if WindBarWidth > 0 then
   304 if WindBarWidth > 0 then
   305    begin
   305    begin
   306    {$WARNINGS OFF}
   306    {$WARNINGS OFF}
   307    r.x:= 8 - (RealTicks shr 6) mod 8;
   307    r.x:= 8 - (RealTicks shr 6) mod 8;
   308    {$WARNINGS ON}
   308    {$WARNINGS ON}
   309    r.y:= 0;
   309    r.y:= 0;
   310    r.w:= WindBarWidth;
   310    r.w:= WindBarWidth;
   311    r.h:= 13;
   311    r.h:= 13;
   312    DrawSpriteFromRect(sprWindR, r, cScreenWidth - 103, cScreenHeight - 28, 13, 0, Surface);
   312 //   DrawSpriteFromRect(sprWindR, r, cScreenWidth - 103, cScreenHeight - 28, 13, 0, Surface);
   313    end else
   313    end else
   314  if WindBarWidth < 0 then
   314  if WindBarWidth < 0 then
   315    begin
   315    begin
   316    {$WARNINGS OFF}
   316    {$WARNINGS OFF}
   317    r.x:= (WindBarWidth + RealTicks shr 6) mod 8;
   317    r.x:= (WindBarWidth + RealTicks shr 6) mod 8;
   318    {$WARNINGS ON}
   318    {$WARNINGS ON}
   319    r.y:= 0;
   319    r.y:= 0;
   320    r.w:= - WindBarWidth;
   320    r.w:= - WindBarWidth;
   321    r.h:= 13;
   321    r.h:= 13;
   322    DrawSpriteFromRect(sprWindL, r, cScreenWidth - 106 + WindBarWidth, cScreenHeight - 28, 13, 0, Surface);
   322 //   DrawSpriteFromRect(sprWindL, r, cScreenWidth - 106 + WindBarWidth, cScreenHeight - 28, 13, 0, Surface);
   323    end;
   323    end;
   324 
   324 
   325 // AmmoMenu
   325 // AmmoMenu
   326 if (AMxCurr < cScreenWidth) or bShowAmmoMenu then ShowAmmoMenu(Surface);
   326 //if (AMxCurr < cScreenWidth) or bShowAmmoMenu then ShowAmmoMenu(Surface);
   327 
   327 
   328 // Cursor
   328 // Cursor
   329 if isCursorVisible then
   329 if isCursorVisible then
   330    begin
   330    begin
   331    if not bShowAmmoMenu then
   331    if not bShowAmmoMenu then
   333        if (Gear^.State and gstHHChooseTarget) <> 0 then
   333        if (Gear^.State and gstHHChooseTarget) <> 0 then
   334          begin
   334          begin
   335          i:= Ammo^[CurSlot, CurAmmo].Pos;
   335          i:= Ammo^[CurSlot, CurAmmo].Pos;
   336          with Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType] do
   336          with Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType] do
   337            if PosCount > 1 then
   337            if PosCount > 1 then
   338              DrawSprite(PosSprite, CursorPoint.X - SpritesData[PosSprite].Width div 2,
   338 //             DrawSprite(PosSprite, CursorPoint.X - SpritesData[PosSprite].Width div 2,
   339                                    CursorPoint.Y - SpritesData[PosSprite].Height div 2,
   339 //                                   CursorPoint.Y - SpritesData[PosSprite].Height div 2,
   340                                    i, Surface);
   340 //                                   i, Surface);
   341          end;
   341          end;
   342    DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8, Surface)
   342 //   DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8, Surface)
   343    end;
   343    end;
   344 
   344 
   345 {$IFDEF COUNTTICKS}
   345 {$IFDEF COUNTTICKS}
   346 DXOutText(10, 10, fnt16, inttostr(cntTicks), Surface);
   346 //DXOutText(10, 10, fnt16, inttostr(cntTicks), Surface);
   347 {$ENDIF}
   347 {$ENDIF}
   348 
   348 
   349 if isPaused then DrawCentered(cScreenWidth div 2, cScreenHeight div 2, PauseSurface, Surface);
   349 //if isPaused then DrawCentered(cScreenWidth div 2, cScreenHeight div 2, PauseSurface, Surface);
   350 
   350 
   351 inc(Frames);
   351 inc(Frames);
   352 if cShowFPS then
   352 if cShowFPS then
   353    begin
   353    begin
   354    inc(CountTicks, Lag);
   354    inc(CountTicks, Lag);
   361       if fpsSurface <> nil then SDL_FreeSurface(fpsSurface);
   361       if fpsSurface <> nil then SDL_FreeSurface(fpsSurface);
   362       fpsSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), $FFFFFF);
   362       fpsSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), $FFFFFF);
   363       end;
   363       end;
   364    r.x:= cScreenWidth - 50;
   364    r.x:= cScreenWidth - 50;
   365    r.y:= 10;
   365    r.y:= 10;
   366    SDL_UpperBlit(fpsSurface, nil, Surface, @r)
   366 //   SDL_UpperBlit(fpsSurface, nil, Surface, @r)
   367    end;
   367    end;
   368 
   368 
   369 inc(SoundTimerTicks, Lag);
   369 inc(SoundTimerTicks, Lag);
   370 if SoundTimerTicks >= 50 then
   370 if SoundTimerTicks >= 50 then
   371    begin
   371    begin