hedgewars/uWorld.pas
changeset 9557 a5005b7ca305
parent 9485 3dee8a3b0406
child 9654 47332746e6d9
equal deleted inserted replaced
9555:485b424be769 9557:a5005b7ca305
    83     AMAnimType: LongInt;
    83     AMAnimType: LongInt;
    84     recTexture: PTexture;
    84     recTexture: PTexture;
    85     AmmoMenuTex     : PTexture;
    85     AmmoMenuTex     : PTexture;
    86     HorizontOffset: LongInt;
    86     HorizontOffset: LongInt;
    87     cOffsetY: LongInt;
    87     cOffsetY: LongInt;
       
    88     WorldEnd, WorldFade : array[0..3] of HwColor4f;
    88 
    89 
    89 const cStereo_Sky           = 0.0500;
    90 const cStereo_Sky           = 0.0500;
    90       cStereo_Horizon       = 0.0250;
    91       cStereo_Horizon       = 0.0250;
    91       cStereo_MidDistance   = 0.0175;
    92       cStereo_MidDistance   = 0.0175;
    92       cStereo_Water_distant = 0.0125;
    93       cStereo_Water_distant = 0.0125;
  1128     s: shortstring;
  1129     s: shortstring;
  1129     highlight: Boolean;
  1130     highlight: Boolean;
  1130     smallScreenOffset, offsetX, offsetY, screenBottom: LongInt;
  1131     smallScreenOffset, offsetX, offsetY, screenBottom: LongInt;
  1131     VertexBuffer: array [0..3] of TVertex2f;
  1132     VertexBuffer: array [0..3] of TVertex2f;
  1132     lw, lh: GLfloat;
  1133     lw, lh: GLfloat;
  1133     WorldEnd, WorldFade : array[0..3] of HwColor4f;
  1134     c1, c2: LongWord; // couple of colours for edges
  1134 begin
  1135 begin
  1135 if (cReducedQuality and rqNoBackground) = 0 then
  1136 if (cReducedQuality and rqNoBackground) = 0 then
  1136     begin
  1137     begin
  1137         // Offsets relative to camera - spare them to wimpier cpus, no bg or flakes for them anyway
  1138         // Offsets relative to camera - spare them to wimpier cpus, no bg or flakes for them anyway
  1138         ScreenBottom:= (WorldDy - trunc(cScreenHeight/cScaleFactor) - (cScreenHeight div 2) + cWaterLine);
  1139         ScreenBottom:= (WorldDy - trunc(cScreenHeight/cScaleFactor) - (cScreenHeight div 2) + cWaterLine);
  1239 
  1240 
  1240 if WorldEdge <> weNone then
  1241 if WorldEdge <> weNone then
  1241     begin
  1242     begin
  1242 (* I think for a bounded world, will fill the left and right areas with black or something. Also will probably want various border effects/animations based on border type.  Prob also, say, trigger a border animation timer on an impact. *)
  1243 (* I think for a bounded world, will fill the left and right areas with black or something. Also will probably want various border effects/animations based on border type.  Prob also, say, trigger a border animation timer on an impact. *)
  1243 
  1244 
  1244     FillChar(WorldFade, sizeof(WorldFade), 0);
       
  1245     WorldFade[0].a:= 255;
       
  1246     WorldFade[1].a:= 255;
       
  1247     FillChar(WorldEnd, sizeof(WorldEnd), 0);
       
  1248     WorldEnd[0].a:= 255;
       
  1249     WorldEnd[1].a:= 255;
       
  1250     WorldEnd[2].a:= 255;
       
  1251     WorldEnd[3].a:= 255;
       
  1252 
       
  1253     glDisable(GL_TEXTURE_2D);
  1245     glDisable(GL_TEXTURE_2D);
  1254     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  1246     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  1255     glEnableClientState(GL_COLOR_ARRAY);
  1247     glEnableClientState(GL_COLOR_ARRAY);
  1256 
  1248 
  1257     glPushMatrix;
  1249     glPushMatrix;
  1301     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  1293     glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  1302 
  1294 
  1303     glColor4ub($FF, $FF, $FF, $FF); // must not be Tint() as color array seems to stay active and color reset is required
  1295     glColor4ub($FF, $FF, $FF, $FF); // must not be Tint() as color array seems to stay active and color reset is required
  1304     glEnable(GL_TEXTURE_2D);
  1296     glEnable(GL_TEXTURE_2D);
  1305 
  1297 
  1306     DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 3.0, $FF, $00, $FF, $FF);
  1298     // I'd still like to have things happen to the border when a wrap or bounce just occurred, based on a timer 
  1307     DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 3.0, $FF, $00, $FF, $FF);
  1299     if WorldEdge = weBounce then
       
  1300         begin
       
  1301         // could maybe alternate order of these on a bounce, or maybe drop the outer ones.
       
  1302         if LeftImpactTimer mod 2 = 0 then
       
  1303             begin
       
  1304             c1:= $5454FFFF; c2:= $FFFFFFFF;
       
  1305             end
       
  1306         else begin
       
  1307             c1:= $FFFFFFFF; c2:= $5454FFFF;
       
  1308             end;
       
  1309         DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 7.0,   c1);
       
  1310         DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 5.0,   c2);
       
  1311         DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 3.0,   c1);
       
  1312         DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 1.0,   c2);
       
  1313         if RightImpactTimer mod 2 = 0 then
       
  1314             begin
       
  1315             c1:= $5454FFFF; c2:= $FFFFFFFF;
       
  1316             end
       
  1317         else begin
       
  1318             c1:= $FFFFFFFF; c2:= $5454FFFF;
       
  1319             end;
       
  1320         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 7.0, c1);
       
  1321         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 5.0, c2);
       
  1322         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 3.0, c1);
       
  1323         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 1.0, c2)
       
  1324         end
       
  1325     else if WorldEdge = weWrap then
       
  1326         begin
       
  1327         DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 5.0, $A0, $30, $60, max(50,255-LeftImpactTimer));
       
  1328         DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 2.0, $FF0000FF);
       
  1329         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 5.0, $A0, $30, $60, max(50,255-RightImpactTimer));
       
  1330         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 2.0, $FF0000FF);
       
  1331         end
       
  1332     else
       
  1333         begin
       
  1334         DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 5.0, $2E8B5780);
       
  1335         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 5.0, $2E8B5780)
       
  1336         end;
       
  1337     if LeftImpactTimer > Lag then dec(LeftImpactTimer,Lag) else LeftImpactTimer:= 0;
       
  1338     if RightImpactTimer > Lag then dec(RightImpactTimer,Lag) else RightImpactTimer:= 0
  1308     end;
  1339     end;
  1309 
  1340 
  1310 // this scale is used to keep the various widgets at the same dimension at all zoom levels
  1341 // this scale is used to keep the various widgets at the same dimension at all zoom levels
  1311 SetScale(cDefaultZoomLevel);
  1342 SetScale(cDefaultZoomLevel);
  1312 
  1343 
  1969     cOffsetY:= 0;
  2000     cOffsetY:= 0;
  1970     stereoDepth:= 0;
  2001     stereoDepth:= 0;
  1971     AMState:= AMHidden;
  2002     AMState:= AMHidden;
  1972     isFirstFrame:= true;
  2003     isFirstFrame:= true;
  1973     stereoDepth:= stereoDepth; // avoid hint
  2004     stereoDepth:= stereoDepth; // avoid hint
       
  2005 
       
  2006     FillChar(WorldFade, sizeof(WorldFade), 0);
       
  2007     WorldFade[0].a:= 255;
       
  2008     WorldFade[1].a:= 255;
       
  2009     FillChar(WorldEnd, sizeof(WorldEnd), 0);
       
  2010     WorldEnd[0].a:= 255;
       
  2011     WorldEnd[1].a:= 255;
       
  2012     WorldEnd[2].a:= 255;
       
  2013     WorldEnd[3].a:= 255;
       
  2014 
  1974 end;
  2015 end;
  1975 
  2016 
  1976 procedure freeModule;
  2017 procedure freeModule;
  1977 begin
  2018 begin
  1978     ResetWorldTex();
  2019     ResetWorldTex();