hedgewars/uWorld.pas
branchwebgl
changeset 8444 75db7bb8dce8
parent 8330 aaefa587e277
parent 8425 4f226963faef
child 8833 c13ebed437cb
equal deleted inserted replaced
8340:46a9fde631f4 8444:75db7bb8dce8
    76     fpsTexture: PTexture;
    76     fpsTexture: PTexture;
    77     timeTexture: PTexture;
    77     timeTexture: PTexture;
    78     FPS: Longword;
    78     FPS: Longword;
    79     CountTicks: Longword;
    79     CountTicks: Longword;
    80     SoundTimerTicks: Longword;
    80     SoundTimerTicks: Longword;
    81     prevPoint: TPoint;
    81     prevPoint, prevTargetPoint: TPoint;
    82     amSel: TAmmoType = amNothing;
    82     amSel: TAmmoType = amNothing;
    83     missionTex: PTexture;
    83     missionTex: PTexture;
    84     missionTimer: LongInt;
    84     missionTimer: LongInt;
    85     stereoDepth: GLfloat;
    85     stereoDepth: GLfloat;
    86     isFirstFrame: boolean;
    86     isFirstFrame: boolean;
    87     AMAnimType: LongInt;
    87     AMAnimType: LongInt;
    88     recTexture: PTexture;
    88     recTexture: PTexture;
    89     AmmoMenuTex     : PTexture;
    89     AmmoMenuTex     : PTexture;
    90     HorizontOffset: LongInt;
    90     HorizontOffset: LongInt;
    91     cOffsetY: LongInt;
    91     cOffsetY: LongInt;
    92     AFRToggle: Boolean;
       
    93 
    92 
    94 const cStereo_Sky           = 0.0500;
    93 const cStereo_Sky           = 0.0500;
    95       cStereo_Horizon       = 0.0250;
    94       cStereo_Horizon       = 0.0250;
    96       cStereo_MidDistance   = 0.0175;
    95       cStereo_MidDistance   = 0.0175;
    97       cStereo_Water_distant = 0.0125;
    96       cStereo_Water_distant = 0.0125;
   106       AMHiding    = 3;
   105       AMHiding    = 3;
   107 
   106 
   108       AMTypeMaskX     = $00000001;
   107       AMTypeMaskX     = $00000001;
   109       AMTypeMaskY     = $00000002;
   108       AMTypeMaskY     = $00000002;
   110       AMTypeMaskAlpha = $00000004;
   109       AMTypeMaskAlpha = $00000004;
   111       AMTypeMaskSlide = $00000008;
   110       //AMTypeMaskSlide = $00000008;
   112 
   111 
   113 {$IFDEF MOBILE}
   112 {$IFDEF MOBILE}
   114       AMSlotSize = 48;
   113       AMSlotSize = 48;
   115       AMTITLE    = 30;
       
   116 {$ELSE}
   114 {$ELSE}
   117       AMSlotSize = 32;
   115       AMSlotSize = 32;
   118 {$ENDIF}
   116 {$ENDIF}
   119       AMSlotPadding = (AMSlotSize - 32) shr 1;
   117       AMSlotPadding = (AMSlotSize - 32) shr 1;
   120 
   118 
   225 
   223 
   226 InitCameraBorders();
   224 InitCameraBorders();
   227 uCursor.init();
   225 uCursor.init();
   228 prevPoint.X:= 0;
   226 prevPoint.X:= 0;
   229 prevPoint.Y:= cScreenHeight div 2;
   227 prevPoint.Y:= cScreenHeight div 2;
       
   228 prevTargetPoint.X:= 0;
       
   229 prevTargetPoint.Y:= 0;
   230 WorldDx:=  -(LAND_WIDTH div 2) + cScreenWidth div 2;
   230 WorldDx:=  -(LAND_WIDTH div 2) + cScreenWidth div 2;
   231 WorldDy:=  -(LAND_HEIGHT - (playHeight div 2)) + (cScreenHeight div 2);
   231 WorldDy:=  -(LAND_HEIGHT - (playHeight div 2)) + (cScreenHeight div 2);
   232 
   232 
   233 //aligns it to the bottom of the screen, minus the border
   233 //aligns it to the bottom of the screen, minus the border
   234 SkyOffset:= 0;
   234 SkyOffset:= 0;
   644          else
   644          else
   645             begin
   645             begin
   646             AMShiftX:= AMShiftTargetX;
   646             AMShiftX:= AMShiftTargetX;
   647             AMShiftY:= AMShiftTargetY;
   647             AMShiftY:= AMShiftTargetY;
   648             prevPoint:= CursorPoint;
   648             prevPoint:= CursorPoint;
       
   649             prevTargetPoint:= TargetCursorPoint;
   649             AMState:= AMHidden;
   650             AMState:= AMHidden;
   650             end;
   651             end;
   651     end;
   652     end;
   652 
   653 
   653 DrawTexture(AmmoRect.x + AMShiftX, AmmoRect.y + AMShiftY, AmmoMenuTex);
   654 DrawTexture(AmmoRect.x + AMShiftX, AmmoRect.y + AMShiftY, AmmoMenuTex);
  1015         begin
  1016         begin
  1016         glClear(GL_COLOR_BUFFER_BIT);
  1017         glClear(GL_COLOR_BUFFER_BIT);
  1017         DrawWorldStereo(Lag, rmDefault)
  1018         DrawWorldStereo(Lag, rmDefault)
  1018         end
  1019         end
  1019 {$IFDEF USE_S3D_RENDERING}
  1020 {$IFDEF USE_S3D_RENDERING}
  1020     else if (cStereoMode = smAFR) then
       
  1021         begin
       
  1022         AFRToggle:= (not AFRToggle);
       
  1023         glClear(GL_COLOR_BUFFER_BIT);
       
  1024         if AFRToggle then
       
  1025             DrawWorldStereo(Lag, rmLeftEye)
       
  1026         else
       
  1027             DrawWorldStereo(Lag, rmRightEye)
       
  1028         end
       
  1029     else if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) then
  1021     else if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) then
  1030         begin
  1022         begin
  1031         // create left fb
  1023         // create left fb
  1032         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framel);
  1024         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framel);
  1033         glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  1025         glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  1706 // Cursor
  1698 // Cursor
  1707 if isCursorVisible then
  1699 if isCursorVisible then
  1708     begin
  1700     begin
  1709     if (not bShowAmmoMenu) then
  1701     if (not bShowAmmoMenu) then
  1710         begin
  1702         begin
       
  1703         if not CurrentTeam^.ExtDriven then TargetCursorPoint:= CursorPoint;
  1711         with CurrentHedgehog^ do
  1704         with CurrentHedgehog^ do
  1712             if (Gear <> nil) and ((Gear^.State and gstHHChooseTarget) <> 0) then
  1705             if (Gear <> nil) and ((Gear^.State and gstHHChooseTarget) <> 0) then
  1713                 begin
  1706                 begin
  1714             if (CurAmmoType = amNapalm) or (CurAmmoType = amMineStrike) then
  1707             if (CurAmmoType = amNapalm) or (CurAmmoType = amMineStrike) then
  1715                 DrawLine(-3000, topY-300, 7000, topY-300, 3.0, (Team^.Clan^.Color shr 16), (Team^.Clan^.Color shr 8) and $FF, Team^.Clan^.Color and $FF, $FF);
  1708                 DrawLine(-3000, topY-300, 7000, topY-300, 3.0, (Team^.Clan^.Color shr 16), (Team^.Clan^.Color shr 8) and $FF, Team^.Clan^.Color and $FF, $FF);
  1716             i:= GetCurAmmoEntry(CurrentHedgehog^)^.Pos;
  1709             i:= GetCurAmmoEntry(CurrentHedgehog^)^.Pos;
  1717             with Ammoz[CurAmmoType] do
  1710             with Ammoz[CurAmmoType] do
  1718                 if PosCount > 1 then
  1711                 if PosCount > 1 then
  1719                     DrawSprite(PosSprite, CursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - CursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i);
  1712                     DrawSprite(PosSprite, TargetCursorPoint.X - (SpritesData[PosSprite].Width shr 1), cScreenHeight - TargetCursorPoint.Y - (SpritesData[PosSprite].Height shr 1),i);
  1720                 end;
  1713                 end;
  1721         DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
  1714         DrawSprite(sprArrow, TargetCursorPoint.X, cScreenHeight - TargetCursorPoint.Y, (RealTicks shr 6) mod 8)
  1722         end
  1715         end
  1723     end;
  1716     end;
  1724 
  1717 
  1725 isFirstFrame:= false
  1718 isFirstFrame:= false
  1726 end;
  1719 end;
  1729 
  1722 
  1730 procedure MoveCamera;
  1723 procedure MoveCamera;
  1731 var EdgesDist, wdy, shs,z, amNumOffsetX, amNumOffsetY: LongInt;
  1724 var EdgesDist, wdy, shs,z, amNumOffsetX, amNumOffsetY: LongInt;
  1732 begin
  1725 begin
  1733 {$IFNDEF MOBILE}
  1726 {$IFNDEF MOBILE}
  1734 if (not (CurrentTeam^.ExtDriven and isCursorVisible and (not bShowAmmoMenu))) and cHasFocus and (GameState <> gsConfirm) then
  1727 if (not (CurrentTeam^.ExtDriven and isCursorVisible and (not bShowAmmoMenu) and autoCameraOn)) and cHasFocus and (GameState <> gsConfirm) then
  1735     uCursor.updatePosition();
  1728     uCursor.updatePosition();
  1736 {$ENDIF}
  1729 {$ENDIF}
  1737 z:= round(200/zoom);
  1730 z:= round(200/zoom);
  1738 if (not PlacingHogs) and (FollowGear <> nil) and (not isCursorVisible) and (not bShowAmmoMenu) and (not fastUntilLag) and autoCameraOn then
  1731 if (not PlacingHogs) and (FollowGear <> nil) and (not isCursorVisible) and (not bShowAmmoMenu) and (not fastUntilLag) and autoCameraOn then
  1739     if ((abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y)) > 4) then
  1732     if ((abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y)) > 4) then
  1800     end
  1793     end
  1801 else
  1794 else
  1802     EdgesDist:= cGearScrEdgesDist;
  1795     EdgesDist:= cGearScrEdgesDist;
  1803 
  1796 
  1804 // this generates the border around the screen that moves the camera when cursor is near it
  1797 // this generates the border around the screen that moves the camera when cursor is near it
  1805 if isCursorVisible or ((FollowGear <> nil) and autoCameraOn) then
  1798 if (CurrentTeam^.ExtDriven and isCursorVisible and autoCameraOn) or
       
  1799    (not CurrentTeam^.ExtDriven and isCursorVisible) or ((FollowGear <> nil) and autoCameraOn) then
  1806     begin
  1800     begin
  1807     if CursorPoint.X < - cScreenWidth div 2 + EdgesDist then
  1801     if CursorPoint.X < - cScreenWidth div 2 + EdgesDist then
  1808         begin
  1802         begin
  1809         WorldDx:= WorldDx - CursorPoint.X - cScreenWidth div 2 + EdgesDist;
  1803         WorldDx:= WorldDx - CursorPoint.X - cScreenWidth div 2 + EdgesDist;
  1810         CursorPoint.X:= - cScreenWidth div 2 + EdgesDist
  1804         CursorPoint.X:= - cScreenWidth div 2 + EdgesDist