Thema: FreePascal Bubblesort Problem

Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#22

AW: Bubblesort Problem

  Alt 7. Mär 2018, 09:52
Zitat:
sondern die Tatsache dass du gar nicht wirklich weißt was du haben willst.
Das ich nicht weis wie ich es sortieren soll..
Richtig!

Mal der komplette part.
Delphi-Quellcode:
procedure DrawCarousel(WinHandle: HWND);
var
  K, I: Integer;
  Angle, anglePi: single;
  rc: TRect;
  speed, fl, z, scale: Single;
  xcenter, ycenter, zcenter: Integer;
  radius: Integer;
  x, y: Integer;
  PiDiv180: Double;
  zorder: array [0..9] of Integer;
  faceorder: array [0..9] of Integer;
begin
    if bAnimate then
    begin
       y := trbY.GetTrackValue(trbY.Handle);
       speed := trbSpeed.GetTrackValue(trbSpeed.Handle) div 4;
       fl := trbFocallength.GetTrackValue(trbFocallength.Handle) / 100;

       if fl < 0.02 then
         fl := 0.001;
       PiDiv180 := 1.74532925199433E-2;

       GetClientRect(HSprCtrl, rc);
       xcenter := (rc.Right - 128) div 2;
       ycenter := (rc.Bottom - 128) div 2;
       zcenter := ycenter div 2;
       radius := round(rc.Right / 3.675);

       for K := High(zorder) downto 0 do
       begin
         Angle := gSpriteData[K].rAngle;
         anglePi := Angle * PiDiv180;
         z := sin(anglePi) * radius + zcenter;
         scale := fl / (fl + z);
         x := round(cos(anglePi) * radius);
         gSpriteData[K].xPos := round(x * scale + xcenter);
         gSpriteData[K].yPos := round(y * scale + ycenter - y);

         zorder[K] := round(Angle - 90);
         if zorder[K] > 180 then
           zorder[K] := 360 - zorder[K];

         faceorder[K] := K;

         if bMoveToLeft then
         begin
           Angle := Angle - speed;
           if Angle < 1 then
             Angle := 360
         end else
         begin
           Angle := Angle + speed;
           if Angle > 359 then
             Angle := Angle - 360;
         end;
         gSpriteData[K].rAngle := round(Angle);

         // Skalierungsfaktor berechnen
         if Check3Ddepth.GetCheckButtonStatus(Check3Ddepth.Handle) then
           gSprCtrl.GD_SetObjectScale(gSpriteData[K].ID, (ABS(zorder[K]) mod 182) * 0.0027777 + 0.5)
         else
         gSprCtrl.GD_SetObjectScale(gSpriteData[K].ID, 1);

         // Alpha Kanal unschalten
         if CheckOpacity.GetCheckButtonStatus(CheckOpacity.Handle) and (fl > 0.999) then
           gSprCtrl.GD_SetObjectAlpha(gSpriteData[K].ID, round(MIN(100 * scale, 255)), false)
         else
         gSprCtrl.GD_SetObjectAlpha(gSpriteData[K].ID, 255, false);

         gSprCtrl.GD_SetObjectXY(gSpriteData[K].ID, gSpriteData[K].xPos, gSpriteData[K].yPos);

         if CheckSelfRotation.GetCheckButtonStatus(CheckSelfRotation.Handle) then
           gSprCtrl.GD_SetObjectAngle(gSpriteData[K].ID, round(gSpriteData[K].rAngle), false)
         else
         gSprCtrl.GD_SetObjectAngle(gSpriteData[K].ID, 0, false);
       end;

       BubbleSort(zorder, faceorder);

       // Sprite ZOrder setzen
       I := faceorder[0];
       if bMoveToLeft then
       begin
         inc(I);
         if I > (ID_MAX_SPRITE - 1) then
           I := 0;
       end;

       gSprCtrl.GD_SetObjectZorder(gSpriteData[I].ID, GD_ORDER_BOTTOM);
       gSprCtrl.GD_SetObjectZorder(gSpriteData[faceorder[ID_MAX_SPRITE - 1]].ID, GD_ORDER_TOP);

       if CheckMarquee.GetCheckButtonStatus(CheckMarquee.Handle) then
         DrawMarquee(rc.Right);

       gSprCtrl.GI_UpdateWindow(HSprCtrl, false);
    end;
end;
Bubblesort habe ich schon gepostet.

gruss
  Mit Zitat antworten Zitat