hedgewars/uGears.pas
changeset 966 664ae90b5b0c
parent 959 18b05fc2d0a6
child 970 1bd9a4eafbc3
equal deleted inserted replaced
965:a4d5fc8eec7a 966:664ae90b5b0c
   505 	exit
   505 	exit
   506 	end;
   506 	end;
   507 defaultPos:= true;
   507 defaultPos:= true;
   508 
   508 
   509 if (Gear^.State and gstHHDriven) <> 0 then
   509 if (Gear^.State and gstHHDriven) <> 0 then
   510 begin
       
   511 	hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx;
       
   512 	hy:= hwRound(Gear^.Y) - 2 + WorldDy;
       
   513 	aangle:= Gear^.Angle * 180 / cMaxAngle - 90;
       
   514 
       
   515 	if CurAmmoGear <> nil then
       
   516 	begin
   510 	begin
   517 		case CurAmmoGear^.Kind of
   511 		hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx;
   518 			gtShotgunShot: if (CurAmmoGear^.State and gstAnimation <> 0) then
   512 		hy:= hwRound(Gear^.Y) - 2 + WorldDy;
   519 					DrawRotated(sprShotgun, hx, hy, hwSign(Gear^.dX), aangle)
   513 		aangle:= Gear^.Angle * 180 / cMaxAngle - 90;
   520 				else
   514 
   521 					DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
   515 		if CurAmmoGear <> nil then
   522 			gtDEagleShot: DrawRotated(sprDEagle, hx, hy, hwSign(Gear^.dX), aangle);
   516 		begin
   523 			gtRope: begin
   517 			case CurAmmoGear^.Kind of
   524 				if Gear^.X < CurAmmoGear^.X then
   518 				gtShotgunShot: if (CurAmmoGear^.State and gstAnimation <> 0) then
   525 					begin
   519 						DrawRotated(sprShotgun, hx, hy, hwSign(Gear^.dX), aangle)
   526 					dAngle:= 0;
   520 					else
   527 					m:= 1
   521 						DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
   528 					end else
   522 				gtDEagleShot: DrawRotated(sprDEagle, hx, hy, hwSign(Gear^.dX), aangle);
   529 					begin
   523 				gtRope: begin
   530 					dAngle:= 180;
   524 					if Gear^.X < CurAmmoGear^.X then
   531 					m:= -1
   525 						begin
       
   526 						dAngle:= 0;
       
   527 						m:= 1
       
   528 						end else
       
   529 						begin
       
   530 						dAngle:= 180;
       
   531 						m:= -1
       
   532 						end;
       
   533 					DrawHedgehog(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
       
   534 							m,
       
   535 							1,
       
   536 							0,
       
   537 							DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
       
   538 					defaultPos:= false
   532 					end;
   539 					end;
   533 				DrawHedgehog(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
   540 				gtBlowTorch: begin
   534 						m,
   541 					DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
   535 						1,
   542 					DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
   536 						0,
   543 							hwSign(Gear^.dX),
   537 						DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
   544 							1,
   538 				defaultPos:= false
   545 							3,
   539 				end;
   546 							0);
   540 			gtBlowTorch: begin
   547 					defaultPos:= false
   541 				DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
   548 					end;
   542 				DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
   549 				gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180);
   543 						hwSign(Gear^.dX),
   550 				gtFirePunch: begin
   544 						1,
   551 					DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
   545 						3,
   552 							hwSign(Gear^.dX),
   546 						0);
   553 							1,
   547 				defaultPos:= false
   554 							4,
   548 				end;
   555 							0);
   549 			gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180);
   556 					defaultPos:= false
   550 			gtFirePunch: begin
   557 					end;
   551 				DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
   558 				gtPickHammer,
   552 						hwSign(Gear^.dX),
   559 				gtTeleport: defaultPos:= false;
   553 						1,
   560 			end;
   554 						4,
   561 
   555 						0);
   562 			case CurAmmoGear^.Kind of
   556 				defaultPos:= false
   563 				gtShotgunShot,
   557 				end;
   564 				gtDEagleShot,
   558 			gtPickHammer,
   565 				gtShover: begin
   559 			gtTeleport: defaultPos:= false;
   566 					DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
   560 		end;
   567 							hwSign(Gear^.dX),
   561 
   568 							0,
   562 		case CurAmmoGear^.Kind of
   569 							4,
   563 			gtShotgunShot,
   570 							0);
   564 			gtDEagleShot,
   571 					defaultPos:= false
   565 			gtShover: begin
   572 				end
   566 				DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   567 						hwSign(Gear^.dX),
       
   568 						0,
       
   569 						4,
       
   570 						0);
       
   571 				defaultPos:= false
       
   572 			end
   573 			end
   573 		end
   574 		end else
   574 	end else
   575 
   575 
   576 		if ((Gear^.State and gstHHJumping) <> 0) then
   576 	if ((Gear^.State and gstHHJumping) <> 0) then
       
   577 		begin
   577 		begin
   578 		if ((Gear^.State and gstHHHJump) <> 0) then
   578 		if ((Gear^.State and gstHHHJump) <> 0) then
   579 			DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
   579 			DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
   580 				- hwSign(Gear^.dX),
   580 				- hwSign(Gear^.dX),
   581 				1,
   581 				1,
   587 				1,
   587 				1,
   588 				1,
   588 				1,
   589 				0);
   589 				0);
   590 			defaultPos:= false
   590 			defaultPos:= false
   591 		end else
   591 		end else
   592 
   592 		
   593 	if (Gear^.Message and (gm_Left or gm_Right) <> 0) then
   593 		if (Gear^.Message and (gm_Left or gm_Right) <> 0) then
   594 		begin
   594 			begin
   595 		DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   596 			hwSign(Gear^.dX),
       
   597 			0,
       
   598 			PHedgehog(Gear^.Hedgehog)^.visStepPos div 2,
       
   599 			0);
       
   600 			defaultPos:= false
       
   601 		end
       
   602     else
       
   603 
       
   604 	if ((Gear^.State and gstAttacked) = 0) then
       
   605 	begin
       
   606 		amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType;
       
   607 		case amt of
       
   608 			amBazooka,
       
   609 			amMortar: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle);
       
   610 			amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle);
       
   611 			amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
       
   612 			amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle);
       
   613 			amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
       
   614 		end;
       
   615 
       
   616 		case amt of
       
   617 			amAirAttack,
       
   618 			amMineStrike: DrawRotated(sprHandAirAttack, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) + WorldDy, hwSign(Gear^.dX), 0);
       
   619 			amPickHammer: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   620 						hwSign(Gear^.dX),
       
   621 						1,
       
   622 						2,
       
   623 						0);
       
   624 			amBlowTorch: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   625 						hwSign(Gear^.dX),
       
   626 						1,
       
   627 						3,
       
   628 						0);
       
   629 			amTeleport: DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, 0, hwSign(Gear^.dX), 0);
       
   630 		else
       
   631 			DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
   595 			DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
   632 				hwSign(Gear^.dX),
   596 				hwSign(Gear^.dX),
   633 				0,
   597 				0,
   634 				4,
   598 				PHedgehog(Gear^.Hedgehog)^.visStepPos div 2,
   635 				0);
   599 				0);
       
   600 				defaultPos:= false
       
   601 			end
       
   602 		else
       
   603 
       
   604 		if ((Gear^.State and gstAttacked) = 0) then
       
   605 		begin
       
   606 			amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType;
       
   607 			case amt of
       
   608 				amBazooka,
       
   609 				amMortar: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle);
       
   610 				amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle);
       
   611 				amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
       
   612 				amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle);
       
   613 				amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
       
   614 			end;
       
   615 
       
   616 			case amt of
       
   617 				amAirAttack,
       
   618 				amMineStrike: DrawRotated(sprHandAirAttack, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) + WorldDy, hwSign(Gear^.dX), 0);
       
   619 				amPickHammer: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   620 							hwSign(Gear^.dX),
       
   621 							1,
       
   622 							2,
       
   623 							0);
       
   624 				amBlowTorch: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   625 							hwSign(Gear^.dX),
       
   626 							1,
       
   627 							3,
       
   628 							0);
       
   629 				amTeleport: DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, 0, hwSign(Gear^.dX), 0);
       
   630 			else
       
   631 				DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   632 					hwSign(Gear^.dX),
       
   633 					0,
       
   634 					4,
       
   635 					0);
       
   636 			end;
       
   637 
       
   638 			case amt of
       
   639 				amBaseballBat: DrawRotated(sprHandBaseball,
       
   640 						hwRound(Gear^.X) + 1 - 4 * hwSign(Gear^.dX) + WorldDx,
       
   641 						hwRound(Gear^.Y) + 6 + WorldDy, hwSign(Gear^.dX), aangle);
       
   642 			end;
       
   643 
       
   644 			defaultPos:= false
       
   645 		end
       
   646 	end else // not gstHHDriven
       
   647 		if ((Gear^.State and gstHHJumping) <> 0) then
       
   648 		begin
       
   649 		if ((Gear^.State and gstHHHJump) <> 0) then
       
   650 			DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   651 				- hwSign(Gear^.dX),
       
   652 				1,
       
   653 				1,
       
   654 				0)
       
   655 			else
       
   656 			DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   657 				hwSign(Gear^.dX),
       
   658 				1,
       
   659 				1,
       
   660 				0);
       
   661 			defaultPos:= false
   636 		end;
   662 		end;
   637 
   663 
   638 		case amt of
       
   639 			amBaseballBat: DrawRotated(sprHandBaseball,
       
   640 					hwRound(Gear^.X) + 1 - 4 * hwSign(Gear^.dX) + WorldDx,
       
   641 					hwRound(Gear^.Y) + 6 + WorldDy, hwSign(Gear^.dX), aangle);
       
   642 		end;
       
   643 
       
   644 		defaultPos:= false
       
   645 	end
       
   646 end;
       
   647 
   664 
   648 if defaultPos then
   665 if defaultPos then
   649 	DrawRotatedF(sprHHIdle,
   666 	DrawRotatedF(sprHHIdle,
   650 		hwRound(Gear^.X) + 1 + WorldDx,
   667 		hwRound(Gear^.X) + 1 + WorldDx,
   651 		hwRound(Gear^.Y) - 3 + WorldDy,
   668 		hwRound(Gear^.Y) - 3 + WorldDy,