当前位置: 首页>>代码示例>>C++>>正文


C++ i2f函数代码示例

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


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

示例1: MatrixInv

/** Inverses mx.
 *  Returns materr(2) if mx isn't a square, 2x2 matrix,
 *  or materr(1) if the initialization didn't go right.
 */
matrix MatrixInv(matrix mx)
{
    if (!isValidOp(mx,mx,'i')) {
        return materr(2);
    }

    if(mx.rows == 2) {

        matrix inv = initialize(mx.rows, mx.columns);
        if(inv.mx == NULL) {
            return materr(1);
        }

        frac tmp;
        frac det = fdiv(i2f(1),
                        fsub(fmul(mx.mx[0][0], mx.mx[1][1]),
                             fmul(mx.mx[0][1], mx.mx[1][0])));

        tmp = mx.mx[0][0];
        inv.mx[0][0] = mx.mx[1][1];
        inv.mx[1][1] = tmp;

        inv.mx[0][1] = fmul(mx.mx[0][1], i2f(-1));
        inv.mx[1][0] = fmul(mx.mx[1][0], i2f(-1));
        return MatrixSMul(mx, det);
    } else {
        return materr(2);
    }
}
开发者ID:ubsan,项目名称:libAlgebra,代码行数:33,代码来源:mal.c

示例2: timer_get_fixed_seconds

fix timer_get_fixed_seconds(void)
{
	fix x;
	unsigned long tv_now = SDL_GetTicks();
	x=i2f(tv_now/1000) | fixdiv(i2f(tv_now % 1000),i2f(1000));
	return x;
}
开发者ID:gameplayer22,项目名称:d2x-1,代码行数:7,代码来源:timer.c

示例3: gr_palette_fade_in

int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys)
{
	int i,j;
	ubyte c;
	fix fade_palette[768];
	fix fade_palette_delta[768];


	if (!gr_palette_faded_out) return 0;

	for (i=0; i<768; i++ )	{
		gr_current_pal[i] = pal[i];
		fade_palette[i] = 0;
		fade_palette_delta[i] = i2f(pal[i]+gr_palette_gamma) / nsteps;
	}

	for (j=0; j<nsteps; j++ )	{
		gr_sync_display();
		outp( 0x3c6, 0xff );
		outp( 0x3c8, 0 );
		for (i=0; i<768; i++ )	{
			fade_palette[i] += fade_palette_delta[i];
			if (fade_palette[i] > i2f(pal[i]+gr_palette_gamma) )
				fade_palette[i] = i2f(pal[i]+gr_palette_gamma);
			c = f2i(fade_palette[i]);
                        if ( c > 63 ) c = 63;
			outp( 0x3c9, c );
		}
	}
	gr_palette_faded_out = 0;
	return 0;
}
开发者ID:gameplayer22,项目名称:d2x-1,代码行数:32,代码来源:gr.c

示例4: gr_palette_fade_in

int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys)	
{
	int i,j;
	ubyte c[768];
	fix fade_palette[768];
	fix fade_palette_delta[768];

	allow_keys  = allow_keys;

	if (!gr_palette_faded_out) return 0;

	for (i=0; i<768; i++ )	{
		gr_current_pal[i] = pal[i];
		fade_palette[i] = 0;
		fade_palette_delta[i] = i2f(pal[i]+gr_palette_gamma) / nsteps;
	}

	for (j=0; j<nsteps; j++ )	{
		gr_sync_display();
		for (i=0; i<768; i++ )	{		
			fade_palette[i] += fade_palette_delta[i];
			if (fade_palette[i] > i2f(pal[i]+gr_palette_gamma) )
				fade_palette[i] = i2f(pal[i]+gr_palette_gamma);
			c[i] = f2i(fade_palette[i]);
			if ( c[i] > 63 ) c[i] = 63;					
		}
		gr_palette_apply(c);
	}
	gr_palette_faded_out = 0;
	return 0;
}
开发者ID:devint1,项目名称:descent-win,代码行数:31,代码来源:PALETTE.C

示例5: gr_palette_fade_in

int gr_palette_fade_in (ubyte *pal, int nsteps, int allow_keys)
{
	int i, j;
	ubyte c;
	fix fade_palette[768];
	fix fade_palette_delta[768];

	int fade_colors[768];

	if (!gr_palette_faded_out) return 0;

	for (i=0; i<768; i++)
	{
		gr_current_pal[i] = pal[i];
		fade_palette[i] = 0;
		fade_palette_delta[i] = i2f(pal[i] + gr_palette_gamma) / nsteps;
	}

 	for (j=0; j<nsteps; j++ )
	{
		for (i = 0; i < 768; i++ )
		{
			fade_palette[i] += fade_palette_delta[i];
			if (fade_palette[i] > i2f(pal[i] + gr_palette_gamma))
				fade_palette[i] = i2f(pal[i] + gr_palette_gamma);
			c = f2i(fade_palette[i]);
			if (c > 63) c = 63;
			fade_colors[i] = c;
		}
		vga_setpalvec (0, 256, fade_colors);
	}

	gr_palette_faded_out = 0;
	return 0;
}
开发者ID:Ringdingcoder,项目名称:d1x,代码行数:35,代码来源:gr.c

示例6: gr_palette_fade_in

int gr_palette_fade_in(ubyte *pal, int nsteps, int allow_keys)	
{
	int i;
	
	if (!gr_palette_faded_out) return 0;
	
#ifdef OGLES
	GLuint saved_screen_tex;
	grs_canvas *save_canvas;
	int darken_step;
	
	if (!grd_curscreen) {
		return 0;
	}
	
	save_canvas = grd_curcanv;
	gr_set_current_canvas(NULL);
	darken_step = GR_FADE_LEVELS / nsteps;
	Gr_scanline_darkening_level = 1;
	saved_screen_tex = ogles_save_screen();
	for (i = 0; i < nsteps; ++i) {
		ogles_draw_saved_screen(saved_screen_tex);
		Gr_scanline_darkening_level	+= darken_step;
		gr_urect(0, 0, grd_curscreen->sc_w, grd_curscreen->sc_h);
		showRenderBuffer();
		gr_sync_display();
	}
	glDeleteTextures(1, &saved_screen_tex);
	Gr_scanline_darkening_level = GR_FADE_LEVELS;
	gr_set_current_canvas(save_canvas);
	gr_palette_apply(pal);
#else
	int j;
	ubyte c[768];
	fix fade_palette[768];
	fix fade_palette_delta[768];
	
	allow_keys  = allow_keys;
	
	for (i=0; i<768; i++ )	{
		fade_palette[i] = 0;
		fade_palette_delta[i] = i2f(pal[i]+gr_palette_gamma) / nsteps;
	}

	for (j=0; j<nsteps; j++ )	{
		gr_sync_display();
		for (i=0; i<768; i++ )	{		
			fade_palette[i] += fade_palette_delta[i];
			if (fade_palette[i] > i2f(pal[i]+gr_palette_gamma) )
				fade_palette[i] = i2f(pal[i]+gr_palette_gamma);
			c[i] = f2i(fade_palette[i]);
			if ( c[i] > 63 ) c[i] = 63;					
		}
		gr_palette_apply(c);
	}
#endif
	gr_palette_faded_out = 0;
	return 0;
}
开发者ID:devint1,项目名称:Descent-Mobile,代码行数:59,代码来源:palette.c

示例7: timer_get_fixed_seconds

fix timer_get_fixed_seconds(void)
{
	fix x;
	struct timeval tv_now;
	gettimeofday(&tv_now, NULL);
	x=i2f(tv_now.tv_sec - tv_old.tv_sec) + fixdiv(i2f((tv_now.tv_usec - tv_old.tv_usec)/1000), i2f(1000));
	return x;
}
开发者ID:Ringdingcoder,项目名称:d1x,代码行数:8,代码来源:timer.c

示例8: scale_row_transparent

static void scale_row_transparent( ubyte * sbits, ubyte * dbits, int width, fix u, fix du )
{
	int i;
	ubyte c;
	ubyte *dbits_end = &dbits[width-1];

	if ( du < F1_0 )	{
		// Scaling up.
		fix next_u;
		int next_u_int;

		next_u_int = f2i(u)+1;
		c = sbits[ next_u_int ];
		next_u = i2f(next_u_int);
		if ( c != TRANSPARENCY_COLOR ) goto NonTransparent;

Transparent:
		while (1)	{
			dbits++;
			if ( dbits > dbits_end ) return;
			u += du;
			if ( u > next_u )	{
				next_u_int = f2i(u)+1;
				c = sbits[ next_u_int ];
				next_u = i2f(next_u_int);
				if ( c != TRANSPARENCY_COLOR ) goto NonTransparent;
			}
		}
		return;

NonTransparent:
		while (1)	{
			*dbits++ = c;
			if ( dbits > dbits_end ) return;
			u += du;
			if ( u > next_u )	{
				next_u_int = f2i(u)+1;
				c = sbits[ next_u_int ];
				next_u = i2f(next_u_int);
				if ( c == TRANSPARENCY_COLOR ) goto Transparent;
			}
		}
		return;



	} else {
		for ( i=0; i<width; i++ )	{
			c = sbits[ f2i(u) ];

			if ( c != TRANSPARENCY_COLOR )
				*dbits = c;

			dbits++;
			u += du;
		}
	}
}
开发者ID:Foran,项目名称:dxx-rebirth,代码行数:58,代码来源:scalec.cpp

示例9: build_mesh

mesh_t* build_mesh() {
	int p;
	double c;
	mesh_t* mesh = mesh_new(5, 6);	// 5 vertexes, 6 triangles
	vector_t* points = mesh->points;
	triangle_t* triangles = mesh->triangles;

	double M_PI = 8.0 * atan(1.0);

	// define the base points
	for (p = 0; p < 4; p++) {
		c = M_PI * p / 4.0;
		points[p].x = (int)(10.0 * cos(c) * 64.0);
		points[p].y = (int)(10.0 * sin(c) * 64.0);
		points[p].z = i2f(5);
	}
	// define the top point
	points[4].x = 0;
	points[4].y = 0;
	points[4].z = i2f(-5);

	// define triangles
	// side a
	triangles[0].vertexes[0] = &points[4];
	triangles[0].vertexes[1] = &points[0];
	triangles[0].vertexes[2] = &points[1];

	// side b
	triangles[1].vertexes[0] = &points[4];
	triangles[1].vertexes[1] = &points[1];
	triangles[1].vertexes[2] = &points[2];

	// side c
	triangles[2].vertexes[0] = &points[4];
	triangles[2].vertexes[1] = &points[2];
	triangles[2].vertexes[2] = &points[3];

	// side d
	triangles[3].vertexes[0] = &points[4];
	triangles[3].vertexes[1] = &points[3];
	triangles[3].vertexes[2] = &points[0];

	// base 1
	triangles[4].vertexes[0] = &points[0];
	triangles[4].vertexes[1] = &points[3];
	triangles[4].vertexes[2] = &points[2];

	// base 2
	triangles[5].vertexes[0] = &points[2];
	triangles[5].vertexes[1] = &points[1];
	triangles[5].vertexes[2] = &points[0];

	return mesh;	// done! :)
}
开发者ID:bitfixer,项目名称:bitfixer,代码行数:54,代码来源:ex11.c

示例10: do_cheat_menu

void do_cheat_menu()
{
	int mmn;
	newmenu_item mm[16];
	char score_text[21];

	sprintf( score_text, "%d", Players[Player_num].score );

	mm[0].type=NM_TYPE_CHECK; mm[0].value=Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE; mm[0].text="Invulnerability";
	mm[1].type=NM_TYPE_CHECK; mm[1].value=Players[Player_num].flags & PLAYER_FLAGS_CLOAKED; mm[1].text="Cloaked";
	mm[2].type=NM_TYPE_CHECK; mm[2].value=0; mm[2].text="All keys";
	mm[3].type=NM_TYPE_NUMBER; mm[3].value=f2i(Players[Player_num].energy); mm[3].text="% Energy"; mm[3].min_value=0; mm[3].max_value=200;
	mm[4].type=NM_TYPE_NUMBER; mm[4].value=f2i(Players[Player_num].shields); mm[4].text="% Shields"; mm[4].min_value=0; mm[4].max_value=200;
	mm[5].type=NM_TYPE_TEXT; mm[5].text = "Score:";
	mm[6].type=NM_TYPE_INPUT; mm[6].text_len = 10; mm[6].text = score_text;
	mm[7].type=NM_TYPE_RADIO; mm[7].value=(Players[Player_num].laser_level==0); mm[7].group=0; mm[7].text="Laser level 1";
	mm[8].type=NM_TYPE_RADIO; mm[8].value=(Players[Player_num].laser_level==1); mm[8].group=0; mm[8].text="Laser level 2";
	mm[9].type=NM_TYPE_RADIO; mm[9].value=(Players[Player_num].laser_level==2); mm[9].group=0; mm[9].text="Laser level 3";
	mm[10].type=NM_TYPE_RADIO; mm[10].value=(Players[Player_num].laser_level==3); mm[10].group=0; mm[10].text="Laser level 4";
	mm[11].type=NM_TYPE_NUMBER; mm[11].value=Players[Player_num].secondary_ammo[CONCUSSION_INDEX]; mm[11].text="Missiles"; mm[11].min_value=0; mm[11].max_value=200;

	mmn = newmenu_do("Wimp Menu",NULL,12, mm, NULL, NULL );

	if (mmn > -1 )  {
		if ( mm[0].value )  {
			Players[Player_num].flags |= PLAYER_FLAGS_INVULNERABLE;
			Players[Player_num].invulnerable_time = GameTime64+i2f(1000);
		} else
			Players[Player_num].flags &= ~PLAYER_FLAGS_INVULNERABLE;
		if ( mm[1].value )
		{
			Players[Player_num].flags |= PLAYER_FLAGS_CLOAKED;
			#ifdef NETWORK
			if (Game_mode & GM_MULTI)
				multi_send_cloak();
			#endif
			ai_do_cloak_stuff();
			Players[Player_num].cloak_time = GameTime64;
		}
		else
			Players[Player_num].flags &= ~PLAYER_FLAGS_CLOAKED;

		if (mm[2].value) Players[Player_num].flags |= PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_RED_KEY | PLAYER_FLAGS_GOLD_KEY;
		Players[Player_num].energy=i2f(mm[3].value);
		Players[Player_num].shields=i2f(mm[4].value);
		Players[Player_num].score = atoi(mm[6].text);
		if (mm[7].value) Players[Player_num].laser_level=0;
		if (mm[8].value) Players[Player_num].laser_level=1;
		if (mm[9].value) Players[Player_num].laser_level=2;
		if (mm[10].value) Players[Player_num].laser_level=3;
		Players[Player_num].secondary_ammo[CONCUSSION_INDEX] = mm[11].value;
		init_gauges();
	}
}
开发者ID:Mako88,项目名称:DXX-Retro,代码行数:54,代码来源:gamecntl.c

示例11: draw_exit_model

draw_exit_model()
{
	vms_vector model_pos;
	int f=15,u=0;	//21;

	vm_vec_scale_add(&model_pos,&mine_exit_point,&mine_exit_orient.fvec,i2f(f));
	vm_vec_scale_add2(&model_pos,&mine_exit_orient.uvec,i2f(u));

	draw_polygon_model(&model_pos,&mine_exit_orient,NULL,(mine_destroyed)?destroyed_exit_modelnum:exit_modelnum,0,f1_0,NULL,NULL);

}
开发者ID:NonCreature0714,项目名称:descent,代码行数:11,代码来源:ENDLEVEL.C

示例12: MultiDoCheatPenalty

void MultiDoCheatPenalty ()
{
DoCheatPenalty ();
LOCALPLAYER.shields = i2f (1);
MultiSendShields ();
LOCALPLAYER.energy = i2f (1);
if (gameData.app.nGameMode & GM_MULTI) {
	gameData.multigame.msg.nReceiver = 100;		// Send to everyone...
	sprintf (gameData.multigame.msg.szMsg, TXT_CRIPPLED, LOCALPLAYER.callsign);
	}
HUDInitMessage (TXT_TAKE_THAT);
}
开发者ID:paud,项目名称:d2x-xl,代码行数:12,代码来源:cheats.c

示例13: MultiDoCheatPenalty

void MultiDoCheatPenalty ()
{
DoCheatPenalty ();
gameData.multi.players [gameData.multi.nLocalPlayer].shields = i2f (1);
MultiSendShields ();
gameData.multi.players [gameData.multi.nLocalPlayer].energy = i2f (1);
#ifdef NETWORK
if (gameData.app.nGameMode & GM_MULTI) {
	multiData.msg.nReceiver = 100;		// Send to everyone...
	sprintf (multiData.msg.szMsg, TXT_CRIPPLED, gameData.multi.players [gameData.multi.nLocalPlayer].callsign);
	}
#endif
HUDInitMessage (TXT_TAKE_THAT);
}
开发者ID:paud,项目名称:d2x-xl,代码行数:14,代码来源:cheats.c

示例14: timer_get_fixed_seconds

fix timer_get_fixed_seconds()
{
        fix x;

	//Ye good olde unix:
        //Ye bad olde Windows DPH:-)
/* DPH: Using timeGetTime will fail approximately 47 days after Windows was
   started as the timer wraps around to 0. Ever had Windows not crash for 47
   consecutive days? Thought not. */

        unsigned long tv_now=timeGetTime()-old_tv;
        x=i2f(tv_now/1000) | fixdiv(i2f(tv_now % 1000),i2f(1000));
	return x;
}
开发者ID:btb,项目名称:d2x,代码行数:14,代码来源:timer.c

示例15: update_player_stats

//update various information about the player
void update_player_stats()
{
	Players[Player_num].time_level += FrameTime;	//the never-ending march of time...
	if ( Players[Player_num].time_level > i2f(3600) )	{
		Players[Player_num].time_level -= i2f(3600);
		Players[Player_num].hours_level++;
	}

	Players[Player_num].time_total += FrameTime;	//the never-ending march of time...
	if ( Players[Player_num].time_total > i2f(3600) )	{
		Players[Player_num].time_total -= i2f(3600);
		Players[Player_num].hours_total++;
	}
}
开发者ID:Mako88,项目名称:DXX-Retro,代码行数:15,代码来源:gameseq.c


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