hedgewars/uGears.pas
changeset 2801 24739a3bf5e3
parent 2792 a3efbf1c4500
child 2802 28cd5b87bce9
equal deleted inserted replaced
2800:f286d91157b8 2801:24739a3bf5e3
   108                                   dLen: hwFloat;
   108                                   dLen: hwFloat;
   109                                   b: boolean;
   109                                   b: boolean;
   110                                   end;
   110                                   end;
   111                 rounded: array[0..MAXROPEPOINTS + 2] of TVertex2f;
   111                 rounded: array[0..MAXROPEPOINTS + 2] of TVertex2f;
   112                 end;
   112                 end;
       
   113     ropeIconSurf: PSDL_Surface;
       
   114     ropeIconTex: PTexture;
       
   115     ropeIconIndex: LongInt;
   113 
   116 
   114 procedure DeleteGear(Gear: PGear); forward;
   117 procedure DeleteGear(Gear: PGear); forward;
   115 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); forward;
   118 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); forward;
   116 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); forward;
   119 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); forward;
   117 //procedure AmmoFlameWork(Ammo: PGear); forward;
   120 //procedure AmmoFlameWork(Ammo: PGear); forward;
   819 	amt: TAmmoType;
   822 	amt: TAmmoType;
   820 	hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
   823 	hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
   821 	lx, ly, dx, dy, ax, ay, aAngle, dAngle, hAngle: real;  // laser, change
   824 	lx, ly, dx, dy, ax, ay, aAngle, dAngle, hAngle: real;  // laser, change
   822 	defaultPos, HatVisible: boolean;
   825 	defaultPos, HatVisible: boolean;
   823     VertexBuffer: array [0..1] of TVertex2f;
   826     VertexBuffer: array [0..1] of TVertex2f;
       
   827 	r1, r2: TSDL_Rect;
   824 begin
   828 begin
   825 if PHedgehog(Gear^.Hedgehog)^.Unplaced then exit;
   829 if PHedgehog(Gear^.Hedgehog)^.Unplaced then exit;
   826 m:= 1;
   830 m:= 1;
   827 if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1;
   831 if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1;
   828 if (Gear^.State and gstHHDeath) <> 0 then
   832 if (Gear^.State and gstHHDeath) <> 0 then
   979 				DrawHedgehog(sx, sy,
   983 				DrawHedgehog(sx, sy,
   980 						i,
   984 						i,
   981 						1,
   985 						1,
   982 						0,
   986 						0,
   983 						DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
   987 						DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
   984 			    with PHedgehog(Gear^.Hedgehog)^ do
   988 				with PHedgehog(Gear^.Hedgehog)^ do
   985                    if (HatTex <> nil) then
   989 					if (HatTex <> nil) then
   986 					DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, sx, sy, 0, i, 32,
   990 						DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, sx, sy, 0, i, 32,
   987                         i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
   991 							i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
       
   992 				
       
   993 				// update the rope weapon icon
       
   994 				with PHedgehog(Gear^.Hedgehog)^ do
       
   995 					begin
       
   996 					if ropeIconIndex <> ord(Ammo^[CurSlot, CurAmmo].AmmoType) then
       
   997 						begin
       
   998 						if ropeIconTex <> nil then
       
   999 							FreeTexture(ropeIconTex);
       
  1000 						r1.x:= ((ord(Ammo^[CurSlot, CurAmmo].AmmoType) - 1) shr 5) * 32;
       
  1001 						r1.y:= ((ord(Ammo^[CurSlot, CurAmmo].AmmoType) - 1) mod 32) * 32;
       
  1002 						r1.w:= 32;
       
  1003 						r1.h:= 32;
       
  1004 						r2.x:= 2;
       
  1005 						r2.y:= 2;
       
  1006 						r2.w:= 32;
       
  1007 						r2.h:= 32;
       
  1008 						SDL_UpperBlit(SpritesData[sprAMAmmos].Surface, @r1, ropeIconSurf, @r2);
       
  1009 						ropeIconTex:= Surface2Tex(ropeIconSurf, true);
       
  1010 						ropeIconIndex:= ord(Ammo^[CurSlot, CurAmmo].AmmoType)
       
  1011 						end;
       
  1012 					// render the rope weapon icon (if weapon is alt useable)
       
  1013 					if (ropeIconTex <> nil) and ((Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) then
       
  1014 						DrawTexture(sx + 16, sy + 16, ropeIconTex)
       
  1015 					end;
   988 				defaultPos:= false
  1016 				defaultPos:= false
   989 				end;
  1017 				end;
   990 			gtBlowTorch: begin
  1018 			gtBlowTorch: begin
   991 				DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
  1019 				DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
   992 				DrawHedgehog(sx, sy,
  1020 				DrawHedgehog(sx, sy,
  2109 	gear:= gear^.NextGear
  2137 	gear:= gear^.NextGear
  2110 	end
  2138 	end
  2111 end;
  2139 end;
  2112 
  2140 
  2113 procedure init_uGears;
  2141 procedure init_uGears;
       
  2142 var r: TSDL_Rect;
  2114 begin
  2143 begin
  2115 	CurAmmoGear:= nil;
  2144 	CurAmmoGear:= nil;
  2116 	GearsList:= nil;
  2145 	GearsList:= nil;
  2117 	KilledHHs:= 0;
  2146 	KilledHHs:= 0;
  2118 	SuddenDeathDmg:= false;
  2147 	SuddenDeathDmg:= false;
  2120 	TrainingTargetGear:= nil;
  2149 	TrainingTargetGear:= nil;
  2121 	skipFlag:= false;
  2150 	skipFlag:= false;
  2122 	
  2151 	
  2123 	AllInactive:= false;
  2152 	AllInactive:= false;
  2124 	PrvInactive:= false;
  2153 	PrvInactive:= false;
       
  2154 	
       
  2155 	ropeIconSurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 36, 36, 32, RMask, GMask, BMask, AMask);
       
  2156 	r.x:= 0;
       
  2157 	r.y:= 0;
       
  2158 	r.w:= 36;
       
  2159 	r.h:= 36;
       
  2160 	DrawRoundRect(@r, cWhiteColor, cNearBlackColor, ropeIconSurf, true);
  2125 end;
  2161 end;
  2126 
  2162 
  2127 procedure free_uGears;
  2163 procedure free_uGears;
  2128 begin
  2164 begin
  2129 	FreeGearsList();
  2165 	FreeGearsList();
       
  2166 	if ropeIconTex <> nil then
       
  2167 		FreeTexture(ropeIconTex);
       
  2168 	if ropeIconSurf <> nil then
       
  2169 		SDL_FreeSurface(ropeIconSurf);
  2130 end;
  2170 end;
  2131 
  2171 
  2132 end.
  2172 end.