hedgewars/uWorld.pas
changeset 6796 3e89dbdc7db9
parent 6795 e4831e13e04a
child 6798 4822b7d41aaa
equal deleted inserted replaced
6795:e4831e13e04a 6796:3e89dbdc7db9
    62     uMobile
    62     uMobile
    63     ;
    63     ;
    64 
    64 
    65 var cWaveWidth, cWaveHeight: LongInt;
    65 var cWaveWidth, cWaveHeight: LongInt;
    66     AMShiftTargetX, AMShiftTargetY, AMShiftX, AMShiftY, SlotsNum: LongInt;
    66     AMShiftTargetX, AMShiftTargetY, AMShiftX, AMShiftY, SlotsNum: LongInt;
       
    67     AMAnimStartTime, AMState : LongInt;
       
    68     AMAnimState: Single;
    67     tmpSurface: PSDL_Surface;
    69     tmpSurface: PSDL_Surface;
    68     fpsTexture: PTexture;
    70     fpsTexture: PTexture;
    69     timeTexture: PTexture;
    71     timeTexture: PTexture;
    70     AMAnimStartTime : LongInt;
       
    71     AMAnimState: Single;
       
    72     AMState: LongInt;
       
    73     FPS: Longword;
    72     FPS: Longword;
    74     CountTicks: Longword;
    73     CountTicks: Longword;
    75     SoundTimerTicks: Longword;
    74     SoundTimerTicks: Longword;
    76     prevPoint: TPoint;
    75     prevPoint: TPoint;
    77     amSel: TAmmoType = amNothing;
    76     amSel: TAmmoType = amNothing;
   199 //aligns it to the bottom of the screen, minus the border
   198 //aligns it to the bottom of the screen, minus the border
   200 SkyOffset:= 0;
   199 SkyOffset:= 0;
   201 HorizontOffset:= 0;
   200 HorizontOffset:= 0;
   202 
   201 
   203 InitTouchInterface();
   202 InitTouchInterface();
   204 
   203 AMAnimType:= AMTypeMaskX or AMTypeMaskAlpha;
   205 end;
   204 end;
   206 
   205 
   207 procedure InitCameraBorders;
   206 procedure InitCameraBorders;
   208 begin
   207 begin
   209 cGearScrEdgesDist:= min(2 * cScreenHeight div 5, 2 * cScreenWidth div 5);
   208 cGearScrEdgesDist:= min(2 * cScreenHeight div 5, 2 * cScreenWidth div 5);
   499         end;
   498         end;
   500 {$ELSE}
   499 {$ELSE}
   501         AmmoRect.x:= (cScreenWidth shr 1) - AmmoRect.w - AMSlotSize;
   500         AmmoRect.x:= (cScreenWidth shr 1) - AmmoRect.w - AMSlotSize;
   502         AmmoRect.y:= cScreenHeight - (AmmoRect.h + AMSlotSize);
   501         AmmoRect.y:= cScreenHeight - (AmmoRect.h + AMSlotSize);
   503 {$ENDIF}
   502 {$ENDIF}
   504     AMShiftTargetX:= (cScreenWidth shr 1) - AmmoRect.x;
   503     if (AMAnimType and AMTypeMaskX) <> 0 then AMShiftTargetX:= (cScreenWidth shr 1) - AmmoRect.x
   505     AMShiftTargetY:= cScreenHeight        - AmmoRect.y;
   504     else AMShiftTargetX:= 0;
       
   505     if (AMAnimType and AMTypeMaskY) <> 0 then AMShiftTargetY:= cScreenHeight        - AmmoRect.y
       
   506     else AMShiftTargetY:= 0;
   506     AMShiftX:= AMShiftTargetX;
   507     AMShiftX:= AMShiftTargetX;
   507     AMShiftY:= AMShiftTargetY;
   508     AMShiftY:= AMShiftTargetY;
   508 end;
   509 end;
   509 
   510 
   510 AMAnimState:= (RealTicks - AMAnimStartTime) / AMAnimDuration;
   511 AMAnimState:= (RealTicks - AMAnimStartTime) / AMAnimDuration;
   520     else
   521     else
   521         if AMAnimState < 1 then
   522         if AMAnimState < 1 then
   522             begin
   523             begin
   523             AMShiftX:= Round(AMShiftTargetX * (1 - AMAnimState));
   524             AMShiftX:= Round(AMShiftTargetX * (1 - AMAnimState));
   524             AMShiftY:= Round(AMShiftTargetY * (1 - AMAnimState));
   525             AMShiftY:= Round(AMShiftTargetY * (1 - AMAnimState));
   525             Tint($FF, $ff, $ff, Round($ff * AMAnimState));
   526             if (AMAnimType and AMTypeMaskAlpha) <> 0 then 
       
   527                 Tint($FF, $ff, $ff, Round($ff * AMAnimState));
   526             end
   528             end
   527         else
   529         else
   528             begin
   530             begin
   529             AMShiftX:= 0;
   531             AMShiftX:= 0;
   530             AMShiftY:= 0;
   532             AMShiftY:= 0;
   544     else
   546     else
   545         if AMAnimState < 1 then
   547         if AMAnimState < 1 then
   546             begin
   548             begin
   547             AMShiftX:= Round(AMShiftTargetX * AMAnimState);
   549             AMShiftX:= Round(AMShiftTargetX * AMAnimState);
   548             AMShiftY:= Round(AMShiftTargetY * AMAnimState);
   550             AMShiftY:= Round(AMShiftTargetY * AMAnimState);
   549             Tint($FF, $ff, $ff, Round($ff * (1-AMAnimState)));
   551             if (AMAnimType and AMTypeMaskAlpha) <> 0 then 
       
   552                 Tint($FF, $ff, $ff, Round($ff * (1-AMAnimState)));
   550             end
   553             end
   551          else 
   554          else 
   552             begin
   555             begin
   553             AMShiftX:= AMShiftTargetX;
   556             AMShiftX:= AMShiftTargetX;
   554             AMShiftY:= AMShiftTargetY;
   557             AMShiftY:= AMShiftTargetY;
   556             AMState:= AMHidden;
   559             AMState:= AMHidden;
   557             end;
   560             end;
   558     end;
   561     end;
   559     
   562     
   560 DrawTexture(AmmoRect.x + AMShiftX, AmmoRect.y + AMShiftY, AmmoMenuTex);
   563 DrawTexture(AmmoRect.x + AMShiftX, AmmoRect.y + AMShiftY, AmmoMenuTex);
   561 Tint($FF, $ff, $ff, $ff);
   564 
   562 
   565 if ((AMState = AMHiding) or (AMState = AMShowingUp)) and ((AMAnimType and AMTypeMaskAlpha) <> 0 )then 
   563     Pos:= -1;
   566     Tint($FF, $ff, $ff, $ff);
   564     Slot:= -1;
   567 
   565     c:= -1;
   568 Pos:= -1;
       
   569 Slot:= -1;
       
   570 c:= -1;
   566 {$IFDEF USE_LANDSCAPE_AMMOMENU}
   571 {$IFDEF USE_LANDSCAPE_AMMOMENU}
   567     for i:= 0 to cMaxSlotIndex do
   572     for i:= 0 to cMaxSlotIndex do
   568         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   573         if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   569             begin
   574             begin
   570             inc(c);
   575             inc(c);