static void
snowThink (SnowScreen *ss,
	   SnowFlake  *sf)
{
    int boxing;

    boxing = firefliesGetScreenBoxing (ss->s->display);

    sf->age += 0.01;
	sf->lifecycle = (sf->age / 10) / sf->lifespan * (firefliesGetSnowSpeed(ss->s->display) / 10);

	int glowStage = (sf->lifecycle * GLOW_STAGES);
	sf->glowAlpha = bezierCurve(glowCurve[glowStage], sf->lifecycle);
	//if (sf->glowAlpha > 1.0)
	//	sf->glowAlpha = 1.0;

	if (	sf->y <= -boxing
			||  sf->y >= ss->s->height + boxing
			|| 	sf->x <= -boxing
			|| 	sf->x >= ss->s->width + boxing
			|| 	sf->z <= -((float) firefliesGetScreenDepth (ss->s->display))
			|| 	sf->z >= 1
			||  sf->age > sf->lifespan)

	{
		initiateSnowFlake(ss,sf);
	}
	snowMove(ss->s->display, sf);
}
예제 #2
0
파일: snow.c 프로젝트: jordigh/fusilli
static void
snowThink (SnowScreen *ss,
           SnowFlake  *sf)
{
	int boxing;

	const BananaValue *
	option_screen_boxing = bananaGetOption (bananaIndex,
	                                        "screen_boxing",
	                                        -1);

	const BananaValue *
	option_screen_depth = bananaGetOption (bananaIndex,
	                                        "screen_depth",
	                                        -1);

	boxing = option_screen_boxing->i;

	if (sf->y >= ss->s->height + boxing ||
	    sf->x <= -boxing ||
	    sf->y >= ss->s->width + boxing ||
	    sf->z <= -((float) option_screen_depth->i / 500.0) ||
	    sf->z >= 1)
	{
		initiateSnowFlake (ss, sf);
	}

	snowMove (sf);
}
예제 #3
0
static void
snowThink (SnowScreen *ss,
	   SnowFlake  *sf)
{
    int boxing;

    boxing = starGetScreenBoxing (ss->s->display);

    if (sf->y >= ss->s->height + boxing ||
	sf->x <= -boxing ||
	sf->y >= ss->s->width + boxing ||
	sf->z <= -((float) starGetScreenDepth (ss->s->display) / 500.0) ||
	sf->z >= 1)
    {
	initiateSnowFlake (ss, sf);
    }
    snowMove (ss->s->display, sf);
}
예제 #4
0
static Bool
snowInitScreen (CompPlugin *p,
		CompScreen *s)
{
    SnowScreen *ss;
    int        i, numFlakes = starGetNumSnowflakes (s->display);
    SnowFlake  *snowFlake;

    SNOW_DISPLAY (s->display);

    ss = calloc (1, sizeof(SnowScreen));

    s->base.privates[sd->screenPrivateIndex].ptr = ss;

    ss->s = s;
    ss->snowTexturesLoaded = 0;
    ss->snowTex = NULL;
    ss->active = FALSE;
    ss->displayListNeedsUpdate = FALSE;

    ss->allSnowFlakes = snowFlake = malloc (numFlakes * sizeof (SnowFlake));

    for (i = 0; i < numFlakes; i++)
    {
	initiateSnowFlake (ss, snowFlake);
	setSnowflakeTexture (ss, snowFlake);
	snowFlake++;
    }

    updateSnowTextures (s);
    setupDisplayList (ss);

    WRAP (ss, s, paintOutput, snowPaintOutput);
    WRAP (ss, s, drawWindow, snowDrawWindow);

    ss->timeoutHandle = compAddTimeout (starGetSnowUpdateDelay (s->display),
					starGetSnowUpdateDelay (s->display) * 1.2, stepSnowPositions, s);

    return TRUE;
}
예제 #5
0
static void
snowDisplayOptionChanged (CompDisplay        *d,
			  CompOption         *opt,
			  StarDisplayOptions num)
{
    SNOW_DISPLAY (d);

    switch (num)
    {
    case StarDisplayOptionSnowSize:
	{
	    CompScreen *s;

	    for (s = d->screens; s; s = s->next)
	    {
		SNOW_SCREEN (s);
		ss->displayListNeedsUpdate = TRUE;
		updateSnowTextures (s);
	    }
	}
	break;
    case StarDisplayOptionSnowUpdateDelay:
	{
	    CompScreen *s;

	    for (s = d->screens; s; s = s->next)
	    {
		SNOW_SCREEN (s);

		if (ss->timeoutHandle)
		    compRemoveTimeout (ss->timeoutHandle);
		ss->timeoutHandle =
		    compAddTimeout (starGetSnowUpdateDelay (d),
									   starGetSnowUpdateDelay (d) *1.2,  stepSnowPositions, s);
	    }
	}
	break;
    case StarDisplayOptionNumSnowflakes:
	{
	    CompScreen *s;
	    int        i, numFlakes;
	    SnowFlake  *snowFlake;

	    numFlakes = starGetNumSnowflakes (d);
	    for (s = d->screens; s; s = s->next)
	    {
		SNOW_SCREEN (s);
		ss->allSnowFlakes = realloc (ss->allSnowFlakes,
					     numFlakes * sizeof (SnowFlake));
		snowFlake = ss->allSnowFlakes;

		for (i = 0; i < numFlakes; i++)
		{
		    initiateSnowFlake (ss, snowFlake);
		    setSnowflakeTexture (ss, snowFlake);
		    snowFlake++;
		}
	    }
	}
	break;
    case StarDisplayOptionSnowTextures:
	{
	    CompScreen *s;
	    CompOption *texOpt;

	    texOpt = starGetSnowTexturesOption (d);

	    sd->snowTexFiles = texOpt->value.list.value;
	    sd->snowTexNFiles = texOpt->value.list.nValue;

	    for (s = d->screens; s; s = s->next)
		updateSnowTextures (s);
	}
	break;
    default:
	break;
    }
}
예제 #6
0
파일: snow.c 프로젝트: jordigh/fusilli
static void
snowChangeNotify (const char        *optionName,
                  BananaType        optionType,
                  const BananaValue *optionValue,
                  int               screenNum)
{
	SNOW_DISPLAY (&display);

	if (strcasecmp (optionName, "snow_size") == 0)
	{
		CompScreen *s;

		for (s = display.screens; s; s = s->next)
		{
			SNOW_SCREEN (s);
			ss->displayListNeedsUpdate = TRUE;
			updateSnowTextures (s);
		}
	}
	else if (strcasecmp (optionName, "snow_update_delay") == 0)
	{
		CompScreen *s;

		for (s = display.screens; s; s = s->next)
		{
			SNOW_SCREEN (s);

			if (ss->timeoutHandle)
				compRemoveTimeout (ss->timeoutHandle);
			ss->timeoutHandle =
			    compAddTimeout (optionValue->i,
			            (float) optionValue->i * 1.2,
			            stepSnowPositions, s);
		}
	}
	else if (strcasecmp (optionName, "num_snowflakes") == 0)
	{
		CompScreen *s;
		int        i, numFlakes;
		SnowFlake  *snowFlake;

		numFlakes = optionValue->i;
		for (s = display.screens; s; s = s->next)
		{
			SNOW_SCREEN (s);
			ss->allSnowFlakes = realloc (ss->allSnowFlakes,
			                             numFlakes * sizeof (SnowFlake));
			snowFlake = ss->allSnowFlakes;

			for (i = 0; i < numFlakes; i++)
			{
				initiateSnowFlake (ss, snowFlake);
				setSnowflakeTexture (ss, snowFlake);
				snowFlake++;
			}
		}
	}
	else if (strcasecmp (optionName, "snow_textures") == 0)
	{
		CompScreen *s;

		for (s = display.screens; s; s = s->next)
			updateSnowTextures (s);
	}
	else if (strcasecmp (optionName, "toggle_key") == 0)
		updateKey (optionValue->s, &sd->toggle_key);

}
예제 #7
0
파일: snow.c 프로젝트: jordigh/fusilli
static Bool
snowInitScreen (CompPlugin *p,
                CompScreen *s)
{
	SnowScreen *ss;

	const BananaValue *
	option_num_snowflakes = bananaGetOption (bananaIndex,
	                                         "num_snowflakes",
	                                         -1);

	const BananaValue *
	option_snow_update_delay = bananaGetOption (bananaIndex,
	                                            "snow_update_delay",
	                                            -1);

	int        i, numFlakes = option_num_snowflakes->i;
	SnowFlake  *snowFlake;

	SNOW_DISPLAY (&display);

	ss = calloc (1, sizeof(SnowScreen));
	if (!ss)
		return FALSE;

	s->privates[sd->screenPrivateIndex].ptr = ss;

	ss->s = s;
	ss->snowTexturesLoaded = 0;
	ss->snowTex = NULL;
	ss->active = FALSE;
	ss->displayListNeedsUpdate = FALSE;

	ss->allSnowFlakes = snowFlake = malloc (numFlakes * sizeof (SnowFlake));
	if (!snowFlake)
	{
		free (ss);
		return FALSE;
	}

	for (i = 0; i < numFlakes; i++)
	{
		initiateSnowFlake (ss, snowFlake);
		setSnowflakeTexture (ss, snowFlake);
		snowFlake++;
	}

	updateSnowTextures (s);
	setupDisplayList (ss);

	WRAP (ss, s, paintOutput, snowPaintOutput);
	WRAP (ss, s, drawWindow, snowDrawWindow);

	ss->timeoutHandle = compAddTimeout (option_snow_update_delay->i,
	                (float)
	                option_snow_update_delay->i *
	                1.2,
	                stepSnowPositions, s);

	return TRUE;
}