hedgewars/uWorld.pas
changeset 161 d8870bbf960e
parent 154 5667e6f38704
child 162 4822f6face35
equal deleted inserted replaced
160:207f520b9e83 161:d8870bbf960e
    46 {$IFDEF COUNTTICKS}
    46 {$IFDEF COUNTTICKS}
    47 var cntTicks: LongWord;
    47 var cntTicks: LongWord;
    48 {$ENDIF}
    48 {$ENDIF}
    49 var FollowGear: PGear = nil;
    49 var FollowGear: PGear = nil;
    50     WindBarWidth: integer = 0;
    50     WindBarWidth: integer = 0;
       
    51     bShowAmmoMenu: boolean = false;
    51 
    52 
    52 implementation
    53 implementation
    53 uses uStore, uMisc, uTeams, uIO, uConsole;
    54 uses uStore, uMisc, uTeams, uIO, uConsole, uKeys;
    54 const RealTicks: Longword = 0;
    55 const RealTicks: Longword = 0;
    55       Frames: Longword = 0;
    56       Frames: Longword = 0;
    56       FPS: Longword = 0;
    57       FPS: Longword = 0;
    57       CountTicks: Longword = 0;
    58       CountTicks: Longword = 0;
    58       prevPoint: TPoint = (X: 0; Y: 0);
    59       prevPoint: TPoint = (X: 0; Y: 0);
    59       
    60 
    60 type TCaptionStr = record
    61 type TCaptionStr = record
    61                    Surf: PSDL_Surface;
    62                    Surf: PSDL_Surface;
    62                    StorePos: Longword;
    63                    StorePos: Longword;
    63                    Group: TCapGroup;
    64                    Group: TCapGroup;
    64                    EndTime: LongWord;
    65                    EndTime: LongWord;
    65                    end;
    66                    end;
    66 
    67 
    67 var cWaterSprCount: integer;
    68 var cWaterSprCount: integer;
    68     Captions: array[0..Pred(cMaxCaptions)] of TCaptionStr;
    69     Captions: array[0..Pred(cMaxCaptions)] of TCaptionStr;
       
    70     AMxLeft, AMxCurr: integer;
    69 
    71 
    70 procedure InitWorld;
    72 procedure InitWorld;
    71 begin
    73 begin
    72 cWaterSprCount:= 1 + cScreenWidth div (SpritesData[sprWater].Width);
    74 cWaterSprCount:= 1 + cScreenWidth div (SpritesData[sprWater].Width);
    73 cScreenEdgesDist:= Min(cScreenWidth div 4, cScreenHeight div 4);
    75 cScreenEdgesDist:= Min(cScreenWidth div 4, cScreenHeight div 4);
    74 SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
    76 SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
    75 prevPoint.X:= cScreenWidth div 2;
    77 prevPoint.X:= cScreenWidth div 2;
    76 prevPoint.Y:= cScreenHeight div 2;
    78 prevPoint.Y:= cScreenHeight div 2;
    77 WorldDx:=  - 1024 + cScreenWidth div 2;
    79 WorldDx:=  - 1024 + cScreenWidth div 2;
    78 WorldDy:=  - 512 + cScreenHeight div 2
    80 WorldDy:=  - 512 + cScreenHeight div 2;
       
    81 AMxLeft:= cScreenWidth - 210;
       
    82 AMxCurr:= cScreenWidth
       
    83 end;
       
    84 
       
    85 procedure ShowAmmoMenu(Surface: PSDL_Surface);
       
    86 const MENUSPEED = 15;
       
    87 var x, y, i, t: integer;
       
    88 begin
       
    89 if (TurnTimeLeft = 0) or KbdKeyPressed then bShowAmmoMenu:= false;
       
    90 if      bShowAmmoMenu  and (AMxCurr > AMxLeft)      then dec(AMxCurr, MENUSPEED);
       
    91 if (not bShowAmmoMenu) and (AMxCurr < cScreenWidth) then inc(AMxCurr, MENUSPEED);
       
    92 
       
    93 if CurrentTeam = nil then exit;
       
    94 with CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog] do
       
    95      begin
       
    96      if Ammo = nil then exit;
       
    97      x:= AMxCurr;
       
    98      y:= cScreenHeight - 40;
       
    99      dec(y);
       
   100      DrawSprite(sprAMBorders, x, y, 0, Surface);
       
   101      dec(y);
       
   102      DrawSprite(sprAMBorders, x, y, 1, Surface);
       
   103      dec(y, 33);
       
   104      DrawSprite(sprAMSlotName, x, y, 0, Surface);
       
   105      for i:= cMaxSlotIndex downto 0 do
       
   106          if Ammo[i, 0].Count > 0 then
       
   107             begin
       
   108             dec(y, 33);
       
   109             DrawSprite(sprAMSlot, x, y, 0, Surface);
       
   110             DrawSprite(sprAMSlotKeys, x + 2, y + 1, i, Surface);
       
   111             t:= 0;
       
   112             while (t <= cMaxSlotAmmoIndex) and (Ammo[i, t].Count > 0) do
       
   113                   begin
       
   114                   DrawSprite(sprAMAmmos, x + t * 33 + 35, y + 1, integer(Ammo[i, t].AmmoType), Surface);
       
   115                   inc(t)
       
   116                   end
       
   117             end;
       
   118      dec(y, 1);
       
   119      DrawSprite(sprAMBorders, x, y, 0, Surface)
       
   120      end
    79 end;
   121 end;
    80 
   122 
    81 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
   123 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
    82 var i, t: integer;
   124 var i, t: integer;
    83     r: TSDL_Rect;
   125     r: TSDL_Rect;
   283         r.h:= 13;
   325         r.h:= 13;
   284         end;
   326         end;
   285    DrawSpriteFromRect(r, cScreenWidth - 106 + WindBarWidth, cScreenHeight - 28, 13, 0, Surface);
   327    DrawSpriteFromRect(r, cScreenWidth - 106 + WindBarWidth, cScreenHeight - 28, 13, 0, Surface);
   286    end;
   328    end;
   287 
   329 
       
   330 // AmmoMenu
       
   331 if (AMxCurr < cScreenWidth) or bShowAmmoMenu then ShowAmmoMenu(Surface);
       
   332 
   288 // Cursor
   333 // Cursor
   289 if isCursorVisible then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8, Surface);
   334 if isCursorVisible then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (RealTicks shr 6) mod 8, Surface);
   290 
   335 
   291 {$IFDEF COUNTTICKS}
   336 {$IFDEF COUNTTICKS}
   292 DXOutText(10, 10, fnt16, inttostr(cntTicks), Surface);
   337 DXOutText(10, 10, fnt16, inttostr(cntTicks), Surface);