hedgewars/uGears.pas
changeset 2940 c02119eee12a
parent 2938 451f917ac46c
child 2941 566f967ec22f
equal deleted inserted replaced
2939:58d811e0d41c 2940:c02119eee12a
    69     SpeechType: Longword;
    69     SpeechType: Longword;
    70     SpeechText: shortstring;
    70     SpeechText: shortstring;
    71     TrainingTargetGear: PGear;
    71     TrainingTargetGear: PGear;
    72     skipFlag: boolean;
    72     skipFlag: boolean;
    73     PlacingHogs: boolean; // a convenience flag to indicate placement of hogs is still in progress
    73     PlacingHogs: boolean; // a convenience flag to indicate placement of hogs is still in progress
       
    74     StepSoundTimer: LongInt;
       
    75     StepSoundChannel: LongInt;
    74     
    76     
    75 procedure init_uGears;
    77 procedure init_uGears;
    76 procedure free_uGears;
    78 procedure free_uGears;
    77 function  AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
    79 function  AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
    78 procedure ProcessGears;
    80 procedure ProcessGears;
   580 var Gear, t: PGear;
   582 var Gear, t: PGear;
   581 begin
   583 begin
   582 PrvInactive:= AllInactive;
   584 PrvInactive:= AllInactive;
   583 AllInactive:= true;
   585 AllInactive:= true;
   584 
   586 
       
   587 if (StepSoundTimer > 0) and (StepSoundChannel < 0) then
       
   588 	begin
       
   589 	WriteLnToConsole('playsteps ...');
       
   590 	StepSoundChannel:= LoopSound(sndSteps)
       
   591 	end
       
   592 else if (StepSoundTimer = 0) and (StepSoundChannel > -1) then
       
   593 	begin
       
   594 	WriteLnToConsole('stopsteps ...');
       
   595 	StopSound(StepSoundChannel);
       
   596 	StepSoundChannel:= -1;
       
   597 	end;
       
   598 
       
   599 if StepSoundTimer > 0 then
       
   600 	dec(StepSoundTimer, 1);
       
   601 
   585 t:= GearsList;
   602 t:= GearsList;
   586 while t <> nil do
   603 while t <> nil do
   587 	begin
   604 	begin
   588 	Gear:= t;
   605 	Gear:= t;
   589 	t:= Gear^.NextGear;
   606 	t:= Gear^.NextGear;
   854 	amt: TAmmoType;
   871 	amt: TAmmoType;
   855 	hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
   872 	hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
   856 	lx, ly, dx, dy, ax, ay, aAngle, dAngle, hAngle: real;  // laser, change
   873 	lx, ly, dx, dy, ax, ay, aAngle, dAngle, hAngle: real;  // laser, change
   857 	defaultPos, HatVisible: boolean;
   874 	defaultPos, HatVisible: boolean;
   858 	VertexBuffer: array [0..1] of TVertex2f;
   875 	VertexBuffer: array [0..1] of TVertex2f;
   859 	stepSounds: boolean;
       
   860 begin
   876 begin
   861 
   877 
   862 if PHedgehog(Gear^.Hedgehog)^.Unplaced then exit;
   878 if PHedgehog(Gear^.Hedgehog)^.Unplaced then exit;
   863 m:= 1;
   879 m:= 1;
   864 if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1;
   880 if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1;
   868 	exit
   884 	exit
   869 	end;
   885 	end;
   870 
   886 
   871 defaultPos:= true;
   887 defaultPos:= true;
   872 HatVisible:= false;
   888 HatVisible:= false;
   873 stepSounds:= false;
       
   874 
   889 
   875 sx:= hwRound(Gear^.X) + 1 + WorldDx;
   890 sx:= hwRound(Gear^.X) + 1 + WorldDx;
   876 sy:= hwRound(Gear^.Y) - 3 + WorldDy;
   891 sy:= hwRound(Gear^.Y) - 3 + WorldDy;
   877 if ((Gear^.State and gstWinner) <> 0) and
   892 if ((Gear^.State and gstWinner) <> 0) and
   878    ((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtPickHammer)) then
   893    ((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtPickHammer)) then
  1044                            hwRound(Gear^.Y) - 8 + WorldDy,
  1059                            hwRound(Gear^.Y) - 8 + WorldDy,
  1045                            0,
  1060                            0,
  1046                            hwSign(Gear^.dX),
  1061                            hwSign(Gear^.dX),
  1047                            32,
  1062                            32,
  1048                            32);
  1063                            32);
  1049 				stepSounds:= true;
       
  1050 				defaultPos:= false
  1064 				defaultPos:= false
  1051 				end;
  1065 				end;
  1052 			gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180);
  1066 			gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180);
  1053 			gtFirePunch: begin
  1067 			gtFirePunch: begin
  1054 				DrawHedgehog(sx, sy,
  1068 				DrawHedgehog(sx, sy,
  1141 		DrawHedgehog(sx, sy,
  1155 		DrawHedgehog(sx, sy,
  1142 			hwSign(Gear^.dX),
  1156 			hwSign(Gear^.dX),
  1143 			0,
  1157 			0,
  1144 			PHedgehog(Gear^.Hedgehog)^.visStepPos div 2,
  1158 			PHedgehog(Gear^.Hedgehog)^.visStepPos div 2,
  1145 			0);
  1159 			0);
  1146 		stepSounds:= true;
       
  1147 		defaultPos:= false;
  1160 		defaultPos:= false;
  1148 		HatVisible:= true
  1161 		HatVisible:= true
  1149 		end
  1162 		end
  1150 	else
  1163 	else
  1151 
  1164 
  1379     begin
  1392     begin
  1380     glColor4f(1, 1, 1, 0.25 + abs(1 - (RealTicks mod 1500) / 750));
  1393     glColor4f(1, 1, 1, 0.25 + abs(1 - (RealTicks mod 1500) / 750));
  1381     DrawSprite(sprVampiric, sx - 24, sy - 24, 0);
  1394     DrawSprite(sprVampiric, sx - 24, sy - 24, 0);
  1382 	glColor4f(1, 1, 1, 1);
  1395 	glColor4f(1, 1, 1, 1);
  1383     end;
  1396     end;
  1384 	
       
  1385 	if stepSounds and (Gear^.SoundChannel < 0) then
       
  1386 		Gear^.SoundChannel:= LoopSound(sndSteps)
       
  1387 	else if not stepSounds and (Gear^.SoundChannel > -1) then
       
  1388 		begin
       
  1389 		StopSound(Gear^.SoundChannel);
       
  1390 		Gear^.SoundChannel:= -1;
       
  1391 		end;
       
  1392 end;
  1397 end;
  1393 
  1398 
  1394 procedure DrawRopeLinesRQ(Gear: PGear);
  1399 procedure DrawRopeLinesRQ(Gear: PGear);
  1395 begin
  1400 begin
  1396 with RopePoints do
  1401 with RopePoints do