hedgewars/uGears.pas
changeset 2852 c6dff591f564
parent 2844 cea15ef417ea
child 2860 13a53315ae18
--- a/hedgewars/uGears.pas	Tue Feb 23 03:57:27 2010 +0000
+++ b/hedgewars/uGears.pas	Tue Feb 23 15:41:37 2010 +0000
@@ -847,8 +847,10 @@
 	hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
 	lx, ly, dx, dy, ax, ay, aAngle, dAngle, hAngle: real;  // laser, change
 	defaultPos, HatVisible: boolean;
-    VertexBuffer: array [0..1] of TVertex2f;
+	VertexBuffer: array [0..1] of TVertex2f;
+	stepSounds: boolean;
 begin
+
 if PHedgehog(Gear^.Hedgehog)^.Unplaced then exit;
 m:= 1;
 if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1;
@@ -860,6 +862,7 @@
 
 defaultPos:= true;
 HatVisible:= false;
+stepSounds:= false;
 
 sx:= hwRound(Gear^.X) + 1 + WorldDx;
 sy:= hwRound(Gear^.Y) - 3 + WorldDy;
@@ -1025,6 +1028,7 @@
 						3,
 						PHedgehog(Gear^.Hedgehog)^.visStepPos div 2,
 						0);
+				stepSounds:= true;
 				defaultPos:= false
 				end;
 			gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180);
@@ -1121,6 +1125,7 @@
 			0,
 			PHedgehog(Gear^.Hedgehog)^.visStepPos div 2,
 			0);
+		stepSounds:= true;
 		defaultPos:= false;
 		HatVisible:= true
 		end
@@ -1363,6 +1368,14 @@
     DrawSprite(sprVampiric, sx - 24, sy - 24, 0);
 	glColor4f(1, 1, 1, 1);
     end;
+	
+	if stepSounds and (Gear^.SoundChannel < 0) then
+		Gear^.SoundChannel:= LoopSound(sndSteps)
+	else if not stepSounds and (Gear^.SoundChannel > -1) then
+		begin
+		StopSound(Gear^.SoundChannel);
+		Gear^.SoundChannel:= -1;
+		end;
 end;
 
 procedure DrawRopeLinesRQ(Gear: PGear);