hedgewars/GSHandlers.inc
changeset 49 3afe33c1cf06
parent 46 c99140d2355a
child 53 0e27949850e3
equal deleted inserted replaced
48:0f396d0c429d 49:3afe33c1cf06
   685    begin
   685    begin
   686    DeleteGear(Gear);
   686    DeleteGear(Gear);
   687    doMakeExplosion(round(Gear.X), round(Gear.Y), 20, EXPLAutoSound)
   687    doMakeExplosion(round(Gear.X), round(Gear.Y), 20, EXPLAutoSound)
   688    end
   688    end
   689 end;
   689 end;
       
   690 
       
   691 ////////////////////////////////////////////////////////////////////////////////
       
   692 var thexchar: array[0..5] of record
       
   693                              oy, ny: integer;
       
   694                              team: PTeam;
       
   695                              end;
       
   696     thexchcnt: Longword;
       
   697 
       
   698 procedure doStepTeamHealthSorterWork(Gear: PGear);
       
   699 var i: integer;
       
   700 begin
       
   701 AllInactive:= false;
       
   702 dec(Gear.Timer);
       
   703 if (Gear.Timer and 15) = 0 then
       
   704    for i:= 0 to Pred(thexchcnt) do
       
   705        with thexchar[i] do
       
   706             {$WARNINGS OFF}
       
   707             team.DrawHealthY:= ny + (oy - ny) * Gear.Timer div 640;
       
   708             {$WARNINGS ON}
       
   709 if Gear.Timer = 0 then
       
   710    DeleteGear(Gear)
       
   711 end;
       
   712 
       
   713 procedure doStepTeamHealthSorter(Gear: PGear);
       
   714 var team: PTeam;
       
   715     i, t: Longword;
       
   716 begin
       
   717 AllInactive:= false;
       
   718 team:= TeamsList;
       
   719 i:= 0;
       
   720 while team <> nil do
       
   721       begin
       
   722       thexchar[i].oy:= team.DrawHealthY;
       
   723       thexchar[i].team:= team;
       
   724       inc(i);
       
   725       team:= team.Next
       
   726       end;
       
   727 thexchcnt:= i;
       
   728 for i:= 1 to thexchcnt do
       
   729     for t:= 0 to thexchcnt - 2 do
       
   730         if thexchar[t].team.TeamHealth > thexchar[Succ(t)].team.TeamHealth then
       
   731            begin
       
   732            thexchar[5]:= thexchar[t];
       
   733            thexchar[t]:= thexchar[Succ(t)];
       
   734            thexchar[Succ(t)]:= thexchar[5]
       
   735            end;
       
   736 t:= cScreenHeight - 4;
       
   737 for i:= 0 to Pred(thexchcnt) do
       
   738     with thexchar[i] do
       
   739          begin
       
   740          dec(t, team.HealthRect.h + 2);
       
   741          ny:= t
       
   742          end;
       
   743 Gear.Timer:= 640;
       
   744 Gear.doStep:= doStepTeamHealthSorterWork
       
   745 end;
       
   746