hedgewars/uWorld.pas
changeset 10360 c243b6a8ad9a
parent 10359 744f1151c707
child 10392 5012e1f9e893
equal deleted inserted replaced
10359:744f1151c707 10360:c243b6a8ad9a
  1002 {$ENDIF}
  1002 {$ENDIF}
  1003 end;
  1003 end;
  1004 
  1004 
  1005 procedure RenderWorldEdge(Lag: Longword);
  1005 procedure RenderWorldEdge(Lag: Longword);
  1006 var
  1006 var
  1007     VertexBuffer: array [0..3] of TVertex2f;
  1007     //VertexBuffer: array [0..3] of TVertex2f;
  1008     c1, c2: LongWord; // couple of colours for edges
  1008     tmp, w: LongInt;
       
  1009     rect: TSDL_Rect;
       
  1010     //c1, c2: LongWord; // couple of colours for edges
  1009 begin
  1011 begin
  1010 if (WorldEdge <> weNone) and (WorldEdge <> weSea) then
  1012 if (WorldEdge <> weNone) and (WorldEdge <> weSea) then
  1011     begin
  1013     begin
  1012 (* 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. *)
  1014 (* 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. *)
  1013 
  1015 
       
  1016     rect.y:= ViewTopY;
       
  1017     rect.h:= ViewHeight;
       
  1018     tmp:= leftX + WorldDx;
       
  1019     w:= tmp - ViewLeftX;
       
  1020 
       
  1021     if w > 0 then
       
  1022         begin
       
  1023         rect.w:= w;
       
  1024         rect.x:= ViewLeftX;
       
  1025         DrawRect(rect, $30, $30, $30, $40, true);
       
  1026         if WorldEdge = weBounce then
       
  1027             DrawLineOnScreen(tmp - 1, ViewTopY, tmp - 1, ViewBottomY, 2, $54, $54, $FF, $FF);
       
  1028         end;
       
  1029 
       
  1030     tmp:= rightX + WorldDx;
       
  1031     w:= ViewRightX - tmp;
       
  1032 
       
  1033     if w > 0 then
       
  1034         begin
       
  1035         rect.w:= w;
       
  1036         rect.x:= tmp;
       
  1037         DrawRect(rect, $30, $30, $30, $40, true);
       
  1038         if WorldEdge = weBounce then
       
  1039             DrawLineOnScreen(tmp - 1, ViewTopY, tmp - 1, ViewBottomY, 2, $54, $54, $FF, $FF);
       
  1040         end;
       
  1041 
       
  1042     (*
  1014     glDisable(GL_TEXTURE_2D);
  1043     glDisable(GL_TEXTURE_2D);
  1015     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  1044     glDisableClientState(GL_TEXTURE_COORD_ARRAY);
  1016     if WorldEdge = weWrap then
  1045     if (WorldEdge = weWrap) or (worldEdge = weBounce) then
  1017         glColor4ub($00, $00, $00, $40)
  1046         glColor4ub($00, $00, $00, $40)
  1018     else
  1047     else
  1019         begin
  1048         begin
  1020         glEnableClientState(GL_COLOR_ARRAY);
  1049         glEnableClientState(GL_COLOR_ARRAY);
  1021         glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WorldFade[0]);
  1050         glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WorldFade[0]);
  1096         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 3.0, c1);
  1125         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 3.0, c1);
  1097         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 1.0, c2)
  1126         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 1.0, c2)
  1098         end
  1127         end
  1099     else if WorldEdge = weWrap then
  1128     else if WorldEdge = weWrap then
  1100         begin
  1129         begin
  1101         {DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 5.0, $A0, $30, $60, max(50,255-LeftImpactTimer));
  1130         DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 5.0, $A0, $30, $60, max(50,255-LeftImpactTimer));
  1102         DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 2.0, $FF0000FF);
  1131         DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 2.0, $FF0000FF);
  1103         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 5.0, $A0, $30, $60, max(50,255-RightImpactTimer));
  1132         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 5.0, $A0, $30, $60, max(50,255-RightImpactTimer));
  1104         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 2.0, $FF0000FF);}
  1133         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 2.0, $FF0000FF);
  1105         end
  1134         end
  1106     else
  1135     else
  1107         begin
  1136         begin
  1108         DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 5.0, $2E8B5780);
  1137         DrawLine(leftX, -3000, leftX, cWaterLine+cVisibleWater, 5.0, $2E8B5780);
  1109         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 5.0, $2E8B5780)
  1138         DrawLine(rightX, -3000, rightX, cWaterLine+cVisibleWater, 5.0, $2E8B5780)
  1110         end;
  1139         end;
  1111     if LeftImpactTimer > Lag then dec(LeftImpactTimer,Lag) else LeftImpactTimer:= 0;
  1140     if LeftImpactTimer > Lag then dec(LeftImpactTimer,Lag) else LeftImpactTimer:= 0;
  1112     if RightImpactTimer > Lag then dec(RightImpactTimer,Lag) else RightImpactTimer:= 0
  1141     if RightImpactTimer > Lag then dec(RightImpactTimer,Lag) else RightImpactTimer:= 0
       
  1142     *)
  1113     end;
  1143     end;
  1114 end;
  1144 end;
  1115 
  1145 
  1116 
  1146 
  1117 procedure RenderTeamsHealth;
  1147 procedure RenderTeamsHealth;
  1231         untint;
  1261         untint;
  1232     end;
  1262     end;
  1233 end;
  1263 end;
  1234 
  1264 
  1235 
  1265 
       
  1266 var preShiftWorldDx: LongInt;
       
  1267 
       
  1268 procedure ShiftWorld(Dir: LongInt; Flip: Boolean);
       
  1269 begin
       
  1270     preShiftWorldDx:= WorldDx;
       
  1271 
       
  1272     if Flip then
       
  1273         begin
       
  1274         WorldDx:= -WorldDx - playWidth - Dir * playWidth;
       
  1275         openglPushMatrix();
       
  1276         openglScalef(-1, 1, 1);
       
  1277         end
       
  1278     else
       
  1279         WorldDx:= WorldDx + Dir * playWidth;
       
  1280 
       
  1281 end;
       
  1282 
       
  1283 procedure UnshiftWorld(Dir: LongInt; Flip: Boolean);
       
  1284 begin
       
  1285     WorldDx:= preShiftWorldDx;
       
  1286 
       
  1287     if Flip then
       
  1288         openglPopMatrix();
       
  1289 
       
  1290 end;
       
  1291 
  1236 procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode);
  1292 procedure DrawWorldStereo(Lag: LongInt; RM: TRenderMode);
  1237 var i, t: LongInt;
  1293 var i, t: LongInt;
  1238     r: TSDL_Rect;
  1294     r: TSDL_Rect;
  1239     tdx, tdy: Double;
  1295     tdx, tdy: Double;
  1240     s: shortstring;
  1296     s: shortstring;
  1241     offsetX, offsetY, screenBottom: LongInt;
  1297     offsetX, offsetY, screenBottom: LongInt;
  1242     VertexBuffer: array [0..3] of TVertex2f;
  1298     VertexBuffer: array [0..3] of TVertex2f;
  1243     replicateToLeft, replicateToRight, tmp: boolean;
  1299     replicateToLeft, replicateToRight, tmp, flip: boolean;
  1244 begin
  1300 begin
  1245 if WorldEdge <> weWrap then
  1301 if (WorldEdge <> weWrap) {and (WorldEdge <> weBounce)} then
  1246 begin
  1302     begin
  1247 replicateToLeft := false;
  1303     replicateToLeft := false;
  1248 replicateToRight:= false;
  1304     replicateToRight:= false;
  1249 end
  1305     flip:= false;
       
  1306     end
  1250 else
  1307 else
  1251 begin
  1308     begin
  1252 replicateToLeft := (leftX  + WorldDx > ViewLeftX);
  1309     replicateToLeft := (leftX  + WorldDx > ViewLeftX);
  1253 replicateToRight:= (rightX + WorldDx < ViewRightX);
  1310     replicateToRight:= (rightX + WorldDx < ViewRightX);
  1254 end;
  1311     flip:= (WorldEdge = weBounce);
       
  1312     end;
  1255 
  1313 
  1256 ScreenBottom:= (WorldDy - trunc(cScreenHeight/cScaleFactor) - (cScreenHeight div 2) + cWaterLine);
  1314 ScreenBottom:= (WorldDy - trunc(cScreenHeight/cScaleFactor) - (cScreenHeight div 2) + cWaterLine);
  1257 
  1315 
  1258 // note: offsetY is negative!
  1316 // note: offsetY is negative!
  1259 offsetY:= 10 *  Min(0, -145 - ScreenBottom); // TODO limit this in the other direction too
  1317 offsetY:= 10 *  Min(0, -145 - ScreenBottom); // TODO limit this in the other direction too
  1300     changeDepth(RM, cStereo_Land);
  1358     changeDepth(RM, cStereo_Land);
  1301     DrawVisualGears(5);
  1359     DrawVisualGears(5);
  1302     DrawLand(WorldDx, WorldDy);
  1360     DrawLand(WorldDx, WorldDy);
  1303 
  1361 
  1304     if replicateToLeft then
  1362     if replicateToLeft then
  1305         DrawLand(WorldDx - playWidth, WorldDy);
  1363         begin
       
  1364         ShiftWorld(-1, flip);
       
  1365         DrawLand(WorldDx, WorldDy);
       
  1366         UnshiftWorld(-1, flip);
       
  1367         end;
  1306 
  1368 
  1307     if replicateToRight then
  1369     if replicateToRight then
  1308         DrawLand(WorldDx + playWidth, WorldDy);
  1370         begin
       
  1371         ShiftWorld(1, flip);
       
  1372         DrawLand(WorldDx, WorldDy);
       
  1373         UnshiftWorld(1, flip);
       
  1374         end;
  1309 
  1375 
  1310     DrawWater(255, 0, 0);
  1376     DrawWater(255, 0, 0);
  1311 
  1377 
  1312 (*
  1378 (*
  1313 // Attack bar
  1379 // Attack bar
  1336 tmp:= bShowFinger;
  1402 tmp:= bShowFinger;
  1337 bShowFinger:= false;
  1403 bShowFinger:= false;
  1338 
  1404 
  1339 if replicateToLeft then
  1405 if replicateToLeft then
  1340     begin
  1406     begin
  1341     // remember original value
  1407     ShiftWorld(-1, flip);
  1342     i:= WorldDx;
       
  1343     WorldDx:= i - playWidth;
       
  1344     DrawVisualGears(1);
  1408     DrawVisualGears(1);
  1345     DrawGears();
  1409     DrawGears();
  1346     DrawVisualGears(6);
  1410     DrawVisualGears(6);
  1347     // reset to original value
  1411     UnshiftWorld(-1, flip);
  1348     WorldDx:= i;
       
  1349     end;
  1412     end;
  1350 
  1413 
  1351 if replicateToRight then
  1414 if replicateToRight then
  1352     begin
  1415     begin
  1353     // remember original value
  1416     ShiftWorld(1, flip);
  1354     i:= WorldDx;
       
  1355     WorldDx:= i + playWidth;
       
  1356     DrawVisualGears(1);
  1417     DrawVisualGears(1);
  1357     DrawGears();
  1418     DrawGears();
  1358     DrawVisualGears(6);
  1419     DrawVisualGears(6);
  1359     // reset to original value
  1420     UnshiftWorld(1, flip);
  1360     WorldDx:= i;
       
  1361     end;
  1421     end;
  1362 
  1422 
  1363 bShowFinger:= tmp;
  1423 bShowFinger:= tmp;
  1364 
  1424 
  1365 DrawVisualGears(1);
  1425 DrawVisualGears(1);
  1401 // note: negative parallax gears should last very little for a smooth stereo effect
  1461 // note: negative parallax gears should last very little for a smooth stereo effect
  1402     ChangeDepth(RM, cStereo_Outside);
  1462     ChangeDepth(RM, cStereo_Outside);
  1403 
  1463 
  1404     if replicateToLeft then
  1464     if replicateToLeft then
  1405         begin
  1465         begin
  1406         // remember original value
  1466         ShiftWorld(-1, flip);
  1407         i:= WorldDx;
       
  1408         WorldDx:= i - playWidth;
       
  1409         DrawVisualGears(2);
  1467         DrawVisualGears(2);
  1410         // reset to original value
  1468         UnshiftWorld(-1, flip);
  1411         WorldDx:= i;
       
  1412         end;
  1469         end;
  1413 
  1470 
  1414     if replicateToRight then
  1471     if replicateToRight then
  1415         begin
  1472         begin
  1416         // remember original value
  1473         ShiftWorld(1, flip);
  1417         i:= WorldDx;
       
  1418         WorldDx:= i + playWidth;
       
  1419         DrawVisualGears(2);
  1474         DrawVisualGears(2);
  1420         // reset to original value
  1475         UnshiftWorld(1, flip);
  1421         WorldDx:= i;
       
  1422         end;
  1476         end;
  1423 
  1477 
  1424     DrawVisualGears(2);
  1478     DrawVisualGears(2);
  1425 
  1479 
  1426 // everything after this ResetDepth will be drawn at screen level (depth = 0)
  1480 // everything after this ResetDepth will be drawn at screen level (depth = 0)
  1427 // note: everything that needs to be readable should be on this level
  1481 // note: everything that needs to be readable should be on this level
  1428     ResetDepth(RM);
  1482     ResetDepth(RM);
  1429 
  1483 
  1430     if replicateToLeft then
  1484     if replicateToLeft then
  1431         begin
  1485         begin
  1432         // remember original value
  1486         ShiftWorld(-1, flip);
  1433         i:= WorldDx;
       
  1434         WorldDx:= i - playWidth;
       
  1435         DrawVisualGears(3);
  1487         DrawVisualGears(3);
  1436         // reset to original value
  1488         UnshiftWorld(-1, flip);
  1437         WorldDx:= i;
       
  1438         end;
  1489         end;
  1439 
  1490 
  1440     if replicateToRight then
  1491     if replicateToRight then
  1441         begin
  1492         begin
  1442         // remember original value
  1493         ShiftWorld(1, flip);
  1443         i:= WorldDx;
       
  1444         WorldDx:= i + playWidth;
       
  1445         DrawVisualGears(3);
  1494         DrawVisualGears(3);
  1446         // reset to original value
  1495         UnshiftWorld(1, flip);
  1447         WorldDx:= i;
       
  1448         end;
  1496         end;
  1449 
  1497 
  1450     DrawVisualGears(3);
  1498     DrawVisualGears(3);
  1451 
  1499 
  1452 {$WARNINGS OFF}
  1500 {$WARNINGS OFF}