static void initiateElement (screen *eScreen, element *ele) { int i, iii; if (ele->type == 4) { float temp = mmRand(elementsGetViscosity( eScreen->cScreen->display)/2.0,elementsGetViscosity( eScreen->cScreen->display),50.0); float xSway = 1.0 - temp*temp * 1.0 / 4.0; for (iii=0; iii<MAX_AUTUMN_AGE; iii++) { ele->autumnFloat[0][iii] = -xSway + (iii * ((2 * xSway)/(MAX_AUTUMN_AGE-1))); } ele->autumnAge[0] = getRand(0,MAX_AUTUMN_AGE-1); ele->autumnAge[1] = ele->autumnAge[0]; ele->x = mmRand (0, eScreen->cScreen->width, 1); ele->autumnChange = 1; ele->y = mmRand (eScreen->cScreen->height+100, eScreen->cScreen->height+ BIG_NUMBER,1); ele->dy[0] = mmRand (-2, -1, 5); } if (ele->type == 0) { float xSway = mmRand(elementsGetAutumnSway( eScreen->cScreen->display)/2,elementsGetAutumnSway( eScreen->cScreen->display),2.0); float ySway = elementsGetAutumnSpeed(eScreen->cScreen->display) / 20.0; for (iii=0; iii<MAX_AUTUMN_AGE; iii++) { ele->autumnFloat[0][iii] = -xSway + (iii * ((2 * xSway)/(MAX_AUTUMN_AGE-1))); } for (iii=0; iii<(MAX_AUTUMN_AGE / 2); iii++) { ele->autumnFloat[1][iii] = -ySway + (iii * ((2 * ySway)/(MAX_AUTUMN_AGE-1))); } for (; iii<MAX_AUTUMN_AGE; iii++) { ele->autumnFloat[1][iii] = ySway - (iii * ((2 * ySway)/(MAX_AUTUMN_AGE-1))); } ele->autumnAge[0] = getRand(0,MAX_AUTUMN_AGE-1); ele->autumnAge[1] = getRand(0,(MAX_AUTUMN_AGE/2)-1); ele->x = mmRand (0, eScreen->cScreen->width, 1); ele->autumnChange = 1; ele->y = -mmRand (100, BIG_NUMBER, 1); ele->dy[0] = mmRand (-2, -1, 5); } if (ele->type == 2) { int snowSway = elementsGetSnowSway (eScreen->cScreen->display); switch (elementsGetWindDirection (eScreen->cScreen->display)) { case WindDirectionNone: ele->x = mmRand (0, eScreen->cScreen->width, 1); ele->dx[0] = mmRand (-snowSway, snowSway, 1.0); ele->y = mmRand (-BIG_NUMBER, -100, 1); ele->dy[0] = mmRand (1, 3, 1); break; case WindDirectionUp: ele->x = mmRand (0, eScreen->cScreen->width, 1); ele->dx[0] = mmRand (-snowSway, snowSway, 1.0); ele->y = mmRand (eScreen->cScreen->height + 100, eScreen->cScreen->height + BIG_NUMBER, 1); ele->dy[0] = -mmRand (1, 3, 1); break; case WindDirectionLeft: ele->x = mmRand (eScreen->cScreen->width+100, eScreen->cScreen->width+BIG_NUMBER, 1); ele->dx[0] = -mmRand (1, 3, 1); ele->y = mmRand (0, eScreen->cScreen->height, 1); ele->dy[0] = mmRand (-snowSway, snowSway, 1.5); break; case WindDirectionRight: ele->x = mmRand (-BIG_NUMBER, -100, 1); ele->dx[0] = mmRand (1, 3, 1); ele->y = mmRand (0, eScreen->cScreen->height, 1); ele->dy[0] = mmRand (-snowSway, snowSway, 1.5); break; default: break; } } ele->z = mmRand (-elementsGetScreenDepth (eScreen->cScreen->display), 0.1, 5000); ele->dz[0] = mmRand (-500, 500, 500000); ele->rAngle = mmRand (-1000, 1000, 50); ele->rSpeed = mmRand (-2100, 2100, 700); if (ele->type == 1) { ele->x = mmRand(0, eScreen->cScreen->width, 1); ele->y = mmRand(0, eScreen->cScreen->height, 1); ele->lifespan = mmRand(50,1000, 100); ele->age = 0.0; for (i = 0; i < 4; i++) { ele->dx[i] = mmRand(-3000, 3000, 200); ele->dy[i] = mmRand(-2000, 2000, 200); ele->dz[i] = mmRand(-1000, 1000, 500000); } } if (ele->type == 3) { float init; ele->dx[0] = mmRand(-50000, 50000, 5000); ele->dy[0] = mmRand(-50000, 50000, 5000); ele->dz[0] = mmRand(000, 200, 2000); ele->x = eScreen->cScreen->width * .5 + elementsGetStarOffsetX (eScreen->cScreen->display); // X Offset ele->y = eScreen->cScreen->height * .5 + elementsGetStarOffsetY (eScreen->cScreen->display); // Y Offset ele->z = mmRand(000, 0.1, 5000); init = mmRand(0,100, 1); ele->x += init * ele->dx[0]; ele->y += init * ele->dy[0]; } }
static void initiateSnowFlake (SnowScreen *ss, SnowFlake *sf) { /* TODO: possibly place snowflakes based on FOV, instead of a cube. */ const BananaValue * option_screen_boxing = bananaGetOption (bananaIndex, "screen_boxing", -1); const BananaValue * option_snow_direction = bananaGetOption (bananaIndex, "snow_direction", -1); const BananaValue * option_screen_depth = bananaGetOption (bananaIndex, "screen_depth", 1); int boxing = option_screen_boxing->i; switch (option_snow_direction->i) { case 0: //Top To Bottom sf->x = mmRand (-boxing, ss->s->width + boxing, 1); sf->xs = mmRand (-1, 1, 500); sf->y = mmRand (-300, 0, 1); sf->ys = mmRand (1, 3, 1); break; case 1: //Bottom To Top sf->x = mmRand (-boxing, ss->s->width + boxing, 1); sf->xs = mmRand (-1, 1, 500); sf->y = mmRand (ss->s->height, ss->s->height + 300, 1); sf->ys = -mmRand (1, 3, 1); break; case 2: //Right To Left sf->x = mmRand (ss->s->width, ss->s->width + 300, 1); sf->xs = -mmRand (1, 3, 1); sf->y = mmRand (-boxing, ss->s->height + boxing, 1); sf->ys = mmRand (-1, 1, 500); break; case 3: //Left To Right sf->x = mmRand (-300, 0, 1); sf->xs = mmRand (1, 3, 1); sf->y = mmRand (-boxing, ss->s->height + boxing, 1); sf->ys = mmRand (-1, 1, 500); break; default: break; } sf->z = mmRand (-option_screen_depth->i, 0.1, 5000); sf->zs = mmRand (-1000, 1000, 500000); sf->ra = mmRand (-1000, 1000, 50); sf->rs = mmRand (-1000, 1000, 1000); }