Jibble

There is a new version of the forums ready for testing. Please post here if you're willing to help test! We could also use the help of coders!

Author Topic: Pixel based transparency effect  (Read 210 times)

newwaveburritos

  • Party Weekend
    • newwaveburritos worked on one or more games that was nominated for an AGS Award!
Pixel based transparency effect
« on: 15 May 2022, 19:17 »
My game is not a true 8 bit game but I do use the sixteen color palette exclusively as as an aesthetic decision.  Thus, using character fade outs and ins kind of feels like cheating to me.  When I import a sprite it has a transparency mask already so I'm wondering if there's a way to randomly replace pixels in the sprite with this transparency mask one by one until the whole sprite is then transparent.  This would look a lot better to my eye than having a character fadeout like from the manual:

Code: [Select]
int trans = cEgo.Transparency;
while (trans < 100) {
  trans++;
  cEgo.Transparency = trans;
  Wait(1);
}

Thanks, everybody!

Pajama Sam

  • Sam's The name
Re: Pixel based transparency effect
« Reply #1 on: 15 May 2022, 21:13 »
I was interested with your idea so I thought i'd try it.I didn't get it to work the way I was doing it but if you would like to try to get what I have to work here it is.
Code: Adventure Game Studio
  1. int pixwide;
  2. int pixheight;
  3. int coverpixelplaced;
  4. function room_AfterFadeIn()
  5. {  
  6.        
  7. }
  8.  
  9. function room_RepExec()
  10. {
  11.         player.Baseline=-2000;
  12.         pixwide = Random(Game.SpriteWidth[2000]);
  13.         pixheight=Random(Game.SpriteHeight[2000]);
  14.         DynamicSprite* draw;
  15.         if(coverpixelplaced==Game.SpriteWidth[2000]||Game.SpriteHeight[2000])
  16.         {
  17.                 //draw.Delete();
  18.                 //way to make character invisible;
  19.         }      
  20.         else
  21.         {
  22.                 draw=DynamicSprite.CreateFromBackground(0,player.x+pixwide, player.y+pixheight, 1,1 );
  23.                 coverpixelplaced+=1;
  24.         }
  25. }
  26.  

Re: Pixel based transparency effect
« Reply #2 on: 17 May 2022, 12:27 »
I made a module:
https://drive.google.com/file/d/1AMUHSUMq_xoszQBP6WUbxCZNVvQb4_7Y/view?usp=sharing

void Character.PixelFade(FadeType fadeType, int width, int speed)

FadeType is eFadeOut or eFadeIn.
width is the width of a single strip of pixels that grows transparent; try a value like 10
speed is the number of frames in between single pixels, use a low number like 3 (smaller number -> faster fading)


newwaveburritos

  • Party Weekend
    • newwaveburritos worked on one or more games that was nominated for an AGS Award!
Re: Pixel based transparency effect
« Reply #3 on: 17 May 2022, 17:02 »
Oh wow!  This is amazing and exactly what I meant.  So, I guess that no there is not really an easy way to do it but there is certainly a way.  Thanks so much for putting that together.