# HG changeset patch # User sheepluva # Date 1416156987 -3600 # Node ID 1a91c1fcba0d08c137d0c23e7dac9063ff2a21b9 # Parent ed5df9cd251f956d12d1406a4cb1907a3f966d51 add bounce effect to bouncy world edges diff -r ed5df9cd251f -r 1a91c1fcba0d hedgewars/uGearsHandlersMess.pas --- a/hedgewars/uGearsHandlersMess.pas Sun Nov 16 17:23:58 2014 +0100 +++ b/hedgewars/uGearsHandlersMess.pas Sun Nov 16 17:56:27 2014 +0100 @@ -310,7 +310,6 @@ tX, tdX, tdY: hwFloat; collV, collH, gX, gY: LongInt; land, xland: word; - boing: PVisualGear; begin tX:= Gear^.X; gX:= hwRound(Gear^.X); @@ -467,20 +466,7 @@ if ((xland or land) and lfBouncy <> 0) and (Gear^.Radius >= 3) and ((Gear^.dX.QWordValue > _0_15.QWordValue) or (Gear^.dY.QWordValue > _0_15.QWordValue)) then begin - boing:= AddVisualGear(gX, gY, vgtStraightShot, 0, false, 1); - if boing <> nil then - with boing^ do - begin - Angle:= random(360); - dx:= 0; - dy:= 0; - FrameTicks:= 200; - tX:= _0; - tX.QWordValue:= Gear^.dY.QWordValue + Gear^.dX.QWordValue; - Scale:= hwFloat2Float(Gear^.Density * tX) / 1.5; - State:= ord(sprBoing) - end; - PlaySound(sndMelonImpact, true) + AddBounceEffectForGear(Gear); end else if (Gear^.nImpactSounds > 0) and (Gear^.State and gstCollision <> 0) and diff -r ed5df9cd251f -r 1a91c1fcba0d hedgewars/uGearsUtils.pas --- a/hedgewars/uGearsUtils.pas Sun Nov 16 17:23:58 2014 +0100 +++ b/hedgewars/uGearsUtils.pas Sun Nov 16 17:56:27 2014 +0100 @@ -25,6 +25,7 @@ procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword); inline; procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord); procedure AddSplashForGear(Gear: PGear; justSkipping: boolean); +procedure AddBounceEffectForGear(Gear: PGear); function ModifyDamage(dmg: Longword; Gear: PGear): Longword; procedure ApplyDamage(Gear: PGear; AttackerHog: PHedgehog; Damage: Longword; Source: TDamageSource); @@ -1441,7 +1442,7 @@ Gear^.X:= int2hwfloat(rightX-Gear^.Radius) end; if (Gear^.Radius > 2) and (Gear^.dX.QWordValue > _0_001.QWordValue) then - PlaySound(sndMelonImpact) + AddBounceEffectForGear(Gear); end{ else if WorldEdge = weSea then begin @@ -1476,4 +1477,21 @@ end; end; +procedure AddBounceEffectForGear(Gear: PGear); +var boing: PVisualGear; +begin + boing:= AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtStraightShot, 0, false, 1); + if boing <> nil then + with boing^ do + begin + Angle:= random(360); + dx:= 0; + dy:= 0; + FrameTicks:= 200; + Scale:= hwFloat2Float(Gear^.Density * hwAbs(Gear^.dY) + hwAbs(Gear^.dX)) / 1.5; + State:= ord(sprBoing) + end; + PlaySound(sndMelonImpact, true) +end; + end.