hedgewars/uWorld.pas
changeset 371 731ad6d27bd1
parent 351 29bc9c36ad5f
child 393 db01cc79f278
equal deleted inserted replaced
370:c75410fe3133 371:731ad6d27bd1
    18 
    18 
    19 unit uWorld;
    19 unit uWorld;
    20 interface
    20 interface
    21 uses SDLh, uGears, uConsts, uFloat;
    21 uses SDLh, uGears, uConsts, uFloat;
    22 {$INCLUDE options.inc}
    22 {$INCLUDE options.inc}
    23 const WorldDx: integer = -512;
    23 const WorldDx: LongInt = -512;
    24       WorldDy: integer = -256;
    24       WorldDy: LongInt = -256;
    25 
    25 
    26 procedure InitWorld;
    26 procedure InitWorld;
    27 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
    27 procedure DrawWorld(Lag: LongInt; Surface: PSDL_Surface);
    28 procedure AddCaption(s: string; Color: Longword; Group: TCapGroup);
    28 procedure AddCaption(s: string; Color: Longword; Group: TCapGroup);
    29 
    29 
    30 {$IFDEF COUNTTICKS}
    30 {$IFDEF COUNTTICKS}
    31 var cntTicks: LongWord;
    31 var cntTicks: LongWord;
    32 {$ENDIF}
    32 {$ENDIF}
    33 var FollowGear: PGear = nil;
    33 var FollowGear: PGear = nil;
    34     WindBarWidth: integer = 0;
    34     WindBarWidth: LongInt = 0;
    35     bShowAmmoMenu: boolean = false;
    35     bShowAmmoMenu: boolean = false;
    36     bSelected: boolean = false;
    36     bSelected: boolean = false;
    37     bShowFinger: boolean = false;
    37     bShowFinger: boolean = false;
    38     Frames: Longword = 0;
    38     Frames: Longword = 0;
    39 
    39 
    48 type TCaptionStr = record
    48 type TCaptionStr = record
    49                    Surf: PSDL_Surface;
    49                    Surf: PSDL_Surface;
    50                    EndTime: LongWord;
    50                    EndTime: LongWord;
    51                    end;
    51                    end;
    52 
    52 
    53 var cWaterSprCount: integer;
    53 var cWaterSprCount: LongInt;
    54     Captions: array[TCapGroup] of TCaptionStr;
    54     Captions: array[TCapGroup] of TCaptionStr;
    55     AMxLeft, AMxCurr, SlotsNum: integer;
    55     AMxLeft, AMxCurr, SlotsNum: LongInt;
    56     fpsSurface: PSDL_Surface;
    56     fpsSurface: PSDL_Surface;
    57 
    57 
    58 procedure InitWorld;
    58 procedure InitWorld;
    59 begin
    59 begin
    60 cWaterSprCount:= 1 + cScreenWidth div (SpritesData[sprWater].Width);
    60 cWaterSprCount:= 1 + cScreenWidth div (SpritesData[sprWater].Width);
    68 AMxCurr:= cScreenWidth
    68 AMxCurr:= cScreenWidth
    69 end;
    69 end;
    70 
    70 
    71 procedure ShowAmmoMenu(Surface: PSDL_Surface);
    71 procedure ShowAmmoMenu(Surface: PSDL_Surface);
    72 const MENUSPEED = 15;
    72 const MENUSPEED = 15;
    73 var x, y, i, t: integer;
    73 var x, y, i, t: LongInt;
    74     Slot, Pos: integer;
    74     Slot, Pos: LongInt;
    75 begin
    75 begin
    76 if (TurnTimeLeft = 0) or KbdKeyPressed then bShowAmmoMenu:= false;
    76 if (TurnTimeLeft = 0) or KbdKeyPressed then bShowAmmoMenu:= false;
    77 if bShowAmmoMenu then
    77 if bShowAmmoMenu then
    78    begin
    78    begin
    79    if AMxCurr = cScreenWidth then prevPoint.X:= 0;
    79    if AMxCurr = cScreenWidth then prevPoint.X:= 0;
   114             DrawSprite(sprAMSlot, x, y, 0, Surface);
   114             DrawSprite(sprAMSlot, x, y, 0, Surface);
   115             DrawSprite(sprAMSlotKeys, x + 2, y + 1, i, Surface);
   115             DrawSprite(sprAMSlotKeys, x + 2, y + 1, i, Surface);
   116             t:= 0;
   116             t:= 0;
   117             while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
   117             while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
   118                   begin
   118                   begin
   119                   DrawSprite(sprAMAmmos, x + t * 33 + 35, y + 1, integer(Ammo^[i, t].AmmoType), Surface);
   119                   DrawSprite(sprAMAmmos, x + t * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType), Surface);
   120                   if (Slot = i) and (CursorPoint.X >= x + t * 33 + 35) and (CursorPoint.X < x + t * 33 + 68) then
   120                   if (Slot = i) and (CursorPoint.X >= x + t * 33 + 35) and (CursorPoint.X < x + t * 33 + 68) then
   121                      begin
   121                      begin
   122                      DrawSprite(sprAMSelection, x + t * 33 + 35, y + 1, 0, Surface);
   122                      DrawSprite(sprAMSelection, x + t * 33 + 35, y + 1, 0, Surface);
   123                      Pos:= t;
   123                      Pos:= t;
   124                      end;
   124                      end;
   148 if AMxLeft = AMxCurr then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (hwFloatTicks shr 6) mod 8, Surface)
   148 if AMxLeft = AMxCurr then DrawSprite(sprArrow, CursorPoint.X, CursorPoint.Y, (hwFloatTicks shr 6) mod 8, Surface)
   149 end;
   149 end;
   150 
   150 
   151 procedure MoveCamera; forward;
   151 procedure MoveCamera; forward;
   152 
   152 
   153 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
   153 procedure DrawWorld(Lag: LongInt; Surface: PSDL_Surface);
   154 var i, t: integer;
   154 var i, t: LongInt;
   155     r: TSDL_Rect;
   155     r: TSDL_Rect;
   156     team: PTeam;
   156     team: PTeam;
   157     tdx, tdy: Double;
   157     tdx, tdy: Double;
   158     grp: TCapGroup;
   158     grp: TCapGroup;
   159     s: string[15];
   159     s: string[15];
   160 
   160 
   161     procedure DrawRepeated(spr: TSprite; Shift: integer);
   161     procedure DrawRepeated(spr: TSprite; Shift: LongInt);
   162     var i, w: integer;
   162     var i, w: LongInt;
   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
   377 Captions[Group].EndTime:= hwFloatTicks + 1500
   377 Captions[Group].EndTime:= hwFloatTicks + 1500
   378 end;
   378 end;
   379 
   379 
   380 procedure MoveCamera;
   380 procedure MoveCamera;
   381 const PrevSentPointTime: LongWord = 0;
   381 const PrevSentPointTime: LongWord = 0;
   382 var EdgesDist: integer;
   382 var EdgesDist: LongInt;
   383 begin
   383 begin
   384 if not (CurrentTeam^.ExtDriven and isCursorVisible) then SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y);
   384 if not (CurrentTeam^.ExtDriven and isCursorVisible) then SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y);
   385 if (FollowGear <> nil) then
   385 if (FollowGear <> nil) then
   386    if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then
   386    if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then
   387       begin
   387       begin