Pixel based transparency effect

Started by newwaveburritos, Sun 15/05/2022 19:17:28

Previous topic - Next topic

newwaveburritos

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: ags

int trans = cEgo.Transparency;
while (trans < 100) {
  trans++;
  cEgo.Transparency = trans;
  Wait(1);
}


Thanks, everybody!

FanOfHumor

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: ags

int pixwide;
int pixheight;
int coverpixelplaced;
function room_AfterFadeIn()
{   
	
}

function room_RepExec()
{
	player.Baseline=-2000;
	pixwide = Random(Game.SpriteWidth[2000]);
	pixheight=Random(Game.SpriteHeight[2000]);
	DynamicSprite* draw;
	if(coverpixelplaced==Game.SpriteWidth[2000]||Game.SpriteHeight[2000])
	{
		//draw.Delete();
		//way to make character invisible;
	}	
	else
	{
		draw=DynamicSprite.CreateFromBackground(0,player.x+pixwide, player.y+pixheight, 1,1 );
		coverpixelplaced+=1;
	}
}

Khris

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

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.

SMF spam blocked by CleanTalk