hedgewars/uGears.pas
changeset 2802 28cd5b87bce9
parent 2801 24739a3bf5e3
child 2811 4cad87e11bf6
equal deleted inserted replaced
2801:24739a3bf5e3 2802:28cd5b87bce9
   815 	if t^.Kind = gtHedgehog then t^.Active:= true;
   815 	if t^.Kind = gtHedgehog then t^.Active:= true;
   816 	t:= t^.NextGear
   816 	t:= t^.NextGear
   817 	end
   817 	end
   818 end;
   818 end;
   819 
   819 
       
   820 procedure RenderAltWeapon(Gear: PGear; sx, sy: LongInt);
       
   821 var r1, r2: TSDL_Rect;
       
   822 begin
       
   823 with PHedgehog(Gear^.Hedgehog)^ do
       
   824 	begin
       
   825 	if ropeIconIndex <> ord(Ammo^[CurSlot, CurAmmo].AmmoType) then
       
   826 		begin
       
   827 		if ropeIconTex <> nil then
       
   828 			FreeTexture(ropeIconTex);
       
   829 		r1.x:= ((ord(Ammo^[CurSlot, CurAmmo].AmmoType) - 1) shr 5) * 32;
       
   830 		r1.y:= ((ord(Ammo^[CurSlot, CurAmmo].AmmoType) - 1) mod 32) * 32;
       
   831 		r1.w:= 32;
       
   832 		r1.h:= 32;
       
   833 		r2.x:= 2;
       
   834 		r2.y:= 2;
       
   835 		r2.w:= 32;
       
   836 		r2.h:= 32;
       
   837 		SDL_UpperBlit(SpritesData[sprAMAmmos].Surface, @r1, ropeIconSurf, @r2);
       
   838 		ropeIconTex:= Surface2Tex(ropeIconSurf, true);
       
   839 		ropeIconIndex:= ord(Ammo^[CurSlot, CurAmmo].AmmoType)
       
   840 		end;
       
   841 	// render the rope weapon icon (if weapon is alt useable)
       
   842 	if (ropeIconTex <> nil) and ((Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) and ((Gear^.State and gstAttacked) = 0) then
       
   843 		DrawTexture(sx + 16, sy + 16, ropeIconTex)
       
   844 	end;
       
   845 end;
       
   846 
   820 procedure DrawHH(Gear: PGear);
   847 procedure DrawHH(Gear: PGear);
   821 var i, t: LongInt;
   848 var i, t: LongInt;
   822 	amt: TAmmoType;
   849 	amt: TAmmoType;
   823 	hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
   850 	hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
   824 	lx, ly, dx, dy, ax, ay, aAngle, dAngle, hAngle: real;  // laser, change
   851 	lx, ly, dx, dy, ax, ay, aAngle, dAngle, hAngle: real;  // laser, change
   825 	defaultPos, HatVisible: boolean;
   852 	defaultPos, HatVisible: boolean;
   826     VertexBuffer: array [0..1] of TVertex2f;
   853     VertexBuffer: array [0..1] of TVertex2f;
   827 	r1, r2: TSDL_Rect;
       
   828 begin
   854 begin
   829 if PHedgehog(Gear^.Hedgehog)^.Unplaced then exit;
   855 if PHedgehog(Gear^.Hedgehog)^.Unplaced then exit;
   830 m:= 1;
   856 m:= 1;
   831 if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1;
   857 if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1;
   832 if (Gear^.State and gstHHDeath) <> 0 then
   858 if (Gear^.State and gstHHDeath) <> 0 then
   988 				with PHedgehog(Gear^.Hedgehog)^ do
  1014 				with PHedgehog(Gear^.Hedgehog)^ do
   989 					if (HatTex <> nil) then
  1015 					if (HatTex <> nil) then
   990 						DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, sx, sy, 0, i, 32,
  1016 						DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, sx, sy, 0, i, 32,
   991 							i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
  1017 							i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
   992 				
  1018 				
   993 				// update the rope weapon icon
  1019 				RenderAltWeapon(Gear, sx, sy);
   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;
       
  1016 				defaultPos:= false
  1020 				defaultPos:= false
  1017 				end;
  1021 				end;
  1018 			gtBlowTorch: begin
  1022 			gtBlowTorch: begin
  1019 				DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
  1023 				DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
  1020 				DrawHedgehog(sx, sy,
  1024 				DrawHedgehog(sx, sy,
  1296             gtJetpack: begin
  1300             gtJetpack: begin
  1297 	                   DrawSprite(sprJetpack, sx-32, sy-32, 0);
  1301 	                   DrawSprite(sprJetpack, sx-32, sy-32, 0);
  1298 	                   if (CurAmmoGear^.MsgParam and gm_Up) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 1);
  1302 	                   if (CurAmmoGear^.MsgParam and gm_Up) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 1);
  1299 	                   if (CurAmmoGear^.MsgParam and gm_Left) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 2);
  1303 	                   if (CurAmmoGear^.MsgParam and gm_Left) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 2);
  1300 	                   if (CurAmmoGear^.MsgParam and gm_Right) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 3);
  1304 	                   if (CurAmmoGear^.MsgParam and gm_Right) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 3);
  1301                        if CurAmmoGear^.Tex <> nil then DrawCentered(sx, sy - 40, CurAmmoGear^.Tex)
  1305                        if CurAmmoGear^.Tex <> nil then DrawCentered(sx, sy - 40, CurAmmoGear^.Tex);
       
  1306 					   RenderAltWeapon(Gear, sx, sy)
  1302                        end;
  1307                        end;
  1303             end;
  1308             end;
  1304         end
  1309         end
  1305     end;
  1310     end;
  1306 
  1311 
  1551                          end;
  1556                          end;
  1552         gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1);
  1557         gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1);
  1553      gtClusterBomb: DrawRotated(sprClusterBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
  1558      gtClusterBomb: DrawRotated(sprClusterBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
  1554          gtCluster: DrawSprite(sprClusterParticle, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, 0);
  1559          gtCluster: DrawSprite(sprClusterParticle, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, 0);
  1555            gtFlame: DrawTextureF(SpritesData[sprFlame].Texture, 1 / (Gear^.Tag mod 3 + 2), hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (GameTicks div 128 + LongWord(Gear^.Tag)) mod 8, 1, 8);
  1560            gtFlame: DrawTextureF(SpritesData[sprFlame].Texture, 1 / (Gear^.Tag mod 3 + 2), hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (GameTicks div 128 + LongWord(Gear^.Tag)) mod 8, 1, 8);
  1556        gtParachute: DrawSprite(sprParachute, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 48 + WorldDy, 0);
  1561        gtParachute: begin
       
  1562 					DrawSprite(sprParachute, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 48 + WorldDy, 0);
       
  1563 					RenderAltWeapon(Gear, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy)
       
  1564 					end;
  1557        gtAirAttack: if Gear^.Tag > 0 then DrawSprite(sprAirplane, hwRound(Gear^.X) - SpritesData[sprAirplane].Width div 2 + WorldDx, hwRound(Gear^.Y) - SpritesData[sprAirplane].Height div 2 + WorldDy, 0)
  1565        gtAirAttack: if Gear^.Tag > 0 then DrawSprite(sprAirplane, hwRound(Gear^.X) - SpritesData[sprAirplane].Width div 2 + WorldDx, hwRound(Gear^.Y) - SpritesData[sprAirplane].Height div 2 + WorldDy, 0)
  1558                                      else DrawSprite(sprAirplane, hwRound(Gear^.X) - SpritesData[sprAirplane].Width div 2 + WorldDx, hwRound(Gear^.Y) - SpritesData[sprAirplane].Height div 2 + WorldDy, 1);
  1566                                      else DrawSprite(sprAirplane, hwRound(Gear^.X) - SpritesData[sprAirplane].Width div 2 + WorldDx, hwRound(Gear^.Y) - SpritesData[sprAirplane].Height div 2 + WorldDy, 1);
  1559          gtAirBomb: DrawRotated(sprAirBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1567          gtAirBomb: DrawRotated(sprAirBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1560         gtTeleport: begin
  1568         gtTeleport: begin
  1561                     HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
  1569                     HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;