hedgewars/uWorld.pas
branchexperimental3D
changeset 4816 c2575faeac3d
parent 4812 f924be23ffb4
child 4818 202eef454354
equal deleted inserted replaced
4814:e19791f08443 4816:c2575faeac3d
    64     amSel: TAmmoType = amNothing;
    64     amSel: TAmmoType = amNothing;
    65     missionTex: PTexture;
    65     missionTex: PTexture;
    66     missionTimer: LongInt;
    66     missionTimer: LongInt;
    67     stereoDepth: GLfloat = 0;
    67     stereoDepth: GLfloat = 0;
    68 
    68 
    69 const cStereo_Sky     = 0.0500;
    69 const cStereo_Sky           = 0.0500;
    70       cStereo_Horizon = 0.0250;
    70       cStereo_Horizon       = 0.0250;
    71       cStereo_Water   = 0.0125;
    71       cStereo_Water_distant = 0.0125;
       
    72       cStereo_Land          = 0.0075;
       
    73       cStereo_Water_near    = 0.0025;
    72 
    74 
    73 procedure InitWorld;
    75 procedure InitWorld;
    74 var i, t: LongInt;
    76 var i, t: LongInt;
    75     cp: PClan;
    77     cp: PClan;
    76     g: ansistring;
    78     g: ansistring;
   764 
   766 
   765     if (cReducedQuality and rq2DWater) = 0 then
   767     if (cReducedQuality and rq2DWater) = 0 then
   766     begin
   768     begin
   767         // Waves
   769         // Waves
   768         DrawWater(255, SkyOffset); 
   770         DrawWater(255, SkyOffset); 
   769         ChangeDepth(RM, -cStereo_Water);
   771         ChangeDepth(RM, -cStereo_Water_distant);
   770         DrawWaves( 1,  0 - WorldDx div 32, - cWaveHeight + offsetY div 35, 64);
   772         DrawWaves( 1,  0 - WorldDx div 32, - cWaveHeight + offsetY div 35, 64);
   771         ChangeDepth(RM, -cStereo_Water);
   773         ChangeDepth(RM, -cStereo_Water_distant);
   772         DrawWaves( -1,  25 + WorldDx div 25, - cWaveHeight + offsetY div 38, 48);
   774         DrawWaves( -1,  25 + WorldDx div 25, - cWaveHeight + offsetY div 38, 48);
   773         ChangeDepth(RM, -cStereo_Water);
   775         ChangeDepth(RM, -cStereo_Water_distant);
   774         DrawWaves( 1,  75 - WorldDx div 19, - cWaveHeight + offsetY div 45, 32);
   776         DrawWaves( 1,  75 - WorldDx div 19, - cWaveHeight + offsetY div 45, 32);
   775         ChangeDepth(RM, -cStereo_Water);
   777         ChangeDepth(RM, -cStereo_Water_distant);
   776         DrawWaves(-1, 100 + WorldDx div 14, - cWaveHeight + offsetY div 70, 24);
   778         DrawWaves(-1, 100 + WorldDx div 14, - cWaveHeight + offsetY div 70, 24);
   777         ResetDepth(RM);
       
   778     end
   779     end
   779     else
   780     else
   780         DrawWaves(-1, 100, - (cWaveHeight + (cWaveHeight shr 1)), 0);
   781         DrawWaves(-1, 100, - (cWaveHeight + (cWaveHeight shr 1)), 0);
   781 
   782 
       
   783     changeDepth(RM, cStereo_Land);
   782     DrawLand(WorldDx, WorldDy);
   784     DrawLand(WorldDx, WorldDy);
   783 
   785 
   784     DrawWater(255, 0);
   786     DrawWater(255, 0);
   785 
   787 
   786 // Attack bar
   788 // Attack bar
   807 
   809 
   808     DrawVisualGears(1);
   810     DrawVisualGears(1);
   809 
   811 
   810     DrawGears;
   812     DrawGears;
   811 
   813 
   812     DrawVisualGears(2);
       
   813 
       
   814     if SuddenDeathDmg then
   814     if SuddenDeathDmg then
   815         DrawWater(cSDWaterOpacity, 0)
   815         DrawWater(cSDWaterOpacity, 0)
   816     else
   816     else
   817         DrawWater(cWaterOpacity, 0);
   817         DrawWater(cWaterOpacity, 0);
   818 
   818 
   819     // Waves
   819     // Waves
   820     ChangeDepth(RM, cStereo_Water);
   820     ChangeDepth(RM, cStereo_Water_near);
   821     DrawWaves( 1, 25 - WorldDx div 9, - cWaveHeight, 12);
   821     DrawWaves( 1, 25 - WorldDx div 9, - cWaveHeight, 12);
   822 
   822 
   823     if (cReducedQuality and rq2DWater) = 0 then
   823     if (cReducedQuality and rq2DWater) = 0 then
   824     begin
   824     begin
   825         //DrawWater(cWaterOpacity, - offsetY div 40);
   825         //DrawWater(cWaterOpacity, - offsetY div 40);
   826         ChangeDepth(RM, cStereo_Water);
   826         ChangeDepth(RM, cStereo_Water_near);
   827         DrawWaves(-1, 50 + WorldDx div 6, - cWaveHeight - offsetY div 40, 8);
   827         DrawWaves(-1, 50 + WorldDx div 6, - cWaveHeight - offsetY div 40, 8);
   828         if SuddenDeathDmg then
   828         if SuddenDeathDmg then
   829             DrawWater(cSDWaterOpacity, - offsetY div 20)
   829             DrawWater(cSDWaterOpacity, - offsetY div 20)
   830         else
   830         else
   831             DrawWater(cWaterOpacity, - offsetY div 20);
   831             DrawWater(cWaterOpacity, - offsetY div 20);
   832         ChangeDepth(RM, cStereo_Water);
   832         ChangeDepth(RM, cStereo_Water_near);
   833         DrawWaves( 1, 75 - WorldDx div 4, - cWaveHeight - offsetY div 20, 2);
   833         DrawWaves( 1, 75 - WorldDx div 4, - cWaveHeight - offsetY div 20, 2);
   834         if SuddenDeathDmg then
   834         if SuddenDeathDmg then
   835             DrawWater(cSDWaterOpacity, - offsetY div 10)
   835             DrawWater(cSDWaterOpacity, - offsetY div 10)
   836         else
   836         else
   837             DrawWater(cWaterOpacity, - offsetY div 10);
   837             DrawWater(cWaterOpacity, - offsetY div 10);
   838         ChangeDepth(RM, cStereo_Water);
   838         ChangeDepth(RM, cStereo_Water_near);
   839         DrawWaves( -1, 25 + WorldDx div 3, - cWaveHeight - offsetY div 10, 0);
   839         DrawWaves( -1, 25 + WorldDx div 3, - cWaveHeight - offsetY div 10, 0);
   840         ResetDepth(RM);
       
   841     end
   840     end
   842     else
   841     else
   843         DrawWaves(-1, 50, - (cWaveHeight shr 1), 0);
   842         DrawWaves(-1, 50, - (cWaveHeight shr 1), 0);
   844 
   843 
       
   844 // everything after this ChangeDepth will be drawn outside the screen
       
   845     ChangeDepth(RM, 0.045);
       
   846     DrawVisualGears(2);
       
   847 
       
   848 // everything after this ResetDepth will be drawn at screen level (depth = 0)
       
   849     ResetDepth(RM);
   845 
   850 
   846 {$WARNINGS OFF}
   851 {$WARNINGS OFF}
   847 // Target
   852 // Target
   848 if (TargetPoint.X <> NoPointX) and (CurrentTeam <> nil) and (CurrentHedgehog <> nil) then
   853 if (TargetPoint.X <> NoPointX) and (CurrentTeam <> nil) and (CurrentHedgehog <> nil) then
   849     begin
   854     begin
   857     end;
   862     end;
   858 {$WARNINGS ON}
   863 {$WARNINGS ON}
   859 
   864 
   860 // this scale is used to keep the various widgets at the same dimension at all zoom levels
   865 // this scale is used to keep the various widgets at the same dimension at all zoom levels
   861 SetScale(cDefaultZoomLevel);
   866 SetScale(cDefaultZoomLevel);
   862 
       
   863 
   867 
   864 // Turn time
   868 // Turn time
   865 {$IFDEF IPHONEOS}
   869 {$IFDEF IPHONEOS}
   866 offsetX:= cScreenHeight - 13;
   870 offsetX:= cScreenHeight - 13;
   867 {$ELSE}
   871 {$ELSE}
   911       r.y:= 0;
   915       r.y:= 0;
   912       r.w:= 2 + TeamHealthBarWidth;
   916       r.w:= 2 + TeamHealthBarWidth;
   913       r.h:= HealthTex^.h;
   917       r.h:= HealthTex^.h;
   914       DrawFromRect(14, cScreenHeight + DrawHealthY, @r, HealthTex);
   918       DrawFromRect(14, cScreenHeight + DrawHealthY, @r, HealthTex);
   915 
   919 
   916       // draw health bar's right border
   920       // draw health bars right border
   917       inc(r.x, cTeamHealthWidth + 2);
   921       inc(r.x, cTeamHealthWidth + 2);
   918       r.w:= 3;
   922       r.w:= 3;
   919       DrawFromRect(TeamHealthBarWidth + 16, cScreenHeight + DrawHealthY, @r, HealthTex);
   923       DrawFromRect(TeamHealthBarWidth + 16, cScreenHeight + DrawHealthY, @r, HealthTex);
   920 
   924 
   921       // draw ai kill counter for gfAISurvival
   925       // draw ai kill counter for gfAISurvival
   986 
   990 
   987 // Cursor
   991 // Cursor
   988 if isCursorVisible and bShowAmmoMenu then
   992 if isCursorVisible and bShowAmmoMenu then
   989    DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8);
   993    DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8);
   990 
   994 
       
   995 // Chat
   991 DrawChat;
   996 DrawChat;
   992 
   997 
       
   998 // confirmation caption
   993 if fastUntilLag then DrawCentered(0, (cScreenHeight shr 1), SyncTexture);
   999 if fastUntilLag then DrawCentered(0, (cScreenHeight shr 1), SyncTexture);
   994 if isPaused then DrawCentered(0, (cScreenHeight shr 1), PauseTexture);
  1000 if isPaused then DrawCentered(0, (cScreenHeight shr 1), PauseTexture);
   995 if not isFirstFrame and (missionTimer <> 0) or isPaused or fastUntilLag or (GameState = gsConfirm) then
  1001 if not isFirstFrame and (missionTimer <> 0) or isPaused or fastUntilLag or (GameState = gsConfirm) then
   996     begin
  1002     begin
   997     if (ReadyTimeLeft = 0) and (missionTimer > 0) then dec(missionTimer, Lag);
  1003     if (ReadyTimeLeft = 0) and (missionTimer > 0) then dec(missionTimer, Lag);