hedgewars/uWorld.pas
changeset 174 0b2c5b22f644
parent 165 9b9144948668
child 175 d226d976d836
equal deleted inserted replaced
173:004493dd60e4 174:0b2c5b22f644
    49     WindBarWidth: integer = 0;
    49     WindBarWidth: integer = 0;
    50     bShowAmmoMenu: boolean = false;
    50     bShowAmmoMenu: boolean = false;
    51     bSelected: boolean = false;
    51     bSelected: boolean = false;
    52 
    52 
    53 implementation
    53 implementation
    54 uses uStore, uMisc, uTeams, uIO, uConsole, uKeys, uLocale;
    54 uses uStore, uMisc, uTeams, uIO, uConsole, uKeys, uLocale, uSound;
    55 const RealTicks: Longword = 0;
    55 const RealTicks: Longword = 0;
    56       Frames: Longword = 0;
    56       Frames: Longword = 0;
    57       FPS: Longword = 0;
    57       FPS: Longword = 0;
    58       CountTicks: Longword = 0;
    58       CountTicks: Longword = 0;
       
    59       SoundTimerTicks: Longword = 0;
    59       prevPoint: TPoint = (X: 0; Y: 0);
    60       prevPoint: TPoint = (X: 0; Y: 0);
    60 
    61 
    61 type TCaptionStr = record
    62 type TCaptionStr = record
    62                    Surf: PSDL_Surface;
    63                    Surf: PSDL_Surface;
    63                    StorePos: Longword;
       
    64                    Group: TCapGroup;
    64                    Group: TCapGroup;
    65                    EndTime: LongWord;
    65                    EndTime: LongWord;
    66                    end;
    66                    end;
    67 
    67 
    68 var cWaterSprCount: integer;
    68 var cWaterSprCount: integer;
   167 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
   167 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
   168 var i, t: integer;
   168 var i, t: integer;
   169     r: TSDL_Rect;
   169     r: TSDL_Rect;
   170     team: PTeam;
   170     team: PTeam;
   171     tdx, tdy: Double;
   171     tdx, tdy: Double;
       
   172     s: string[15];
   172 
   173 
   173     procedure DrawRepeated(spr: TSprite; Shift: integer);
   174     procedure DrawRepeated(spr: TSprite; Shift: integer);
   174     var i, w: integer;
   175     var i, w: integer;
   175     begin
   176     begin
   176     w:= SpritesData[spr].Width;
   177     w:= SpritesData[spr].Width;
   389    begin
   390    begin
   390    FPS:= Frames;
   391    FPS:= Frames;
   391    Frames:= 0;
   392    Frames:= 0;
   392    CountTicks:= 0;
   393    CountTicks:= 0;
   393    end;
   394    end;
   394 if cShowFPS then DXOutText(cScreenWidth - 50, 10, fnt16, inttostr(FPS) + ' fps', Surface)
   395 if cShowFPS then DXOutText(cScreenWidth - 50, 10, fnt16, inttostr(FPS) + ' fps', Surface);
       
   396 
       
   397 inc(SoundTimerTicks, Lag);
       
   398 if SoundTimerTicks >= 50 then
       
   399    begin
       
   400    SoundTimerTicks:= 0;
       
   401    if cVolumeDelta <> 0 then
       
   402       begin
       
   403       str(ChangeVolume(cVolumeDelta), s);
       
   404       AddCaption(Format('Volume %1%', s), $FFFFFF, capgrpVolume)
       
   405       end
       
   406    end
   395 end;
   407 end;
   396 
   408 
   397 procedure AddCaption(s: string; Color: Longword; Group: TCapGroup);
   409 procedure AddCaption(s: string; Color: Longword; Group: TCapGroup);
   398 var i, t, m, k: LongWord;
   410 var i, m: LongWord;
   399 begin
   411 begin
   400 if Group in [capgrpGameState, capgrpNetSay] then WriteLnToConsole(s);
   412 if Group in [capgrpGameState, capgrpNetSay] then WriteLnToConsole(s);
   401 i:= 0;
   413 i:= 0;
   402 while (i < cMaxCaptions) and (Captions[i].Group <> Group) do inc(i);
   414 while (i < cMaxCaptions) and (Captions[i].Group <> Group) do inc(i);
   403 if i < cMaxCaptions then
   415 if i < cMaxCaptions then
   422    begin
   434    begin
   423    m:= 0;
   435    m:= 0;
   424    while (m < cMaxCaptions)and(Captions[m].EndTime > 0) do inc(m)
   436    while (m < cMaxCaptions)and(Captions[m].EndTime > 0) do inc(m)
   425    end;
   437    end;
   426 
   438 
   427 k:= 0;
       
   428 for i:= 0 to Pred(cMaxCaptions) do
       
   429     for t:= 0 to Pred(cMaxCaptions) do
       
   430         if (Captions[t].EndTime > 0) and (Captions[t].StorePos = k) then inc(k);
       
   431 
   439 
   432 Captions[m].Surf:= RenderString(s, Color, fntBig);
   440 Captions[m].Surf:= RenderString(s, Color, fntBig);
   433 Captions[m].StorePos:= k;
       
   434 Captions[m].Group:= Group;
   441 Captions[m].Group:= Group;
   435 Captions[m].EndTime:= RealTicks + 1200
   442 Captions[m].EndTime:= RealTicks + 1200
   436 end;
   443 end;
   437 
   444 
   438 procedure MoveCamera;
   445 procedure MoveCamera;