fade screen effect slowdown

Posted By: Denn15

fade screen effect slowdown - 02/02/14 16:52

in my game i have a red panel that covers the screen and gets visible and fades out when the player gets hurt, however it makes the fps drop significantly on some computers, so far only laptops, but they should be able to make such an effect without dropping in fps.

i just want to know if there is another way to make the screen fade in and out with a color or if that is the only solution, or if there is a way to optimise it.
Posted By: Ch40zzC0d3r

Re: fade screen effect slowdown - 02/02/14 17:11

Are you using draw_quad to perfomt this action?
draw_quad is (like all other _draw functions) very computing heavy!
Posted By: Denn15

Re: fade screen effect slowdown - 02/02/14 17:18

Code:
function take_damage()
{
	wait(1);
	fadered.scale_x = screen_size.x;
	fadered.scale_y = screen_size.y;
	fadered.alpha = 30;
	effect_sprite("spark.tga", part6, 16, player_box.x, nullvector);
	while (fadered.alpha > 0)
	{
		fadered.alpha = fadered.alpha - 0.5 * 3 * time_step;
		wait (1);
	}
}



This is how i have made the fading effect. fadered is a panel consisting of a 64x64 red image.
Posted By: LemmyTheSlayer

Re: fade screen effect slowdown - 02/02/14 18:01

you might try to replace
Code:
fadered.scale_x = screen_size.x;
fadered.scale_y = screen_size.y;


with
Code:
fadered.scale_x = screen_size.x/64;
fadered.scale_y = screen_size.y/64;



scale_x and scale_y do not set the new panel size, they scale it.
that means, if your screen size is 1024x768, you would have a panel with a width of 1024*64=65536 pixels and a breadth of 768*64=49152 pixels.
that makes 65536*49125=3219456000 pixels in total. of course most of them won't be visible on the screen, but afaik the calculations are made anyway.
Posted By: Uhrwerk

Re: fade screen effect slowdown - 02/02/14 18:36

You're confusing scale_x / y and size_x / y.
Posted By: Denn15

Re: fade screen effect slowdown - 02/02/14 19:17

doing like lemmytheslyaer suggested seems to work well. thanks for your help
© 2024 lite-C Forums