# HG changeset patch # User unc0rr # Date 1417379782 -10800 # Node ID 9a9f0cbb10b242c9cf625eba885350731f75626f # Parent 3c649bf438a3ea6549dff301346dc9f2c5998ae3 Limit fire particles speed to 2 diff -r 3c649bf438a3 -r 9a9f0cbb10b2 hedgewars/uGearsHandlersMess.pas --- a/hedgewars/uGearsHandlersMess.pas Sun Nov 30 21:32:24 2014 +0100 +++ b/hedgewars/uGearsHandlersMess.pas Sun Nov 30 23:36:22 2014 +0300 @@ -2127,7 +2127,7 @@ gX,gY,i: LongInt; sticky: Boolean; vgt: PVisualGear; - tdX,tdY: HWFloat; + tdX,tdY, f: HWFloat; landPixel: Word; begin WorldWrap(Gear); @@ -2166,19 +2166,30 @@ end; end; - - if Gear^.dX.QWordValue > _0_01.QWordValue then - Gear^.dX := Gear^.dX * _0_995; - - Gear^.dY := Gear^.dY + cGravity; - // if sticky then Gear^.dY := Gear^.dY + cGravity; - - if Gear^.dY.QWordValue > _0_2.QWordValue then - Gear^.dY := Gear^.dY * _0_995; - - //if sticky then Gear^.X := Gear^.X + Gear^.dX else - Gear^.X := Gear^.X + Gear^.dX + cWindSpeed * 640; - Gear^.Y := Gear^.Y + Gear^.dY; + if (Gear^.dX.QWordValue > _2.QWordValue) + or (Gear^.dY.QWordValue > _2.QWordValue) + then + begin + // norm speed vector to length of 2 for fire particles to keep flying in the same direction + f:= _2 / Distance(Gear^.dX, Gear^.dY); + Gear^.dX:= Gear^.dX * f; + Gear^.dY:= Gear^.dY * f; + end + else begin + if Gear^.dX.QWordValue > _0_01.QWordValue then + if Gear^.dX.QWordValue > _2.QWordValue then + Gear^.dX := Gear^.dX * _0_995; + + Gear^.dY := Gear^.dY + cGravity; + // if sticky then Gear^.dY := Gear^.dY + cGravity; + + if Gear^.dY.QWordValue > _0_2.QWordValue then + Gear^.dY := Gear^.dY * _0_995; + + //if sticky then Gear^.X := Gear^.X + Gear^.dX else + Gear^.X := Gear^.X + Gear^.dX + cWindSpeed * 640; + Gear^.Y := Gear^.Y + Gear^.dY; + end; gX := hwRound(Gear^.X); gY := hwRound(Gear^.Y);