hedgewars/uGears.pas
changeset 822 2ae8fd8ef804
parent 821 e6c0408b54ed
child 823 90d651e75547
equal deleted inserted replaced
821:e6c0408b54ed 822:2ae8fd8ef804
   469       end
   469       end
   470 end;
   470 end;
   471 
   471 
   472 procedure DrawHH(Gear: PGear; Surface: PSDL_Surface);
   472 procedure DrawHH(Gear: PGear; Surface: PSDL_Surface);
   473 var t: LongInt;
   473 var t: LongInt;
       
   474 	amt: TAmmoType;
       
   475 	hx, hy: LongInt;
       
   476 	aangle: real;
   474 begin
   477 begin
   475 if (Gear^.State and gstHHDriven) <> 0 then
   478 if (Gear^.State and gstHHDriven) <> 0 then
   476    begin
   479 begin
   477    if CurAmmoGear <> nil then
   480 	if CurAmmoGear <> nil then
   478       begin
   481 	begin
   479       if (CurAmmoGear^.Kind = gtRope) then
   482 		if (CurAmmoGear^.Kind = gtRope) then
   480       DrawHedgehog(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
   483 		DrawHedgehog(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
   481              1,
   484 				1,
   482              1,
   485 				1,
   483              0,
   486 				0,
   484              DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) - 110);
   487 				DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) - 110);
   485       end else
   488 	end else
   486       DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
   489 	if (Gear^.Message and (gm_Left or gm_Right) <> 0) then
   487              hwSign(Gear^.dX),
   490 		DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
   488              0,
   491 			hwSign(Gear^.dX),
   489              PHedgehog(Gear^.Hedgehog)^.visStepPos div 2,
   492 			0,
   490              0);
   493 			PHedgehog(Gear^.Hedgehog)^.visStepPos div 2,
   491    end else
   494 			0)
   492    DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
   495     else
   493              hwSign(Gear^.dX),
   496 	begin
   494              0,
   497 		amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType;
   495              8,
   498 		hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx;
   496              0);
   499 		hy:= hwRound(Gear^.Y) - 2 + WorldDy;
       
   500 		aangle:= Gear^.Angle * 180 / cMaxAngle - 90;
       
   501 		case amt of
       
   502 			amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle);
       
   503 		else
       
   504 		end;
       
   505 		case amt of
       
   506 			amRope: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   507 						hwSign(Gear^.dX),
       
   508 						0,
       
   509 						4,
       
   510 						0);
       
   511 		else
       
   512 			DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   513 				hwSign(Gear^.dX),
       
   514 				0,
       
   515 				3,
       
   516 				0);
       
   517 		end
       
   518 	end
       
   519 end else
       
   520 	DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   521 		hwSign(Gear^.dX),
       
   522 		0,
       
   523 		3,
       
   524 		0);
   497 
   525 
   498 with PHedgehog(Gear^.Hedgehog)^ do
   526 with PHedgehog(Gear^.Hedgehog)^ do
   499      if (Gear^.State{ and not gstAnimation}) = 0 then
   527      if (Gear^.State{ and not gstAnimation}) = 0 then
   500         begin
   528         begin
   501         t:= hwRound(Gear^.Y) - cHHRadius - 10 + WorldDy;
   529         t:= hwRound(Gear^.Y) - cHHRadius - 10 + WorldDy;
   529                  DrawRotatedTex(Team^.CrosshairTex,
   557                  DrawRotatedTex(Team^.CrosshairTex,
   530                                 12, 12,
   558                                 12, 12,
   531                                 Round(hwRound(Gear^.X) +
   559                                 Round(hwRound(Gear^.X) +
   532                                 hwSign(Gear^.dX) * Sin(Gear^.Angle*pi/cMaxAngle)*60) + WorldDx,
   560                                 hwSign(Gear^.dX) * Sin(Gear^.Angle*pi/cMaxAngle)*60) + WorldDx,
   533                                 Round(hwRound(Gear^.Y) -
   561                                 Round(hwRound(Gear^.Y) -
   534                                 Cos(Gear^.Angle*pi/cMaxAngle)*60) + WorldDy,
   562                                 Cos(Gear^.Angle*pi/cMaxAngle)*60) + WorldDy, 0,
   535                                 hwSign(Gear^.dX) * Gear^.Angle * 180 / cMaxAngle)
   563                                 hwSign(Gear^.dX) * Gear^.Angle * 180 / cMaxAngle)
   536         end;
   564         end;
   537 end;
   565 end;
   538 
   566 
   539 procedure DrawGears(Surface: PSDL_Surface);
   567 procedure DrawGears(Surface: PSDL_Surface);
   606 begin
   634 begin
   607 Gear:= GearsList;
   635 Gear:= GearsList;
   608 while Gear<>nil do
   636 while Gear<>nil do
   609       begin
   637       begin
   610       case Gear^.Kind of
   638       case Gear^.Kind of
   611        gtAmmo_Bomb: DrawRotated(sprBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.DirAngle);
   639        gtAmmo_Bomb: DrawRotated(sprBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
   612         gtHedgehog: DrawHH(Gear, Surface);
   640         gtHedgehog: DrawHH(Gear, Surface);
   613     gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, DxDy2Angle(Gear^.dY, Gear^.dX));
   641     gtAmmo_Grenade: DrawRotated(sprGrenade, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
   614        gtHealthTag,
   642        gtHealthTag,
   615      gtSmallDamage: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
   643      gtSmallDamage: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex);
   616            gtGrave: DrawSurfSprite(hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, PHedgehog(Gear^.Hedgehog)^.Team^.GraveTex, Surface);
   644            gtGrave: DrawSurfSprite(hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, PHedgehog(Gear^.Hedgehog)^.Team^.GraveTex, Surface);
   617              gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4, Surface);
   645              gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4, Surface);
   618             gtRope: begin
   646             gtRope: begin
   628                              end;
   656                              end;
   629                        DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy,
   657                        DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy,
   630                                     hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy);
   658                                     hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy);
   631                        DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
   659                        DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
   632                                     hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy);
   660                                     hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy);
   633                        DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, RopePoints.HookAngle)
   661                        DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle)
   634                        end else
   662                        end else
   635                        begin
   663                        begin
   636                        DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
   664                        DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
   637                                     hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy);
   665                                     hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy);
   638                        DrawRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, DxDy2Angle(Gear^.dY, Gear^.dX));
   666                        DrawRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
   639                        end;
   667                        end;
   640                     end;
   668                     end;
   641       gtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State, Surface);
   669       gtSmokeTrace: if Gear^.State < 8 then DrawSprite(sprSmokeTrace, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State, Surface);
   642        gtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State, Surface);
   670        gtExplosion: DrawSprite(sprExplosion50, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.State, Surface);
   643             gtMine: if ((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)
   671             gtMine: if ((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)
   644                        then DrawRotated(sprMineOff, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.DirAngle)
   672                        then DrawRotated(sprMineOff, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle)
   645                        else DrawRotated(sprMineOn, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.DirAngle);
   673                        else DrawRotated(sprMineOn, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
   646             gtCase: case Gear^.Pos of
   674             gtCase: case Gear^.Pos of
   647                          posCaseAmmo  : DrawSprite(sprCase, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0, Surface);
   675                          posCaseAmmo  : DrawSprite(sprCase, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0, Surface);
   648                          posCaseHealth: DrawSprite(sprFAid, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, (GameTicks shr 6) mod 13, Surface);
   676                          posCaseHealth: DrawSprite(sprFAid, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, (GameTicks shr 6) mod 13, Surface);
   649                          end;
   677                          end;
   650         gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1, Surface);
   678         gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1, Surface);
   651      gtClusterBomb: DrawRotated(sprClusterBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.DirAngle);
   679      gtClusterBomb: DrawRotated(sprClusterBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
   652          gtCluster: DrawSprite(sprClusterParticle, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, 0, Surface);
   680          gtCluster: DrawSprite(sprClusterParticle, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, 0, Surface);
   653            gtFlame: DrawSprite(sprFlame, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy,(GameTicks div 128 + Gear^.Angle) mod 8, Surface);
   681            gtFlame: DrawSprite(sprFlame, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy,(GameTicks div 128 + Gear^.Angle) mod 8, Surface);
   654        gtParachute: DrawSprite(sprParachute, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 48 + WorldDy, 0, Surface);
   682        gtParachute: DrawSprite(sprParachute, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 48 + WorldDy, 0, Surface);
   655        gtAirAttack: if Gear^.Tag > 0 then DrawSprite(sprAirplane, hwRound(Gear^.X) - 60 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, 0, Surface)
   683        gtAirAttack: if Gear^.Tag > 0 then DrawSprite(sprAirplane, hwRound(Gear^.X) - 60 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, 0, Surface)
   656                                      else DrawSprite(sprAirplane, hwRound(Gear^.X) - 60 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, 1, Surface);
   684                                      else DrawSprite(sprAirplane, hwRound(Gear^.X) - 60 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, 1, Surface);
   657          gtAirBomb: DrawRotated(sprAirBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, DxDy2Angle(Gear^.dY, Gear^.dX));
   685          gtAirBomb: DrawRotated(sprAirBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
   658         gtSwitcher: DrawSprite(sprSwitch, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 56 + WorldDy, (GameTicks shr 6) mod 12, Surface);
   686         gtSwitcher: DrawSprite(sprSwitch, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 56 + WorldDy, (GameTicks shr 6) mod 12, Surface);
   659           gtTarget: DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0, Surface);
   687           gtTarget: DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0, Surface);
   660               end;
   688               end;
   661       Gear:= Gear^.NextGear
   689       Gear:= Gear^.NextGear
   662       end;
   690       end;