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


C++ game_import_t::cprintf方法代码示例

本文整理汇总了C++中game_import_t::cprintf方法的典型用法代码示例。如果您正苦于以下问题:C++ game_import_t::cprintf方法的具体用法?C++ game_import_t::cprintf怎么用?C++ game_import_t::cprintf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在game_import_t的用法示例。


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

示例1: game_cprintf

void game_cprintf(edict_t *ent, int printlevel, char *fmt, ...)
{
	va_list args;
	char buf[1024];

	va_start(args, fmt);
	vsnprintf(buf, sizeof buf, fmt, args);
	buf[sizeof buf - 1] = 0;
	va_end(args);

	if (ent == NULL)
		q2a_lua_LogMessage(buf);

	gi.cprintf(ent, printlevel, "%s", buf);
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例2: CheckPlayerLookTargets

void CheckPlayerLookTargets (void)
{
    cvar_t *show_look;
    int i;
	edict_t	*ent;
    player_state_t *ps;
	vec3_t view_origin, forward, right, distance, view_target;
	trace_t trace;

    // Set this console variable to display information about what the
    // player is looking at.  For debugging purposes.
    show_look = gi.cvar("show_look", "0", CVAR_SERVERINFO);

    // Iterate over all the active players.
    for (i=0 ; i<maxclients->value ; i++)
    {
		ent = g_edicts + 1 + i;
		if (!ent->inuse)
			continue;
        
        // Calculate the player's line of sight, beginning at view_origin
        // and extending to view_target a fair distance away.
        ps = &ent->client->ps;
        VectorAdd(ent->s.origin, ps->viewoffset, view_origin);
        AngleVectors(ps->viewangles, forward, right, NULL);
        VectorSet(distance, LOOK_DISTANCE, 0, 0);
        G_ProjectSource(view_origin, distance, forward, right, view_target);

        // Trace the player's line of sight and see what we hit.  We begin
        // the trace at view_origin, use a size zero bounding box (NULL,
        // NULL), end the trace at view_target, ignore the player 'ent', and
        // stop when we hit any of the specified object types.
        trace = gi.trace(view_origin, NULL, NULL, view_target, ent,
                         MASK_OPAQUE|CONTENTS_WINDOW|CONTENTS_MONSTER|
                         CONTENTS_DEADMONSTER);

        // If show_look is true, report what the player is currently
        // looking at for debugging purposes
        if (show_look->value && trace.ent && trace.ent->classname)
            gi.cprintf(ent, PRINT_HIGH, "Looking at: %s %x\n",
                       trace.ent->classname, trace.ent);

		// If we're looking at something new, remember it and run any
		// associated look_target.
		if (trace.ent != ent->client->looking_at)
		{
			ent->client->looking_at = trace.ent;
			if (trace.ent && trace.ent->look_target)
				G_UseTargetsByName(trace.ent, trace.ent->look_target, ent);
		}

		// Objects don't get reticles if they're too far away.
		if (trace.fraction > (1.0 * RETICLE_DISTANCE) / LOOK_DISTANCE)
			trace.ent = NULL;

		// We need to resend the reticle every frame, in case the entity
		// is moving relative to the world.
		SendReticle(trace.ent, ent);

		// If the reticle is on something new, remember it and run any
		// associated r_look_target (sound familiar?).
		if (trace.ent != ent->client->reticle_on)
		{
			ent->client->reticle_on = trace.ent;
			if (trace.ent && trace.ent->r_look_target)
				G_UseTargetsByName(trace.ent, trace.ent->r_look_target, ent);
		}
    }
}
开发者ID:lambda,项目名称:wxQuake2,代码行数:69,代码来源:g_main.c


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