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

C++ NRAND函数代码示例

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

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



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

示例1: init_moebius

ENTRYPOINT void
init_moebius (ModeInfo * mi)
{
	moebiusstruct *mp;

	if (moebius == NULL) {
		if ((moebius = (moebiusstruct *) calloc(MI_NUM_SCREENS(mi),
					    sizeof (moebiusstruct))) == NULL)
			return;
	}
	mp = &moebius[MI_SCREEN(mi)];
	mp->step = NRAND(90);
	mp->ant_position = NRAND(90);

    {
      double rot_speed = 0.3;
      mp->rot = make_rotator (rot_speed, rot_speed, rot_speed, 1, 0, True);
      mp->trackball = gltrackball_init ();
    }

	if ((mp->glx_context = init_GL(mi)) != NULL) {

		reshape_moebius(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
		glDrawBuffer(GL_BACK);
		pinit(mi);
	} else {
		MI_CLEARWINDOW(mi);
	}
}
开发者ID:davehorner,项目名称:XScreenSaverWin,代码行数:29,代码来源:moebius.c


示例2: MakeTeapot

static void
MakeTeapot(ModeInfo * mi, int newdir)
{
  pipesstruct *pp = &pipes[MI_SCREEN(mi)];

  switch (newdir) {
  case dirUP:
  case dirDOWN:
    glRotatef(90.0, 1.0, 0.0, 0.0);
    glRotatef(NRAND(3) * 90.0, 0.0, 0.0, 1.0);
    break;
  case dirLEFT:
  case dirRIGHT:
    glRotatef(90.0, 0.0, -1.0, 0.0);
    glRotatef((NRAND(3) * 90.0) - 90.0, 0.0, 0.0, 1.0);
    break;
  case dirNEAR:
  case dirFAR:
    glRotatef(NRAND(4) * 90.0, 0.0, 0.0, 1.0);
    break;
  }

  glCallList(pp->teapot);
  mi->polygon_count += pp->teapot_polys;
  glFrontFace(GL_CCW);
}
开发者ID:davehorner,项目名称:XScreenSaverWin,代码行数:26,代码来源:pipes.c


示例3: look

static int
look(ModeInfo * mi)
{
	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);

	/*GC          gc = MI_GC(mi); */
	nosestruct *np = &noses[MI_SCREEN(mi)];
	int         i;

	if (NRAND(3)) {
		i = (LRAND() & 1) ? D : F;
		XCopyArea(display, np->position[i], window, np->noseGC[i],
			  0, 0, PIXMAP_SIZE, PIXMAP_SIZE, np->x, np->y);
		return 3;
	}
	if (!NRAND(5))
		return 0;
	if (NRAND(3)) {
		i = (LRAND() & 1) ? LF : RF;
		XCopyArea(display, np->position[i], window, np->noseGC[i],
			  0, 0, PIXMAP_SIZE, PIXMAP_SIZE, np->x, np->y);
		return 3;
	}
	if (!NRAND(5))
		return 0;
	i = (LRAND() & 1) ? L : R;
	XCopyArea(display, np->position[i], window, np->noseGC[i],
		  0, 0, PIXMAP_SIZE, PIXMAP_SIZE, np->x, np->y);
	return 3;
}
开发者ID:Gelma,项目名称:xlockmore-for-13.04,代码行数:31,代码来源:nose.c


示例4: change_fire

ENTRYPOINT void change_fire(ModeInfo * mi)
{
    firestruct *fs = &fire[MI_SCREEN(mi)];

    if (!fs->glx_context)
	return;

    glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(fs->glx_context));

    /* if available, randomly change some values */
    if (do_fog)
	fs->fog = LRAND() & 1;
    if (do_shadows)
	fs->shadows = LRAND() & 1;
    /* reset observer position */
    frame = 0;
    vinit(fs->obs, DEF_OBS[0], DEF_OBS[1], DEF_OBS[2]);
    fs->v = 0.0;
    /* particle randomisation */
    fs->eject_r = 0.1 + NRAND(10) * 0.03;
    fs->ridtri = 0.1 + NRAND(10) * 0.005;

    if (MI_IS_DEBUG(mi)) {
	(void) fprintf(stderr,
		       "%s:\n\tnum_part=%d\n\ttrees=%d\n\tfog=%s\n\tshadows=%s\n\teject_r=%.3f\n\tridtri=%.3f\n",
		       MI_NAME(mi),
		       fs->np,
		       fs->num_trees,
		       fs->fog ? "on" : "off",
		       fs->shadows ? "on" : "off",
		       fs->eject_r, fs->ridtri);
    }
}
开发者ID:RazZziel,项目名称:pongclock,代码行数:33,代码来源:glforestfire.c


示例5: init_morph3d

void
init_morph3d(ModeInfo * mi)
{
	morph3dstruct *mp;

	if (morph3d == NULL) {
		if ((morph3d = (morph3dstruct *) calloc(MI_NUM_SCREENS(mi),
					    sizeof (morph3dstruct))) == NULL)
			return;
	}
	mp = &morph3d[MI_SCREEN(mi)];
	mp->step = NRAND(90);
	mp->VisibleSpikes = 1;
	if ((mp->glx_context = init_GL(mi)) != NULL) {

		reshape_morph3d(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
		glDrawBuffer(GL_BACK);
		mp->object = MI_COUNT(mi);
		if (mp->object <= 0 || mp->object > 5)
			mp->object = NRAND(5) + 1;
		pinit(mi);
	} else {
		MI_CLEARWINDOW(mi);
	}
}
开发者ID:Gelma,项目名称:xlockmore-for-13.04,代码行数:25,代码来源:morph3d.c


示例6: Init

static Bool Init(ModeInfo * mi)
{
    int i;
    firestruct *fs = &fire[MI_SCREEN(mi)];

    /* default settings */
    fs->eject_r = 0.1 + NRAND(10) * 0.03;
    fs->dt = 0.015;
    fs->eject_vy = 4;
    fs->eject_vl = 1;
    fs->ridtri = 0.1 + NRAND(10) * 0.005;
    fs->maxage = 1.0 / fs->dt;
    vinit(fs->obs, DEF_OBS[0], DEF_OBS[1], DEF_OBS[2]);
    fs->v = 0.0;
    fs->alpha = DEF_ALPHA;
    fs->beta = DEF_BETA;

    /* initialise texture stuff */
    if (do_texture)
    	inittextures(mi);
    else
    {
	fs->ttexture = (XImage*) NULL;
	fs->gtexture = (XImage*) NULL;
    }

    if (MI_IS_DEBUG(mi)) {
	(void) fprintf(stderr,
		       "%s:\n\tnum_part=%d\n\ttrees=%d\n\tfog=%s\n\tshadows=%s\n\teject_r=%.3f\n\tridtri=%.3f\n",
		       MI_NAME(mi),
		       fs->np,
		       fs->num_trees,
		       fs->fog ? "on" : "off",
		       fs->shadows ? "on" : "off",
		       fs->eject_r, fs->ridtri);
    }

    /* initialise particles and trees */
    for (i = 0; i < fs->np; i++) {
	setnewpart(fs, &(fs->p[i]));
    }

    if (fs->num_trees)
	if (!inittree(mi)) {
		return False;
	}

    /* if no fire particles then initialise rain particles */
    if (!fs->np)
    {
	vinit(fs->min,-7.0f,-0.2f,-7.0f);
  	vinit(fs->max,7.0f,8.0f,7.0f);
    	for (i = 0; i < NUMPART; i++) {
	    setnewrain(fs, &(fs->r[i]));
    	}
    }
    
    return True;
}
开发者ID:mmarseglia,项目名称:xscreensaver,代码行数:59,代码来源:glforestfire.c


示例7: create_path

static void
create_path(circuitstruct * wp, int n)
{
	int         col, row;
	int         count = 0;
	int         dir, prob;
	int         nextcol, nextrow, i;

#ifdef RANDOMSTART
	/* Path usually "mushed" in a corner */
	col = NRAND(wp->ncols) + 1;
	row = NRAND(wp->nrows) + 1;
#else
	/* Start from center */
	col = wp->ncols / 2;
	row = wp->nrows / 2;
#endif
	wp->mincol = col - 1, wp->minrow = row - 2;
	wp->maxcol = col + 1, wp->maxrow = row + 2;
	dir = NRAND(wp->neighbors) * ANGLES / wp->neighbors;
	*(wp->newcells + col + row * wp->bncols) = HEAD;
	while (++count < n) {
		prob = NRAND(wp->prob_array[wp->neighbors - 1]);
		i = 0;
		while (prob > wp->prob_array[i])
			i++;
		dir = ((dir * wp->neighbors / ANGLES + i) %
		       wp->neighbors) * ANGLES / wp->neighbors;
		nextcol = col;
		nextrow = row;
		positionOfNeighbor(wp, dir, &nextcol, &nextrow);
		if (withinBounds(wp, nextcol, nextrow)) {
			col = nextcol;
			row = nextrow;
			if (col == wp->mincol && col > 2)
				wp->mincol--;
			if (row == wp->minrow && row > 2)
				wp->minrow--;
			else if (row == wp->minrow - 1 && row > 3)
				wp->minrow -= 2;
			if (col == wp->maxcol && col < wp->bncols - 3)
				wp->maxcol++;
			if (row == wp->maxrow && row < wp->bnrows - 3)
				wp->maxrow++;
			else if (row == wp->maxrow + 1 && row < wp->bnrows - 4)
				wp->maxrow += 2;

			if (!*(wp->newcells + col + row * wp->bncols))
				*(wp->newcells + col + row * wp->bncols) = WIRE;
		} else {
			if (wp->neighbors == 3)
				break;	/* There is no reverse step */
			dir = ((dir * wp->neighbors / ANGLES + wp->neighbors / 2) %
			       wp->neighbors) * ANGLES / wp->neighbors;
		}
	}
	*(wp->newcells + col + row * wp->bncols) = HEAD;
}
开发者ID:Gelma,项目名称:xlockmore-for-13.04,代码行数:58,代码来源:wire.c


示例8: wiggle_line

static void
wiggle_line(XPoint * p, int number, int amount)
{
	int         i;

	for (i = 0; i < number; i++) {
		p[i].x += NRAND(amount) - amount / 2;
		p[i].y += NRAND(amount) - amount / 2;
	}
}
开发者ID:RazZziel,项目名称:pongclock,代码行数:10,代码来源:lightning.c


示例9: InitDrop

static void InitDrop(ModeInfo * mi, rainstruct *rp, dropstruct *drop)
{
  /* Where does the drop fall in the pool?
     At least 20% of height from top and not completely at the bottom */
  int yMin = MI_HEIGHT(mi) / 5;
  int yMax = MI_HEIGHT(mi) - ((MAX_RADIUS * 3) / 2);
  drop->pool.x = 0;
  drop->pool.y = yMin + NRAND(yMax - yMin);

  /* How fast does it fall? */
  drop->offset.x = 5 + NRAND(5);
  drop->offset.y = 20 + NRAND(20);

  /* Where does the drop start */
  drop->drop.x = NRAND(MI_WIDTH(mi));
  drop->drop.height = 0;
  drop->drop.width = drop->drop.x + drop->offset.x;
  drop->drop.y = drop->drop.height + drop->offset.y;

  /* How large is the pool and how fast does it grow? */
  drop->radius = 0;
  drop->radius_step = 1 + NRAND(2);
  drop->max_radius = (MAX_RADIUS / 2) + NRAND(MAX_RADIUS / 2);

  /* Colored drops? */
  if (rp->colored_drops)
  {
    if (rp->base_color == 0)
      drop->color = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi)));
    else
      drop->color = rp->base_color + (NRAND(2) == 1 ? -1 : 1) * NRAND(12);
  }
  else
    drop->color = MI_WHITE_PIXEL(mi);
}
开发者ID:Gelma,项目名称:xlockmore-for-13.04,代码行数:35,代码来源:rain.c


示例10: draw_blot

void
draw_blot(ModeInfo * mi)
{
	blotstruct *bp;
	XPoint     *xp;
	int         x, y, k;

	if (blots == NULL)
		return;
	bp = &blots[MI_SCREEN(mi)];
	xp = bp->pointBuffer;
	if (xp == NULL)
		init_blot(mi);

	MI_IS_DRAWN(mi) = True;
	if (MI_NPIXELS(mi) > 2) {
		XSetForeground(MI_DISPLAY(mi), MI_GC(mi), MI_PIXEL(mi, bp->pix));
		if (++bp->pix >= MI_NPIXELS(mi))
			bp->pix = 0;
	}
	x = bp->xmid;
	y = bp->ymid;
	k = bp->size;
	while (k >= 4) {
		x += (NRAND(1 + (bp->offset << 1)) - bp->offset);
		y += (NRAND(1 + (bp->offset << 1)) - bp->offset);
		k--;
		xp->x = x;
		xp->y = y;
		xp++;
		if (bp->xsym) {
			k--;
			xp->x = bp->width - x;
			xp->y = y;
			xp++;
		}
		if (bp->ysym) {
			k--;
			xp->x = x;
			xp->y = bp->height - y;
			xp++;
		}
		if (bp->xsym && bp->ysym) {
			k--;
			xp->x = bp->width - x;
			xp->y = bp->height - y;
			xp++;
		}
	}
	XDrawPoints(MI_DISPLAY(mi), MI_WINDOW(mi), MI_GC(mi),
		    bp->pointBuffer, (bp->size - k), CoordModeOrigin);
	if (++bp->count > MI_CYCLES(mi))
		init_blot(mi);
}
开发者ID:Bluerise,项目名称:bitrig-xenocara,代码行数:54,代码来源:blot.c


示例11: RandomSoup

static void
RandomSoup(life1dstruct * lp, int n, int v)
{
	int         col;

	v /= 2;
	if (v < 1)
		v = 1;
	for (col = lp->ncols / 2 - v; col < lp->ncols / 2 + v; ++col)
		if (NRAND(100) < n && col >= 0 && col < lp->ncols)
			lp->newcells[col + lp->border] = (unsigned char) NRAND(lp->k - 1) + 1;
}
开发者ID:Gelma,项目名称:xlockmore-for-13.04,代码行数:12,代码来源:life1d.c


示例12: RandomSoup

static void
RandomSoup(circuitstruct * wp)
{
	int         i, j;

	for (j = 2; j < wp->bnrows - 2; j++)
		for (i = 2; i < wp->bncols - 2; i++) {
			*(wp->newcells + i + j * wp->bncols) =
				(NRAND(100) > wp->n) ? SPACE : (NRAND(4)) ? WIRE : (NRAND(2)) ?
				HEAD : TAIL;
		}
}
开发者ID:Gelma,项目名称:xlockmore-for-13.04,代码行数:12,代码来源:wire.c


示例13: init_fadeplot

ENTRYPOINT void
init_fadeplot (ModeInfo * mi)
{
	fadeplotstruct *fp;

	if (fadeplots == NULL) {
		if ((fadeplots = (fadeplotstruct *) calloc(MI_NUM_SCREENS(mi),
					   sizeof (fadeplotstruct))) == NULL)
			return;
	}
	fp = &fadeplots[MI_SCREEN(mi)];

	fp->width = MI_WIDTH(mi);
	fp->height = MI_HEIGHT(mi);
	fp->min = MAX(MIN(fp->width, fp->height) / 2, 1);

	fp->speed.x = 8;
	fp->speed.y = 10;
	fp->step.x = 1;
	fp->step.y = 1;
	fp->temps = 0;
	fp->factor.x = MAX(fp->width / (2 * fp->min), 1);
	fp->factor.y = MAX(fp->height / (2 * fp->min), 1);

	fp->nbstep = MI_COUNT(mi);
	if (fp->nbstep < -MINSTEPS) {
		fp->nbstep = NRAND(-fp->nbstep - MINSTEPS + 1) + MINSTEPS;
	} else if (fp->nbstep < MINSTEPS)
		fp->nbstep = MINSTEPS;

	fp->maxpts = MI_CYCLES(mi);
	if (fp->maxpts < 1)
		fp->maxpts = 1;

	if (fp->pts == NULL) {
		if ((fp->pts = (XPoint *) calloc(fp->maxpts, sizeof (XPoint))) ==
				 NULL) {
			free_fadeplot(fp);
			return;
		}
	}
	if (MI_NPIXELS(mi) > 2)
		fp->pix = NRAND(MI_NPIXELS(mi));

	if (fp->stab != NULL)
		(void) free((void *) fp->stab);
	if (!initSintab(mi))
		return;
	MI_CLEARWINDOW(mi);
}
开发者ID:BuBuaBu,项目名称:bang-screensaver,代码行数:50,代码来源:fadeplot.c


示例14: init_colors

static void
init_colors(ModeInfo *mi)
{
	if (strncasecmp(bubble_color_str, "auto", strlen("auto")) == 0) {
		glb_config.bubble_colour[0] = ((float) (NRAND(100)) / 100.0);
		glb_config.bubble_colour[1] = ((float) (NRAND(100)) / 100.0);
		/* I keep more blue */
		glb_config.bubble_colour[2] = ((float) (NRAND(50)) / 100.0) + 0.50;
	} else if (strncasecmp(bubble_color_str, "random", strlen("random")) == 0) {
	    glb_config.bubble_colour[0] = -1.0;
	} else {
		parse_color(mi, "bubble", bubble_color_str, glb_config.bubble_colour);
	}
}
开发者ID:BuBuaBu,项目名称:bang-screensaver,代码行数:14,代码来源:b_lockglue.c


示例15: InitDropColors

static void InitDropColors(ModeInfo * mi, rainstruct *rp)
{
  /* Once in every 10 times show only white drops */
  rp->colored_drops = (NRAND(10) != 1);

  /* When using colored, use the all random colors or around the base color */
  if (rp->colored_drops)
  {
    if (NRAND(2) == 1)
      rp->base_color = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi)));
    else
      rp->base_color = 0;
  }
}
开发者ID:Gelma,项目名称:xlockmore-for-13.04,代码行数:14,代码来源:rain.c


示例16: move_blob

static void
move_blob(blob * b, int maxx, int maxy)
{
	maxx *= SCALE;
	maxy *= SCALE;

	b->x += b->dx;
	b->y += b->dy;

	/* If we've reached the edge of the box, reverse direction. */
	if ((b->x > maxx && b->dx >= 0) ||
	    (b->x < 0 && b->dx < 0)) {
		b->dx = -b->dx;
	}
	if ((b->y > maxy && b->dy >= 0) ||
	    (b->y < 0 && b->dy < 0)) {
		b->dy = -b->dy;
	}
	/* Alter velocity randomly. */
	if (!(LRAND() % 10)) {
		b->dx += (NRAND(b->max_velocity / 2) * RANDSIGN());
		b->dy += (NRAND(b->max_velocity / 2) * RANDSIGN());

		/* Throttle velocity */
		if (b->dx > b->max_velocity || b->dx < -b->max_velocity)
			b->dx /= 2;
		if (b->dy > b->max_velocity || b->dy < -b->max_velocity)
			b->dy /= 2;
	} {
		double      th = b->th;
		double      d = (b->torque == 0 ? 0 : (b->torque) * LRAND() / MAXRAND);

		if (th < 0)
			th = -(th + d);
		else
			th += d;

		if (th > (M_PI + M_PI))
			th -= (M_PI + M_PI);
		else if (th < 0)
			th += (M_PI + M_PI);

		b->th = (b->th > 0 ? th : -th);
	}

	/* Alter direction of rotation randomly. */
	if (!(LRAND() % 100))
		b->th *= -1;
}
开发者ID:Bluerise,项目名称:bitrig-xenocara,代码行数:49,代码来源:goop.c


示例17: init_grav

ENTRYPOINT void
init_grav(ModeInfo * mi)
{
	Display    *display = MI_DISPLAY(mi);
	GC          gc = MI_GC(mi);
	unsigned char ball;
	gravstruct *gp;

	if (gravs == NULL) {
		if ((gravs = (gravstruct *) calloc(MI_NUM_SCREENS(mi),
					       sizeof (gravstruct))) == NULL)
			return;
	}
	gp = &gravs[MI_SCREEN(mi)];

	gp->width = MI_WIDTH(mi);
	gp->height = MI_HEIGHT(mi);

	gp->sr = STARRADIUS;

	gp->nplanets = MI_COUNT(mi);
	if (gp->nplanets < 0) {
		if (gp->planets) {
			(void) free((void *) gp->planets);
			gp->planets = (planetstruct *) NULL;
		}
		gp->nplanets = NRAND(-gp->nplanets) + 1;	/* Add 1 so its not too boring */
	}
	if (gp->planets == NULL) {
		if ((gp->planets = (planetstruct *) calloc(gp->nplanets,
				sizeof (planetstruct))) == NULL)
			return;
	}

	MI_CLEARWINDOW(mi);

	if (MI_NPIXELS(mi) > 2)
		gp->starcolor = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi)));
	else
		gp->starcolor = MI_WHITE_PIXEL(mi);
	for (ball = 0; ball < (unsigned char) gp->nplanets; ball++)
		init_planet(mi, &gp->planets[ball]);

	/* Draw centrepoint */
	XDrawArc(display, MI_WINDOW(mi), gc,
		 gp->width / 2 - gp->sr / 2, gp->height / 2 - gp->sr / 2, gp->sr, gp->sr,
		 0, 23040);
}
开发者ID:david-sackmary,项目名称:distro-mods,代码行数:48,代码来源:grav.c


示例18: init_planet

static void
init_planet(ModeInfo * mi, planetstruct * planet)
{
	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);
	GC          gc = MI_GC(mi);
	gravstruct *gp = &gravs[MI_SCREEN(mi)];

	if (MI_NPIXELS(mi) > 2)
		planet->colors = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi)));
	else
		planet->colors = MI_WHITE_PIXEL(mi);
	/* Initialize positions */
	POS(X) = FLOATRAND(-XR, XR);
	POS(Y) = FLOATRAND(-YR, YR);
	POS(Z) = FLOATRAND(-ZR, ZR);

	if (POS(Z) > -ALMOST) {
		planet->xi = (int)
			((double) gp->width * (HALF + POS(X) / (POS(Z) + DIST)));
		planet->yi = (int)
			((double) gp->height * (HALF + POS(Y) / (POS(Z) + DIST)));
	} else
		planet->xi = planet->yi = -1;
	planet->ri = RADIUS;

	/* Initialize velocities */
	VEL(X) = FLOATRAND(-VR, VR);
	VEL(Y) = FLOATRAND(-VR, VR);
	VEL(Z) = FLOATRAND(-VR, VR);

	/* Draw planets */
	Planet(planet->xi, planet->yi);
}
开发者ID:Bluerise,项目名称:bitrig-xenocara,代码行数:34,代码来源:grav.c


示例19: init_planet

static void
init_planet(ModeInfo * mi, planetstruct * planet)
{
	gravstruct *gp = &gravs[MI_SCREEN(mi)];

# ifdef HAVE_JWXYZ
    jwxyz_XSetAntiAliasing (MI_DISPLAY(mi), MI_GC(mi), False);
# endif

	if (MI_NPIXELS(mi) > 2)
		planet->colors = MI_PIXEL(mi, NRAND(MI_NPIXELS(mi)));
	else
		planet->colors = MI_WHITE_PIXEL(mi);
	/* Initialize positions */
	POS(X) = FLOATRAND(-XR, XR);
	POS(Y) = FLOATRAND(-YR, YR);
	POS(Z) = FLOATRAND(-ZR, ZR);

	if (POS(Z) > -ALMOST) {
		planet->xi = (int)
			((double) gp->width * (HALF + POS(X) / (POS(Z) + DIST)));
		planet->yi = (int)
			((double) gp->height * (HALF + POS(Y) / (POS(Z) + DIST)));
	} else
		planet->xi = planet->yi = -1;
	planet->ri = RADIUS;

	/* Initialize velocities */
	VEL(X) = FLOATRAND(-VR, VR);
	VEL(Y) = FLOATRAND(-VR, VR);
	VEL(Z) = FLOATRAND(-VR, VR);
}
开发者ID:MaddTheSane,项目名称:xscreensaver,代码行数:32,代码来源:grav.c


示例20: init_stairs

ENTRYPOINT void
init_stairs (ModeInfo * mi)
{
	int         screen = MI_SCREEN(mi);
	stairsstruct *sp;

	if (stairs == NULL) {
		if ((stairs = (stairsstruct *) calloc(MI_NUM_SCREENS(mi),
					     sizeof (stairsstruct))) == NULL)
			return;
	}
	sp = &stairs[screen];

	sp->step = 0.0;
	sp->rotating = 0;
	sp->sphere_position = NRAND(NPOSITIONS);
	sp->sphere_tick = 0;

	if ((sp->glx_context = init_GL(mi)) != NULL) {

		reshape_stairs(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
		glDrawBuffer(GL_BACK);
		if (!glIsList(sp->objects))
			sp->objects = glGenLists(1);
		pinit(mi);
	} else {
		MI_CLEARWINDOW(mi);
	}

    sp->trackball = gltrackball_init (False);
}
开发者ID:mmarseglia,项目名称:xscreensaver,代码行数:31,代码来源:stairs.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ NRF24L01_WriteReg函数代码示例发布时间:2022-05-30
下一篇:
C++ NPVARIANT_TO_STRING函数代码示例发布时间: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