Esempio n. 1
0
void speed_switching(void)
{
	shutter0.w = shutter1.w;

	count_x = count_x0;
	count_y = count_y0;

	sign_count_x3=sign_of(count_x3);
	sign_count_x2=sign_of(count_x2);
	sign_count_x1=sign_of(count_x1);
	sign_count_y3=sign_of(count_y3);
	sign_count_y2=sign_of(count_y2);
	sign_count_y1=sign_of(count_y1);

	count_x3 = count_x2;
	count_y3 = count_y2;
	count_x2 = count_x1;
	count_y2 = count_y1;
	count_x1 = (signed char) delta_x;
	count_y1 = (signed char) delta_y;

}
Esempio n. 2
0
/*
 * Cette fonction update la position du joueur en fonction de
 * Sa vitesse et des différents obstacles sur la map
 */
 void update_a_modifs(double *sens_x, double *sens_y, double v_x, double v_y, double *x_modif, double *y_modif, double * range)
{
    *sens_x = sign_of(v_x);
    *sens_y = sign_of(v_y);

    if ( (fabs(v_x)<0.01)             /* (x2 == x1) */
    &&   (fabs(v_y)>0.01) )           /* (y2 != y1) */
    {
        if   (fabs(v_y)>1)
        {
            *x_modif = 0;
            *y_modif = *sens_y;
            *range   = fabs(v_y);
        }
        else
        {
            *x_modif = 0;
            *y_modif = v_y;
            *range   = 1;
        }
    }

    else if ( (fabs(v_x)>0.01)        /* (x2 != x1) */
         &&   (fabs(v_y)<0.01) )      /* (y2 == y1) */
    {
        if   (fabs(v_x)>1)
        {
            *x_modif = *sens_x;
            *y_modif = 0;
            *range   = fabs(v_x);
        }
        else
        {
            *x_modif = v_x;
            *y_modif = 0;
            *range   = 1;
        }
    }
    else                                /* (x2 != x1) */
    {                                   /* (y2 != y1) */
        if (fabs(v_y) > fabs(v_x))
        {
            if   (fabs(v_y) > 1)
            {
                *x_modif = *sens_x *fabs(v_x/v_y);
                *y_modif = *sens_y;
                *range   = fabs(v_y);
            }
            else
            {
                *x_modif = v_x;
                *y_modif = v_y;
                *range   = 1;
            }
        }
        else
        {
            if   (fabs(v_x) > 1)
            {
                *x_modif = *sens_x;
                *y_modif = *sens_y * fabs(v_y/v_x);
                *range   = fabs(v_x);
            }
            else
            {
                *x_modif = v_x;
                *y_modif = v_y;
                *range   = 1;
            }
        }
    }
}