hedgewars/uGearsHandlersMess.pas
changeset 13346 0c3f612edc19
parent 13328 15d804dcd736
child 13362 030b085b182f
equal deleted inserted replaced
13345:85644a45e988 13346:0c3f612edc19
  1214 end;
  1214 end;
  1215 
  1215 
  1216 ////////////////////////////////////////////////////////////////////////////////
  1216 ////////////////////////////////////////////////////////////////////////////////
  1217 procedure spawnBulletTrail(Bullet: PGear; bulletX, bulletY: hwFloat; fadeIn: Boolean);
  1217 procedure spawnBulletTrail(Bullet: PGear; bulletX, bulletY: hwFloat; fadeIn: Boolean);
  1218 var oX, oY: hwFloat;
  1218 var oX, oY: hwFloat;
  1219     fromX, fromY, toX, toY, dX, dY, length, stepLength: real;
  1219     fromX, fromY, toX, toY, dX, dY, bLength, stepLength: real;
  1220     VGear: PVisualGear;
  1220     VGear: PVisualGear;
  1221     i, steps: LongWord;
  1221     i, steps: LongWord;
  1222 begin
  1222 begin
  1223     if Bullet^.PortalCounter = 0 then
  1223     if Bullet^.PortalCounter = 0 then
  1224         begin
  1224         begin
  1236     toX:= hwFloat2Float(bulletX);
  1236     toX:= hwFloat2Float(bulletX);
  1237     toY:= hwFloat2Float(bulletY);
  1237     toY:= hwFloat2Float(bulletY);
  1238 
  1238 
  1239     dX:= toX - fromX;
  1239     dX:= toX - fromX;
  1240     dY:= toY - fromY;
  1240     dY:= toY - fromY;
  1241     length:= sqrt(dX * dX + dY * dY);
  1241     bLength:= sqrt(dX * dX + dY * dY);
  1242     dX:= dX / length;
  1242     dX:= dX / bLength;
  1243     dY:= dY / length;
  1243     dY:= dY / bLength;
  1244 
  1244 
  1245     if fadeIn then
  1245     if fadeIn then
  1246         begin
  1246         begin
  1247         steps:= 10;
  1247         steps:= 10;
  1248         stepLength:= 12;
  1248         stepLength:= 12;
  1249         fromX:= fromX + dX * 45;
  1249         fromX:= fromX + dX * 45;
  1250         fromY:= fromY + dY * 45;
  1250         fromY:= fromY + dY * 45;
  1251         length:= length - 45;
  1251         bLength:= bLength - 45;
  1252         end
  1252         end
  1253     else steps:= 1;
  1253     else steps:= 1;
  1254 
  1254 
  1255     for i:= 0 to steps - 1 do
  1255     for i:= 0 to steps - 1 do
  1256         begin
  1256         begin
  1257             if i < steps - 1 then
  1257             if i < steps - 1 then
  1258                 begin
  1258                 begin
  1259                 toX:= fromX + dX * minD(stepLength, length);
  1259                 toX:= fromX + dX * minD(stepLength, bLength);
  1260                 toY:= fromY + dY * minD(stepLength, length);
  1260                 toY:= fromY + dY * minD(stepLength, bLength);
  1261                 end
  1261                 end
  1262             else if steps > 1 then
  1262             else if steps > 1 then
  1263                 begin
  1263                 begin
  1264                 toX:= fromX + dX * length;
  1264                 toX:= fromX + dX * bLength;
  1265                 toY:= fromY + dY * length;
  1265                 toY:= fromY + dY * bLength;
  1266                 end;
  1266                 end;
  1267 
  1267 
  1268             if length > 0 then
  1268             if bLength > 0 then
  1269                 begin
  1269                 begin
  1270                 VGear := AddVisualGear(round(fromX), round(fromY), vgtLineTrail);
  1270                 VGear := AddVisualGear(round(fromX), round(fromY), vgtLineTrail);
  1271                 if VGear <> nil then
  1271                 if VGear <> nil then
  1272                     begin
  1272                     begin
  1273                     VGear^.X:= fromX;
  1273                     VGear^.X:= fromX;
  1291 
  1291 
  1292             if i < steps - 1 then
  1292             if i < steps - 1 then
  1293                 begin
  1293                 begin
  1294                 fromX:= toX;
  1294                 fromX:= toX;
  1295                 fromY:= toY;
  1295                 fromY:= toY;
  1296                 length:= length - stepLength;
  1296                 bLength:= bLength - stepLength;
  1297                 end
  1297                 end
  1298         end;
  1298         end;
  1299 end;
  1299 end;
  1300 
  1300 
  1301 procedure LineShoveHelp(Gear: PGear; oX, oY, tX, tY, dX, dY: hwFloat; count: LongWord);
  1301 procedure LineShoveHelp(Gear: PGear; oX, oY, tX, tY, dX, dY: hwFloat; count: LongWord);