diff options
Diffstat (limited to 'movement.c')
-rw-r--r-- | movement.c | 31 |
1 files changed, 16 insertions, 15 deletions
@@ -16,11 +16,12 @@ SnowflakeTransform (snowflakeRec * snow) void newSnowflakePosition(SnowglobeScreen *as, int i) { - int sector = NRAND(hSize); - float ang = randf(2*PI/q)-PI/q; - float r = (radius-0.01*as->snow[i].size/2); - float factor = sinf(PI*(0.5-1/q))/sinf(PI*(0.5-1/q)+fabsf(ang)); - ang += (0.5+((float) sector))*2*PI/q; + int sector = NRAND(as->hsize); + float ang = randf(as->arcAngle*toRadians)-0.5*as->arcAngle*toRadians; + float r = (as->radius-0.01*as->snow[i].size/2); + float factor = sinf(0.5*(PI-as->arcAngle*toRadians))/ + sinf(0.5*(PI-as->arcAngle*toRadians)+fabsf(ang)); + ang += (0.5+((float) sector))*as->arcAngle*toRadians; ang = fmodf(ang,2*PI); float d = randf(1); @@ -47,7 +48,7 @@ SnowflakeDrift (CompScreen *s, int index) snowflakeRec * snow = &(as->snow[index]); - float speed = snow->speed*speedFactor; + float speed = snow->speed*as->speedFactor; speed/=1000; float x = snow->x; float y = snow->y; @@ -75,7 +76,7 @@ SnowflakeDrift (CompScreen *s, int index) } - float bottom = (renderGround ? getHeight(as->ground, x, y) : -0.5)+0.01*snow->size/2; + float bottom = (snowglobeGetShowGround(s) ? getHeight(as->ground, x, y) : -0.5)+0.01*snow->size/2; if (z<bottom) { @@ -93,22 +94,22 @@ SnowflakeDrift (CompScreen *s, int index) } - float ang = atan2(y, x); + float ang = atan2f(y, x); int i; - for (i=0; i<hSize; i++) + for (i=0; i< as->hsize; i++) { - float cosAng = cosf(fmodf(2*i*PI/q-ang, 2*PI)); + float cosAng = cosf(fmodf(i*as->arcAngle*toRadians-ang, 2*PI)); if (cosAng<=0) continue; float r = hypotf(x, y); - float d = r*cosAng-(distance-0.01*snow->size/2); + float d = r*cosAng-(as->distance-0.01*snow->size/2); if (d>0) { - x -= d*cosf(ang)*fabsf(cosf(2*i*PI/q)); - y -= d*sinf(ang)*fabsf(sinf(2*i*PI/q)); + x -= d*cosf(ang)*fabsf(cosf(i*as->arcAngle*toRadians)); + y -= d*sinf(ang)*fabsf(sinf(i*as->arcAngle*toRadians)); } } @@ -116,6 +117,6 @@ SnowflakeDrift (CompScreen *s, int index) snow->y = y; snow->z = z; - snow->psi = fmodf(snow->psi+snow->dpsi*speedFactor, 360); - snow->theta= fmodf(snow->theta+snow->dtheta*speedFactor, 360); + snow->psi = fmodf(snow->psi+snow->dpsi*as->speedFactor, 360); + snow->theta= fmodf(snow->theta+snow->dtheta*as->speedFactor, 360); } |