• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ RAD函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中RAD函数的典型用法代码示例。如果您正苦于以下问题:C++ RAD函数的具体用法?C++ RAD怎么用?C++ RAD使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了RAD函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: trajectory_set_windows

/** set windows for trajectory */
void trajectory_set_windows(struct trajectory *traj, double d_win,
			    double a_win_deg, double a_start_deg)
{
    traj->d_win = d_win ;
    traj->a_win_rad = RAD(a_win_deg);
	traj->a_start_rad = RAD(a_start_deg);
}
开发者ID:31415us,项目名称:modules,代码行数:8,代码来源:trajectory_manager.c


示例2: find_wall

float	find_wall(t_env *env , int **map, float each_x, unsigned int *color)
{
  float	x1;
  float	y1;
  float	k_x;
  float	k_y;
  float	tmp;

  x1 = env->x + 0.5;
  y1 = env->y + each_x;
  tmp = x1;
  x1 = cos(RAD(env->angle)) * (tmp - env->x) - sin(RAD(env->angle))
    * (y1 - env->y);
  y1 = sin(RAD(env->angle)) * (tmp - env->x) + cos(RAD(env->angle))
    * (y1 - env->y);
  k_x = find_x(env, map, x1, y1);
  k_y = find_y(env, map, x1, y1);
  *color = 0;
  (x1 > 0) ? (*color = FIRST_COLOR) : (*color = SECOND_COLOR);
  (k_x > k_y) ? ((y1 > 0) ? (*color = THIRD_COLOR)
		 : (*color = FOURTH_COLOR)) : (0);
  if (k_x > k_y)
    return (k_y);
  return (k_x);
}
开发者ID:sebastiencs,项目名称:wolf3d,代码行数:25,代码来源:find_wall.c


示例3: RAD

void camera_t::focus(real_t newFovX, real_t newFovY)
{
	fov[X] = RAD(newFovX);
	fov[Y] = RAD(newFovY);

	filmSize[X] = static_cast<real_t>( frustum[nearPlane].dist * tan( fov[X]/2 ) * 2 );
	filmSize[Y] = static_cast<real_t>( frustum[nearPlane].dist * tan( fov[Y]/2 ) * 2 );

	frustum[topPlane].normal = forward;
	frustum[topPlane].normal.rotateAround( right, fov[Y]/2 );
	frustum[topPlane].dist = - ( position dot frustum[topPlane].normal );

	frustum[bottomPlane].normal = forward;
	frustum[bottomPlane].normal.rotateAround( right, -fov[Y]/2 );
	frustum[bottomPlane].dist = - ( position dot frustum[bottomPlane].normal );

	frustum[leftPlane].normal = forward;
	frustum[leftPlane].normal.rotateAround( up, fov[X]/2 );
	frustum[leftPlane].dist = - ( position dot frustum[leftPlane].normal );

	frustum[rightPlane].normal = forward;
	frustum[rightPlane].normal.rotateAround( up, -fov[X]/2 );
	frustum[rightPlane].dist = - ( position dot frustum[rightPlane].normal );

	frustum[nearPlane].normal = forward;
	frustum[nearPlane].dist = 1;

	frustum[farPlane].normal = -forward;
	frustum[farPlane].dist = 1000;
}
开发者ID:valentingalea,项目名称:newpas,代码行数:30,代码来源:CAMERA.CPP


示例4: rotate

	vec3 &		rotate(vec3 angle)
	{
		vec3	radangle = { RAD(angle.x), RAD(angle.y), RAD(angle.z) };
		vec3	tmpsin = { sin(radangle.x), sin(radangle.y), sin(radangle.z) };
		vec3	tmpcos = { cos(radangle.x), cos(radangle.y), cos(radangle.z) };
		return rotateByCache(tmpsin, tmpcos);
	}
开发者ID:JeanGamain,项目名称:jmax,代码行数:7,代码来源:vec3.hpp


示例5: RAD

int cPositioner::CalcHourAngle(int Longitude)
{
  double Alpha = RAD(Longitude - Setup.SiteLon);
  double Lat = RAD(Setup.SiteLat);
  int Sign = Setup.SiteLat >= 0 ? -1 : 1; // angles to the right are positive, angles to the left are negative
  return Sign * round(DEG(atan2(sin(Alpha), cos(Alpha) - cos(Lat) * SAT_EARTH_RATIO)));
}
开发者ID:nvertigo,项目名称:vdr,代码行数:7,代码来源:positioner.c


示例6: calc_delta_cone

double	calc_delta_cone(t_object *object, double *vect, t_cam *cam)
{
  double	a;
  double	b;
  double	c;
  double	delta;
  t_point	*point;
  t_point	*point2;
  double	r;

  point = init_point(vect[X], vect[Y], vect[Z], 0);
  point2 = init_point(cam->x, cam->y, cam->z, 0);
  point2 = inv_rotate(point2, (t_cam *) object);
  point = inv_rotate(point, (t_cam *) object);
  r = (double) object->r;
  a = (pow(point->x, 2) + pow(point->z, 2) - (pow(point->y, 2) * pow(tan(RAD(r)), 2)));
  b = 2 * ((point->x * (point2->x - object->x)) + (point->z * (point2->z - object->z))
	   - (point->y * (point2->y - object->y) * pow(tan(RAD(r)), 2)));
  c = pow((point2->x - object->x), 2) + pow((point2->z - object->z), 2) 
       - (pow(((point2->y - object->y)), 2) * pow(tan(RAD(r)), 2));
  delta = (b * b) - (4.0 * a * c);
  vect[X] = b;
  vect[Y] = a;
  return (delta);
}
开发者ID:Frozenhorns,项目名称:project,代码行数:25,代码来源:calc_delta.c


示例7: star_parse_hip

int star_parse_hip(struct star *s, FILE *fp)
{
    char buf[STAR_HIP_RECLEN + 1];

    /* Constants for use in computing galactic coordinates. */

    const double c1 = PI * 282.25 / 180.0;
    const double c2 = PI *  62.6  / 180.0;
    const double c3 = PI *  33.0  / 180.0;

    /* Read a single line from the given file. */

    if (fgets(buf, STAR_HIP_RECLEN + 1, fp))
    {
        double ra;
        double de;
        double mag;
        double plx;

        /* Attempt to parse necessary data from the line. */

        if (sscanf(buf + 51, "%lf", &ra)  == 1 &&
            sscanf(buf + 64, "%lf", &de)  == 1 &&
            sscanf(buf + 41, "%lf", &mag) == 1 &&
            sscanf(buf + 79, "%lf", &plx) == 1 && plx > 0.0)
        {
            double b, l, n1, n2, n3;

            /* Compute equatorial position in parsecs and radians. */

            plx = 1000.0 / fabs(plx);
            ra  = RAD(ra);
            de  = RAD(de);

            /* Compute the position in galactic coordinates. */
            n1 =                     cos(de) * cos(ra - c1);
            n2 = sin(de) * sin(c2) + cos(de) * sin(ra - c1) * cos(c2);
            n3 = sin(de) * cos(c2) - cos(de) * sin(ra - c1) * sin(c2);

            l = -atan2(n1, n2) + c3;
            b =  asin(n3);

            /* l = ra; */
            /* b = de; */

            s->pos[0] = (float) (sin(l) * cos(b) * plx);
            s->pos[1] = (float) (         sin(b) * plx);
            s->pos[2] = (float) (cos(l) * cos(b) * plx);

            /* Compute the absolute magnitude and color. */

            s->mag =  (float) (mag - 5.0 * log(plx / 10.0) / log(10.0));

            star_color(buf[435], s->col);
            
            return 1;
        }
    }
    return 0;
}
开发者ID:johnh530,项目名称:electro,代码行数:60,代码来源:star.c


示例8: calculate_solar_azimuth

//sjin: add solar azimuth wrapper funcions
EXPORT int64 calculate_solar_azimuth(OBJECT *obj, double lititude, double *value)
{
	static SolarAngles sa; // just for the functions
	double std_time = 0.0;
	double solar_time = 0.0;
	short int doy = 0;
	DATETIME dt;

	climate *cli;
	if (obj == 0 || value == 0){
		//throw "climate/calc_solar: null object pointer in arguement";
		return 0;
	}
	cli = OBJECTDATA(obj, climate);
	if(gl_object_isa(obj, "climate", "climate") == 0){
		//throw "climate/calc_solar: input object is not a climate object";
		return 0;
	}

	gl_localtime(obj->clock, &dt);
	std_time = (double)(dt.hour) + ((double)dt.minute)/60.0 + (dt.is_dst ? -1:0);
	solar_time = sa.solar_time(std_time, doy, RAD(cli->tz_meridian), RAD(obj->longitude));

	double hr_ang = -(15.0 * PI_OVER_180)*(solar_time-12.0); // morning +, afternoon -

    double decl = 0.409280*sin(2.0*PI*(284+doy)/365);

	double alpha = (90.0 * PI_OVER_180) - lititude + decl;

	*value = acos( (sin(decl)*cos(lititude) - cos(decl)*sin(lititude)*cos(hr_ang))/cos(alpha) );

    return 1;
}
开发者ID:Noah-Maze,项目名称:windlab-d,代码行数:34,代码来源:climate.cpp


示例9: display

void
display(void) {
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    glLoadIdentity();
#define RAD(x) (((x)*M_PI)/180.)
    gluLookAt(-sinf(RAD(rotx))*5.5,transy,cosf(RAD(rotx))*5.5, 0.,0.,0., 0.,1.,0.);

    glTranslatef(0.f, 0.f, transx*10.f);

    /* floor */
    glColor4f(0.f,.2f,0.f,1.f);
    glBegin(GL_POLYGON);
	glVertex3f(-4.0, -1.0, -4.0);
	glVertex3f( 4.0, -1.0, -4.0);
	glVertex3f( 4.0, -1.0,  4.0);
	glVertex3f(-4.0, -1.0,  4.0);
    glEnd();

    glEnable(GL_COLOR_MATERIAL);
    glEnable(GL_LIGHTING);
    glColor3f(.1f,.1f,.1f);
    glPushMatrix();
    glTranslatef(-1.f, -1.+.2f, -1.5f);
    glScalef(.2f,.2f, .2f);
    logs();
    glDisable(GL_LIGHTING);
    glPopMatrix();

    glPushMatrix();
    glTranslatef(-1.f, -1.f+.2f, -1.5f);
    calcMatrix();
    draw_smoke(smoke);
    glPopMatrix();

    glPushMatrix();
    glTranslatef(-1.f, -.25f, -1.5f);
    calcMatrix();
    glScalef(1.f,1.f,1.);
    if (texture) {
	glBindTexture(GL_TEXTURE_2D, the_texture+1);
	glEnable(GL_TEXTURE_2D);
    }
    glColor4f(intensity, intensity, intensity, opacity);
    glRotatef(rot, 0., 0., 1.);
    glDepthMask(0);
    glBegin(GL_POLYGON);
	glTexCoord2f(0.0, 0.0); glVertex2f(-1.0, -1.0);
	glTexCoord2f(1.0, 0.0); glVertex2f(1.0, -1.0);
	glTexCoord2f(1.0, 1.0); glVertex2f(1.0, 1.0);
	glTexCoord2f(0.0, 1.0); glVertex2f(-1.0, 1.0);
    glEnd();
    glDepthMask(1);
    glPopMatrix();
    glDisable(GL_TEXTURE_2D);

    glutSwapBuffers();
}
开发者ID:mox601,项目名称:grafica,代码行数:58,代码来源:fire.c


示例10: star_parse_tyc

int star_parse_tyc(struct star *s, FILE *fp)
{
    char buf[STAR_TYC_RECLEN + 1];

    /* Constants for use in computing galactic coordinates. */

    const double c1 = PI * 282.25 / 180.0;
    const double c2 = PI *  62.6  / 180.0;
    const double c3 = PI *  33.0  / 180.0;

    /* Read a single line from the given file. */

    if (fgets(buf, STAR_TYC_RECLEN + 1, fp))
    {
        double ra, de;
        double bt, vt;
        double mag;
        double plx;
        int    hip;

        /* Attempt to parse necessary data from the line. */

        if (sscanf(buf + 142, "%d",  &hip) == 0 &&
            sscanf(buf + 152, "%lf", &ra)  == 1 &&
            sscanf(buf + 165, "%lf", &de)  == 1 &&
            sscanf(buf + 110, "%lf", &bt)  == 1 &&
            sscanf(buf + 123, "%lf", &vt)  == 1)
        {
            double b, l, n1, n2, n3;
        
            /* Compute equatorial position in parsecs and radians. */
            
            mag = vt - 0.090 * (bt - vt);
            ra  = RAD(ra);
            de  = RAD(de);
            plx = 10.0;

            /* Compute the position in galactic coordinates. */

            n1 =                     cos(de) * cos(ra - c1);
            n2 = sin(de) * sin(c2) + cos(de) * sin(ra - c1) * cos(c2);
            n3 = sin(de) * cos(c2) - cos(de) * sin(ra - c1) * sin(c2);

            l = -atan2(n1, n2) + c3;
            b =  asin(n3);

            s->pos[0] = (GLfloat) (sin(l) * cos(b) * plx);
            s->pos[1] = (GLfloat) (         sin(b) * plx);
            s->pos[2] = (GLfloat) (cos(l) * cos(b) * plx);
            s->mag    =   (float) mag;

            star_color('K', s->col);

            return 1;
        }
    }
    return 0;
}
开发者ID:johnh530,项目名称:electro,代码行数:58,代码来源:star.c


示例11: RAD

void RobotsMover::rotateTable(int counter, float angle_step)
{
    std::vector<double> angles;  
    angles.resize(6);
    angles = p.table_start_pose;
    angles[5] = RAD(180.0) - counter * RAD(angle_step); 
    
    table_mover->moveToPose(angles);
}
开发者ID:roboticlab,项目名称:object_scanner,代码行数:9,代码来源:robots_mover.cpp


示例12: Timer

void Timer(int value)
{
  glutTimerFunc(estado.delayMovimento, Timer, 0);
  // ... accoes do temporizador ... 
  if(estado.teclas.q==GL_TRUE)
	  modelo.tanque.angCanhao+=5;
  if(estado.teclas.a==GL_TRUE)
	  modelo.tanque.angCanhao-=5;
  if(estado.teclas.z==GL_TRUE)
	  modelo.tanque.angTorre-=5;
  if(estado.teclas.x==GL_TRUE)
	  modelo.tanque.angTorre+=5;
  if(estado.teclas.up==GL_TRUE){
	  if(modelo.tanque.velocidade<=1)
			modelo.tanque.velocidade+=0.20;
	  if(modelo.tanque.gForceV<=1)
			modelo.tanque.gForceV+=0.3;
  }else{
	  if(modelo.tanque.velocidade>0)
			modelo.tanque.velocidade-=0.05;
	  if(modelo.tanque.gForceV>=0)
			modelo.tanque.gForceV-=0.3;
  }
  if(estado.teclas.down){
	  if(modelo.tanque.velocidade>=-1)
			modelo.tanque.velocidade-=0.20;
	  if(modelo.tanque.gForceV>=-1)
			modelo.tanque.gForceV-=0.3;
  }else{
	  if(modelo.tanque.velocidade<0)
			modelo.tanque.velocidade+=0.05;
	  if(modelo.tanque.gForceV>=0)
			modelo.tanque.gForceV+=0.3;
  }
  if(estado.teclas.left){
	  if(modelo.tanque.direccaoRodas<=3)
		modelo.tanque.direccaoRodas+=0.5;
  }
  if(estado.teclas.right){
	  if(modelo.tanque.direccaoRodas>=-3)
		modelo.tanque.direccaoRodas-=0.5;
  }

  if(!estado.teclas.left && !estado.teclas.right){
	  modelo.tanque.direccaoRodas = modelo.tanque.direccaoRodas*0.9;
  }

  modelo.tanque.direccao+=modelo.tanque.velocidade*modelo.tanque.direccaoRodas;
  modelo.tanque.x = modelo.tanque.x+modelo.tanque.velocidade*cos(RAD(modelo.tanque.direccao));
  modelo.tanque.y = modelo.tanque.y+modelo.tanque.velocidade*sin(RAD(modelo.tanque.direccao));

  if(estado.menuActivo || modelo.parado) // sair em caso de o jogo estar parado ou menu estar activo
    return;

  // redesenhar o ecra 
  glutPostRedisplay();
}
开发者ID:1100580,项目名称:Cplusplus-graphic-systems,代码行数:57,代码来源:main.cpp


示例13: random_robot_pos2

static Pos2 random_robot_pos2(const FieldGeometry *f) {
  std::uniform_real_distribution<Float> rx(
      -f->field_length / 2 + ROBOT_DIAM / 2,
      f->field_length / 2 + ROBOT_DIAM / 2);
  std::uniform_real_distribution<Float> ry(-f->field_width / 2 + ROBOT_DIAM / 2,
                                           f->field_width / 2 + ROBOT_DIAM / 2);
  std::uniform_real_distribution<Float> rw(-RAD(180), RAD(180));
  // return std::forward(rx(gen), ry(gen), rw(gen));
  return {rx(gen), ry(gen), rw(gen)};
}
开发者ID:gustavokcouto,项目名称:ssl-sim,代码行数:10,代码来源:sslsim.cpp


示例14: acos

int cPositioner::HorizonLongitude(ePositionerDirection Direction)
{
  double Delta;
  if (abs(Setup.SiteLat) <= SAT_VISIBILITY_LAT)
     Delta = acos(SAT_EARTH_RATIO / cos(RAD(Setup.SiteLat)));
  else
     Delta = 0;
  if ((Setup.SiteLat >= 0) != (Direction == pdLeft))
     Delta = -Delta;
  return NormalizeAngle(round(DEG(RAD(Setup.SiteLon) + Delta)));
}
开发者ID:nvertigo,项目名称:vdr,代码行数:11,代码来源:positioner.c


示例15: fit

// Fit
void fit(orbit_t orb,int *ia)
{
  int i,n;
  double a[7],da[7];
  double db[7]={0.1,0.1,0.002,0.1,0.1,0.01,0.0001};

  // Copy parameters
  a[0]=orb.eqinc*R2D;
  da[0]=da[0]*R2D;
  a[1]=orb.ascn*R2D;
  da[1]=da[1]*R2D;
  a[2]=orb.ecc;
  a[3]=orb.argp*R2D;
  da[3]=da[3]*R2D;
  a[4]=orb.mnan*R2D;
  da[4]=da[4]*R2D;
  a[5]=orb.rev;
  a[6]=orb.bstar;

  for (i=0;i<7;i++) {
    if (ia[i]==1)
      da[i]=db[i];
    else
      da[i]=0.0;
  }

  // Construct struct
  // a[0]: inclination
  // a[1]: RA of ascending node
  // a[2]: eccentricity
  // a[3]: argument of periastron
  // a[4]: mean anomaly
  // a[5]: revs per day
  // a[6]: bstar

  // Count highlighted points
  for (i=0,n=0;i<d.n;i++)
    if (d.p[i].flag==1)
      n++;

  if (n>0)
    versafit(n,7,a,da,chisq,0.0,1e-7,"n");

  // Return parameters
  orb.eqinc=RAD(a[0]);
  orb.ascn=RAD(modulo(a[1],360.0));
  orb.ecc=a[2];
  orb.argp=RAD(modulo(a[3],360.0));
  orb.mnan=RAD(modulo(a[4],360.0));
  orb.rev=a[5];
  orb.bstar=a[6];

  return;
}
开发者ID:cbassa,项目名称:sattools,代码行数:55,代码来源:xyz2tle.c


示例16: horizon

/**
	Calculate the solar radation for a surface facing the given compass point.

	@param cpt compass point of the direction the surface is facing
	@param doy day of year
	@param lat latitude of the surface
	@param sol_time the solar time of day
	@param dnr Direct Normal Radiation
	@param dhr Diffuse Horizontal Radiation
	@param ghr Global Horizontal Radiation
	@param gnd_ref Ground Reflectivity
	@param vert_angle the angle of the surface relative to the horizon (Default is 90 degrees)
*/
double tmy2_reader::calc_solar(COMPASS_PTS cpt, short doy, double lat, double sol_time, double dnr, double dhr, double ghr, double gnd_ref, double vert_angle = 90)
{
	SolarAngles *sa = new SolarAngles();
	double surface_angle = surface_angles[cpt];
	double cos_incident = sa->cos_incident(lat,RAD(vert_angle),RAD(surface_angle),sol_time,doy);
	delete sa;
	//double solar = (dnr * cos_incident + dhr/2 + ghr * gnd_ref);
	double solar = dnr * cos_incident + dhr;

	if (peak_solar==0 || solar>peak_solar) peak_solar = solar;
	return solar;
}
开发者ID:Noah-Maze,项目名称:windlab-d,代码行数:25,代码来源:climate.cpp


示例17: vector

Vector vector(Coordinate c){

	Vector v;

	double lat = RAD(c.latitude);
	double lon = RAD(c.longitude);

	v.x = cos(lat) * sin(lon);
	v.y = sin(lat);
	v.z = cos(lat) * cos(lon);

	return v;
}
开发者ID:ubukata,项目名称:estudos,代码行数:13,代码来源:geodist.c


示例18: vsm_get_dr_current

/* calculate the real time current value */
int32_t vsm_get_dr_current(vam_stastatus_t *last, vam_stastatus_t *current)
{
    double deltaT = 0.0;
    double v, s, dR;
    double dir, lon1, lat1, lon2, lat2; /* Radians */
  	uint32_t t = osal_get_systemtime();
    
	if(!last || !current)
    {
        return -1;
    }

    deltaT = ((t>=last->time) ? (t-last->time) : \
             (t+RT_UINT32_MAX - last->time)) / 1000.0;

    memcpy(current, last, sizeof(vam_stastatus_t));
    if(deltaT == 0 || (last->speed < 5))
    {
        return 0;
    }
    
    /* deltaT != 0, the calculate the "current" value */
    lon1 = RAD((double)last->pos.lon);
    lat1 = RAD((double)last->pos.lat);
    dir = RAD((double)last->dir);
    
    /* uniform rectilinear motion */ 
    v = last->speed / 3.6f;
    s = v*deltaT; 
    
	/* lat2 = asin( sin lat1 * cos dR + cos lat1 * sin dR * cos θ )
    lon2 = lon1 + atan2( sin θ * sin dR * cos lat1, cos dR- sin lat1 * sin lat2 )
    where lat is latitude, lon is longitude, θis the bearing (clockwise from north), 
    dR is the angular distance d/R; d being the distance travelled, R the earth’s radius */
    dR = s / EARTH_RADIUS / 1000.0;
    lat2 = asin(sin(lat1)*cos(dR) + cos(lat1)*sin(dR)*cos(dir));
    lon2 = lon1 + atan2(sin(dir)*sin(dR)*cos(lat1), cos(dR)-sin(lat1)*sin(lat2));

    current->time = t;
    current->dir = dir * 180.0 / PI;
    current->speed = v*3.6;
    current->pos.lon = lon2 * 180.0 / PI;
    current->pos.lat = lat2 * 180.0 / PI;
#if 0
    char buf[100];
    sprintf(buf, "(lon=%f,lat=%f),h=%f,d=%f,s=%f,v=%f", current->pos.lon, current->pos.lat, current->dir, 
                                      vsm_get_relative_pos(last, current, 0), s, v);
    rt_kprintf("c%d%s\r\n", t, buf);
#endif
    return 0;
}
开发者ID:gexueyuan,项目名称:Cygnoides,代码行数:52,代码来源:cv_vam_util.c


示例19: keyHandler

int keyHandler(void *null) {
	distance = 2.0f;
	while(e.type != SDL_QUIT) {
		keyPress = SDL_GetKeyState(NULL);
		if(keyPress[SDLK_ESCAPE]) {
			SDL_Quit();
			break;
		}
		if(keyPress[SDLK_w] || keyPress[SDLK_UP]) {
			player.idlerot = player.ent.rotation;
			if(player.speed < player.maxspd && SDL_GetTicks() - t2 >= 200) {
				player.speed += player.accel;
				t2 = SDL_GetTicks();
			}
			player.ent.x += player.speed * (float) sin(RAD(player.ent.rotation));
			player.ent.y -= player.speed * (float) cos(RAD(player.ent.rotation));
		} else if(player.speed > 0.0f) {
			if(SDL_GetTicks() - t2 >= 200) {
				player.speed -= (player.speed / 2) * player.decel;
				t2 = SDL_GetTicks();
				if(player.speed < 0.01f) {
					player.speed = 0.0f;
				}
			}
			player.ent.x += player.speed * (float) sin(RAD(player.idlerot));
			player.ent.y -= player.speed * (float) cos(RAD(player.idlerot));
		}
		
		if(keyPress[SDLK_d] || keyPress[SDLK_RIGHT]) {
			player.ent.rotation += distance * 1.0f;
		} else if(keyPress[SDLK_a] || keyPress[SDLK_LEFT]) {
			player.ent.rotation -= distance * 1.0f;
		}
		if(t1 == 0 || SDL_GetTicks() - t1 > 100) {
			t1 = SDL_GetTicks();
			if(keyPress[SDLK_SPACE]) {
				bullets[nextBullet] = player.ent;
				bullets[nextBullet].speed = 3 + player.maxspd;
				bullets[nextBullet++].flags = FLAG_ALIVE;
				if(nextBullet >= MAX_BULLETS) nextBullet = 0;
			}
		}
		if(player.ent.rotation > 359) player.ent.rotation = 0;
		else if(player.ent.rotation < 0) player.ent.rotation = 359;
		//free(keyPress);
		SDL_Delay(10);
	}
	return 0;
}
开发者ID:LasseSkogland,项目名称:Scripts,代码行数:49,代码来源:keys.c


示例20: b3n_draw_circleofcircles

void		b3n_draw_circleofcircles(int x, int y, unsigned int size, float angle, int32_t* colors, unsigned int nbr, s_b3n_env* env)
{
	float				offset;
	unsigned int		i;

	if (nbr < 3)
		return ;
	offset = 360.f / nbr;
	i = 0;
	while (i < nbr)
	{
		b3n_draw_circle(x + (size * cos(RAD(angle + (i * offset)))), y + (size * sin(RAD(angle + (i * offset)))), (size * M_PI) / nbr, colors[i], env);
		i++;
	}
}
开发者ID:n0izn0iz,项目名称:b3n,代码行数:15,代码来源:drawing.c



注:本文中的RAD函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ RAD2DEG函数代码示例发布时间:2022-05-30
下一篇:
C++ R4函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap