hedgewars/uWorld.pas
changeset 841 0700e3d3474d
parent 803 3f73901a350a
child 842 fae2fae2fe8d
equal deleted inserted replaced
840:3c0028245ff3 841:0700e3d3474d
    99      if Ammo = nil then exit;
    99      if Ammo = nil then exit;
   100      SlotsNum:= 0;
   100      SlotsNum:= 0;
   101      x:= AMxCurr;
   101      x:= AMxCurr;
   102      y:= cScreenHeight - 40;
   102      y:= cScreenHeight - 40;
   103      dec(y);
   103      dec(y);
   104      DrawSprite(sprAMBorders, x, y, 0, Surface);
   104      DrawSprite(sprAMBorders, x, y, 0);
   105      dec(y);
   105      dec(y);
   106      DrawSprite(sprAMBorders, x, y, 1, Surface);
   106      DrawSprite(sprAMBorders, x, y, 1);
   107      dec(y, 33);
   107      dec(y, 33);
   108      DrawSprite(sprAMSlotName, x, y, 0, Surface);
   108      DrawSprite(sprAMSlotName, x, y, 0);
   109      for i:= cMaxSlotIndex downto 0 do
   109      for i:= cMaxSlotIndex downto 0 do
   110          if Ammo^[i, 0].Count > 0 then
   110          if Ammo^[i, 0].Count > 0 then
   111             begin
   111             begin
   112             if (CursorPoint.Y >= y - 33) and (CursorPoint.Y < y) then Slot:= i;
   112             if (CursorPoint.Y >= y - 33) and (CursorPoint.Y < y) then Slot:= i;
   113             dec(y, 33);
   113             dec(y, 33);
   114             inc(SlotsNum);
   114             inc(SlotsNum);
   115             DrawSprite(sprAMSlot, x, y, 0, Surface);
   115             DrawSprite(sprAMSlot, x, y, 0);
   116             DrawSprite(sprAMSlotKeys, x + 2, y + 1, i, Surface);
   116             DrawSprite(sprAMSlotKeys, x + 2, y + 1, i);
   117             t:= 0;
   117             t:= 0;
   118             while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
   118             while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
   119                   begin
   119                   begin
   120                   DrawSprite(sprAMAmmos, x + t * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType), Surface);
   120                   DrawSprite(sprAMAmmos, x + t * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType));
   121                   if (Slot = i) and (CursorPoint.X >= x + t * 33 + 35) and (CursorPoint.X < x + t * 33 + 68) then
   121                   if (Slot = i) and (CursorPoint.X >= x + t * 33 + 35) and (CursorPoint.X < x + t * 33 + 68) then
   122                      begin
   122                      begin
   123                      DrawSprite(sprAMSelection, x + t * 33 + 35, y + 1, 0, Surface);
   123                      DrawSprite(sprAMSelection, x + t * 33 + 35, y + 1, 0);
   124                      Pos:= t;
   124                      Pos:= t;
   125                      end;
   125                      end;
   126                   inc(t)
   126                   inc(t)
   127                   end
   127                   end
   128             end;
   128             end;
   129      dec(y, 1);
   129      dec(y, 1);
   130      DrawSprite(sprAMBorders, x, y, 0, Surface);
   130      DrawSprite(sprAMBorders, x, y, 0);
   131 
   131 
   132      if (Pos >= 0) then
   132      if (Pos >= 0) then
   133         if Ammo^[Slot, Pos].Count > 0 then
   133         if Ammo^[Slot, Pos].Count > 0 then
   134            begin
   134            begin
   135            DXOutText(AMxCurr + 10, cScreenHeight - 68, fnt16, trAmmo[Ammoz[Ammo^[Slot, Pos].AmmoType].NameId], Surface);
   135            DXOutText(AMxCurr + 10, cScreenHeight - 68, fnt16, trAmmo[Ammoz[Ammo^[Slot, Pos].AmmoType].NameId], Surface);
   144               end;
   144               end;
   145            end;
   145            end;
   146      end;
   146      end;
   147 
   147 
   148 bSelected:= false;
   148 bSelected:= false;
   149 if AMxLeft = AMxCurr then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8, Surface)
   149 if AMxLeft = AMxCurr then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8)
   150 end;
   150 end;
   151 
   151 
   152 procedure MoveCamera; forward;
   152 procedure MoveCamera; forward;
   153 
   153 
   154 procedure DrawWorld(Lag: LongInt; Surface: PSDL_Surface);
   154 procedure DrawWorld(Lag: LongInt; Surface: PSDL_Surface);
   163     begin
   163     begin
   164     w:= SpritesData[spr].Width;
   164     w:= SpritesData[spr].Width;
   165     i:= Shift mod w;
   165     i:= Shift mod w;
   166     if i > 0 then dec(i, w);
   166     if i > 0 then dec(i, w);
   167     repeat
   167     repeat
   168       DrawSprite(spr, i, WorldDy + 1024 - SpritesData[spr].Height, 0, Surface);
   168       DrawSprite(spr, i, WorldDy + 1024 - SpritesData[spr].Height, 0);
   169       inc(i, w)
   169       inc(i, w)
   170     until i > cScreenWidth
   170     until i > cScreenWidth
   171     end;
   171     end;
   172 
   172 
   173 begin
   173 begin
   186 
   186 
   187 DrawVisualGears;
   187 DrawVisualGears;
   188 
   188 
   189 // Waves
   189 // Waves
   190 {$WARNINGS OFF}
   190 {$WARNINGS OFF}
   191 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)      ) and $FF), cWaterLine + WorldDy - 64, 0);
   192 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx - (RealTicks shr 6) + 192) and $FF), cWaterLine + WorldDy - 48, 0, Surface);
   192 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx - (RealTicks shr 6) + 192) and $FF), cWaterLine + WorldDy - 48, 0);
   193 {$WARNINGS ON}
   193 {$WARNINGS ON}
   194 
   194 
   195 DrawLand(WorldDx, WorldDy);
   195 DrawLand(WorldDx, WorldDy);
   196 // Water
   196 // Water
   197 r.y:= WorldDy + cWaterLine + 32;
   197 r.y:= WorldDy + cWaterLine + 32;
   215 
   215 
   216 DrawGears(Surface);
   216 DrawGears(Surface);
   217 
   217 
   218 // Waves
   218 // Waves
   219 {$WARNINGS OFF}
   219 {$WARNINGS OFF}
   220 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6) +  64) and $FF), cWaterLine + WorldDy - 32, 0, Surface);
   220 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6) +  64) and $FF), cWaterLine + WorldDy - 32, 0);
   221 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx - (RealTicks shr 6) + 128) and $FF), cWaterLine + WorldDy - 16, 0, Surface);
   221 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx - (RealTicks shr 6) + 128) and $FF), cWaterLine + WorldDy - 16, 0);
   222 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6)      ) and $FF), cWaterLine + WorldDy     , 0, Surface);
   222 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 256  + ((WorldDx + (RealTicks shr 6)      ) and $FF), cWaterLine + WorldDy     , 0);
   223 {$WARNINGS ON}
   223 {$WARNINGS ON}
   224 
   224 
   225 // Turn time
   225 // Turn time
   226 if TurnTimeLeft <> 0 then
   226 if TurnTimeLeft <> 0 then
   227    begin
   227    begin
   228    i:= Succ(Pred(TurnTimeLeft) div 1000);
   228    i:= Succ(Pred(TurnTimeLeft) div 1000);
   229    if i>99 then t:= 112
   229    if i>99 then t:= 112
   230       else if i>9 then t:= 96
   230       else if i>9 then t:= 96
   231                   else t:= 80;
   231                   else t:= 80;
   232    DrawSprite(sprFrame, t, cScreenHeight - 48, 1, Surface);
   232    DrawSprite(sprFrame, t, cScreenHeight - 48, 1);
   233    while i > 0 do
   233    while i > 0 do
   234          begin
   234          begin
   235          dec(t, 32);
   235          dec(t, 32);
   236          DrawSprite(sprBigDigit, t, cScreenHeight - 48, i mod 10, Surface);
   236          DrawSprite(sprBigDigit, t, cScreenHeight - 48, i mod 10);
   237          i:= i div 10
   237          i:= i div 10
   238          end;
   238          end;
   239    DrawSprite(sprFrame, t - 4, cScreenHeight - 48, 0, Surface);
   239    DrawSprite(sprFrame, t - 4, cScreenHeight - 48, 0);
   240    end;
   240    end;
   241 
   241 
   242 // Attack bar
   242 // Attack bar
   243 if CurrentTeam <> nil then
   243 if CurrentTeam <> nil then
   244    case AttackBar of
   244    case AttackBar of
   254                 tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle);
   254                 tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle);
   255                 tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle);
   255                 tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle);
   256                 for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do
   256                 for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do
   257                     DrawSprite(sprPower, hwRound(Gear^.X) + system.round(WorldDx + tdx * (24 + i * 2)) - 16,
   257                     DrawSprite(sprPower, hwRound(Gear^.X) + system.round(WorldDx + tdx * (24 + i * 2)) - 16,
   258                                          hwRound(Gear^.Y) + system.round(WorldDy + tdy * (24 + i * 2)) - 12,
   258                                          hwRound(Gear^.Y) + system.round(WorldDy + tdy * (24 + i * 2)) - 12,
   259                                          i, Surface)
   259                                          i)
   260                 end
   260                 end
   261         end;
   261         end;
   262 
   262 
   263 // Target
   263 // Target
   264 if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0, Surface);
   264 if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0);
   265 
   265 
   266 //glPopMatrix;
   266 //glPopMatrix;
   267 
   267 
   268 // Captions
   268 // Captions
   269 i:= 8;
   269 i:= 8;
   292       r.w:= 2 + TeamHealthBarWidth;
   292       r.w:= 2 + TeamHealthBarWidth;
   293       r.h:= HealthTex^.h;
   293       r.h:= HealthTex^.h;
   294 
   294 
   295       DrawFromRect(cScreenWidth div 2,
   295       DrawFromRect(cScreenWidth div 2,
   296                         DrawHealthY,
   296                         DrawHealthY,
   297                         @r, HealthTex, Surface);
   297                         @r, HealthTex);
   298 
   298 
   299       inc(r.x, cTeamHealthWidth + 2);
   299       inc(r.x, cTeamHealthWidth + 2);
   300       r.w:= 3;
   300       r.w:= 3;
   301 
   301 
   302       DrawFromRect(cScreenWidth div 2 + TeamHealthBarWidth + 2,
   302       DrawFromRect(cScreenWidth div 2 + TeamHealthBarWidth + 2,
   303                         DrawHealthY,
   303                         DrawHealthY,
   304                         @r, HealthTex, Surface);
   304                         @r, HealthTex);
   305       end;
   305       end;
   306 
   306 
   307 // Lag alert
   307 // Lag alert
   308 if isInLag then DrawSprite(sprLag, 32, 32  + cConsoleYAdd, (RealTicks shr 7) mod 12, Surface);
   308 if isInLag then DrawSprite(sprLag, 32, 32  + cConsoleYAdd, (RealTicks shr 7) mod 12);
   309 
   309 
   310 // Wind bar
   310 // Wind bar
   311 DrawSprite(sprWindBar, cScreenWidth - 180, cScreenHeight - 30, 0, Surface);
   311 DrawSprite(sprWindBar, cScreenWidth - 180, cScreenHeight - 30, 0);
   312 if WindBarWidth > 0 then
   312 if WindBarWidth > 0 then
   313    begin
   313    begin
   314    {$WARNINGS OFF}
   314    {$WARNINGS OFF}
   315    r.x:= 8 - (RealTicks shr 6) mod 8;
   315    r.x:= 8 - (RealTicks shr 6) mod 8;
   316    {$WARNINGS ON}
   316    {$WARNINGS ON}
   317    r.y:= 0;
   317    r.y:= 0;
   318    r.w:= WindBarWidth;
   318    r.w:= WindBarWidth;
   319    r.h:= 13;
   319    r.h:= 13;
   320    DrawSpriteFromRect(sprWindR, r, cScreenWidth - 103, cScreenHeight - 28, 13, 0, Surface);
   320    DrawSpriteFromRect(sprWindR, r, cScreenWidth - 103, cScreenHeight - 28, 13, 0);
   321    end else
   321    end else
   322  if WindBarWidth < 0 then
   322  if WindBarWidth < 0 then
   323    begin
   323    begin
   324    {$WARNINGS OFF}
   324    {$WARNINGS OFF}
   325    r.x:= (WindBarWidth + RealTicks shr 6) mod 8;
   325    r.x:= (WindBarWidth + RealTicks shr 6) mod 8;
   326    {$WARNINGS ON}
   326    {$WARNINGS ON}
   327    r.y:= 0;
   327    r.y:= 0;
   328    r.w:= - WindBarWidth;
   328    r.w:= - WindBarWidth;
   329    r.h:= 13;
   329    r.h:= 13;
   330    DrawSpriteFromRect(sprWindL, r, cScreenWidth - 106 + WindBarWidth, cScreenHeight - 28, 13, 0, Surface);
   330    DrawSpriteFromRect(sprWindL, r, cScreenWidth - 106 + WindBarWidth, cScreenHeight - 28, 13, 0);
   331    end;
   331    end;
   332 
   332 
   333 // AmmoMenu
   333 // AmmoMenu
   334 if (AMxCurr < cScreenWidth) or bShowAmmoMenu then ShowAmmoMenu(Surface);
   334 if (AMxCurr < cScreenWidth) or bShowAmmoMenu then ShowAmmoMenu(Surface);
   335 
   335 
   343          i:= Ammo^[CurSlot, CurAmmo].Pos;
   343          i:= Ammo^[CurSlot, CurAmmo].Pos;
   344          with Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType] do
   344          with Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType] do
   345            if PosCount > 1 then
   345            if PosCount > 1 then
   346               DrawSprite(PosSprite, CursorPoint.X - SpritesData[PosSprite].Width div 2,
   346               DrawSprite(PosSprite, CursorPoint.X - SpritesData[PosSprite].Width div 2,
   347                                     CursorPoint.Y - SpritesData[PosSprite].Height div 2,
   347                                     CursorPoint.Y - SpritesData[PosSprite].Height div 2,
   348                                     i, Surface);
   348                                     i);
   349          end;
   349          end;
   350    DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8, Surface)
   350    DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8)
   351    end;
   351    end;
   352 
   352 
   353 if isPaused then DrawCentered(cScreenWidth div 2, cScreenHeight div 2, PauseTexture);
   353 if isPaused then DrawCentered(cScreenWidth div 2, cScreenHeight div 2, PauseTexture);
   354 
   354 
   355 inc(Frames);
   355 inc(Frames);
   366       tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), $FFFFFF);
   366       tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), $FFFFFF);
   367       fpsTexture:= Surface2Tex(tmpSurface);
   367       fpsTexture:= Surface2Tex(tmpSurface);
   368       SDL_FreeSurface(tmpSurface)
   368       SDL_FreeSurface(tmpSurface)
   369       end;
   369       end;
   370    if fpsTexture <> nil then
   370    if fpsTexture <> nil then
   371       begin
   371       DrawTexture(cScreenWidth - 50, 10, fpsTexture);
   372       r.x:= 0;
       
   373       r.y:= 0;
       
   374       r.w:= fpsTexture^.w;
       
   375       r.h:= fpsTexture^.h;
       
   376       DrawFromRect(cScreenWidth - 50, 10, @r, fpsTexture, Surface);
       
   377       end
       
   378    end;
   372    end;
   379 
   373 
   380 inc(SoundTimerTicks, Lag);
   374 inc(SoundTimerTicks, Lag);
   381 if SoundTimerTicks >= 50 then
   375 if SoundTimerTicks >= 50 then
   382    begin
   376    begin