Page 4 of 5 FirstFirst ... 2345 LastLast
Results 31 to 40 of 42

Thread: Need help with DrawAlpha

  1. #31

    Need help with DrawAlpha

    Yeah, yeah, tried that one, but it somehow totally mussed up all the system memory stored pictures in hardware mode and did pretty strange things for me othervise as well... Strange thing is that .05 CAN actually display the transparency in hardware as seen on my second picture, but not on every place as seen on my first picture
    That's why I still think that that one is somewhat closer to the yay ^^
    Oh, what visual greatness would be some lens flares...

  2. #32

    Need help with DrawAlpha

    OH FOR ****'S SAKE! I got it!!! In hardware mode .05 ignores the transparent colour setting and simply uses the upper-left corner pixel's colur as transparent!!! AAAHHHHH

  3. #33

    Need help with DrawAlpha

    This feature is in version 1.05 and 1.06 too but in 1.06 is corrected it for explicit set color key. image_pixel[0,0] is used for surfaces only, because there isn't set up color but boolean switch transparent only. there http://turbo.gamedev.net/ is old version still. Regards
    Ijcro.

  4. #34

    Need help with DrawAlpha

    Yeah, but point is that I've figured this out, and .05 works well for me now... .06 is very... *VERY* ****ed up somehow... Don't ask me tho, I have no idea what's on with it... As said, you'll see a final-ish version of the game + source...

  5. #35

    Need help with DrawAlpha

    Do you use 05 version as well? Hmm.
    It si depend by picture or algorithm? Send me, please, snippet of your code how you it use please! Thank you!
    Ijcro.

  6. #36

    Need help with DrawAlpha

    Example objects:

    Code:
      
      TShipType = class
      private
      public
        ShipName: String;
        Picture: TDirectDrawSurface;
        PictureFile: String;
        MaxHP, MaxShield, MaxSpeed: Double;
        HitSoundIndex: Integer;
        HitBoxes: Array of TRect;
        Turrets: Array of TPoint;
      end;
    
      TShip = class
      private
        ShieldAnimIndex: Integer;
        ShieldHits: Integer;
        Procedure Shoot;
        Procedure HitCheck;
        Procedure Explode;
        Function AI: ShortInt;
      public
        ShipType: ^TShipType;
        Position: TPoint;
        HP, Shield, Speed: Double;
        NoShield, Invulnerable: Boolean;
        LaserType: ^TLaserType;
        Lasers: Array of TPoint;
        LaserCoolDown: Word;
        IsWarping, IsExploding: Boolean;
        WarpCounter, ExplosionCounter: Word;
        Procedure WarpIn;
        Procedure Update;
        Procedure Draw;
        Procedure DrawLasers;
      end;
    Picture loader for the ship's pictures:
    Code:
    ...
      If Length(ShipTypes) > 0 Then
        For I := 0 To Length(ShipTypes) - 1 Do
          Try
            ShipTypes[I].Picture := TDirectDrawSurface.Create(Window.DXDraw.DDraw);
            ShipTypes[I].Picture.LoadFromFile(Misc.GetAppDir + ShipTypes[I].PictureFile);
            ShipTypes[I].Picture.TransparentColor := $FF00FF;
          Except
            Misc.Error('Cannot load the picture: ' + ShipTypes[I].PictureFile + ' of ship: ' + ShipTypes[I].ShipName);
          end;
    ...
    Picture loader for the shield picture:
    Code:
      If ShieldType.PictureFile <> '' Then
      begin
        ShieldType.Picture &#58;= TDirectDrawSurface.Create&#40;Window.DXDraw.DDraw&#41;;
        ShieldType.Picture.LoadFromFile&#40;Misc.GetAppDir + ShieldType.PictureFile&#41;;
        ShieldType.Picture.TransparentColor &#58;= $FF00FF;
      end;
    Drawing code:
    Code:
    Procedure TShip.Draw;
    var ShipRect&#58; TRect;
      // Function to get the shield effect's alpha
      Function RetShieldAlpha&#58; Integer;
      var I&#58; Integer;
      begin
        Result &#58;= 100;
        For I &#58;= 1 To ShieldHits Do
          Result &#58;= Result + 15;
        If Result > 200 Then Result &#58;= 200;
        If ShieldAnimIndex < 15 Then Result &#58;= Result + Round&#40;&#40;ShieldAnimIndex - 15&#41; * 6.7&#41;
      end;
    
    begin
      If NOT&#40;IsWarping AND &#40;WarpCounter <= 30&#41;&#41; Then
      begin
        ShipRect &#58;= PicRect&#40;Speed, ShipType.MaxSpeed, ShipType.Picture.Width, ShipType.Picture.Height&#41;;
        // If Warping&#58; &#40;30-110. warpframe&#41;
        If IsWarping AND &#40;WarpCounter > 30&#41; AND &#40;WarpCounter < 110&#41; Then
          ShipRect.Top &#58;= Round&#40;ShipRect.Bottom - &#40;&#40;WarpCounter - 30&#41; / &#40;80 / ShipRect.Bottom&#41;&#41;&#41;;
        // Draw
        Window.DXDraw.Surface.Draw&#40;Position.X, Position.Y, ShipRect, ShipType.Picture, True&#41;;
        // Shield
        If ShieldAnimIndex > 0 Then Window.DXDraw.Surface.DrawAlpha&#40;Bounds&#40;Position.X, Position.Y + ShipType.Picture.Height + 5 - ShipRect.Top - ShieldType.Picture.Height, ShipType.Picture.Width DIV 5, ShieldType.Picture.Height&#41;, ShieldType.Picture.ClientRect, ShieldType.Picture, True, RetShieldAlpha&#41;;
        // Spark
        If &#40;&#40;HP < ShipType.MaxHP / 6&#41; AND &#40;Random&#40;64&#41; = 0&#41;&#41; OR &#40;&#40;HP < ShipType.MaxHP / 3&#41; AND &#40;Random&#40;64&#41; = 0&#41;&#41; Then
        begin
          Misc.Sounds.Play&#40;SparkSounds&#91;Random&#40;2&#41;&#93;, Round&#40;&#40;Position.X / &#40;800 - ShipType.Picture.Width DIV 5&#41; * 200&#41; - 100&#41;&#41;;
          With Window.DXDraw.Surface.Canvas Do
          begin
            Pen.Width &#58;= 1;
            Pen.Color &#58;= clAqua;
            MoveTo&#40;Random&#40;ShipType.Picture.Width DIV 10&#41; + Position.X + ShipType.Picture.Width DIV 20, Random&#40;ShipType.Picture.Height&#41; + Position.Y&#41;;
            LineTo&#40;Random&#40;ShipType.Picture.Width DIV 10&#41; + Position.X + ShipType.Picture.Width DIV 20, Random&#40;ShipType.Picture.Height&#41; + Position.Y&#41;;
            Release;
          end;
        end;
      end;
    end;
    P.S.: I know my code is shit at places and that spark thing is very lame, but I'm a lazy person, so don't tell me about these...

  7. #37

    Need help with DrawAlpha

    Well that's new approach alright Never seen images held as surfaces in that scale before...propably 1 reason for problems. TDXImageList was made for the purpose of holding all game graphics. To manually fill it from files, there is much discussion around internet so i'm not going into details now... no Delphi open and all

  8. #38

    Need help with DrawAlpha

    Well that's new approach alright
    Not at all. It's also how I have been doing things when I used DelphiX. Its also one of the ways in the demos provided. It works quite well IMO.

    note: I've always used the last version of DelphiX by Hori and not any of the newer (undelphix and newer) made by other developers.

  9. #39

    Need help with DrawAlpha

    Quote Originally Posted by Traveler
    note: I've always used the last version of DelphiX by Hori and not any of the newer (undelphix and newer) made by other developers.
    It's well, I want collect all changes from developers around the world and put it into last version unDelphiX.

    Many developers no work in DelphiX now, their links no lives on Internet and others developer waiting only complete and fully functional version. Anybody not want spend their time to learn basics, at first clamp they run off. Because unDelphi is perfect not yet , they rather vote C++ and pure DX or any OpenGL version without Delphi (and when you can use Delphi from now on? Try Asphyre instead! Or anything other!). Framework unDelphiX is trifle now only... it is sad reality. And position DelphiX in Japan, where DelphiX was born, is the same or worse.

    :idea:
    Ijcro.

  10. #40

    Need help with DrawAlpha

    Well, I just like DelphiX's approach, but this is my first real thing in fact, so that's about why I used it... I wanna learn C++ and pure DirectX too and try to go for being a real game programmer... But first I should finnish this as a good prog for my finals at school

Page 4 of 5 FirstFirst ... 2345 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •