Пример #1
0
void GAMECLIENT::on_game_restart()
{
	if(!demorec_isplaying() && config.tc_autodemo && demorec_isrecording())
	{
		demorec_record_stop();
		teecomp_demo_start();
	}
	for(int i=0; i<MAX_CLIENTS; i++)
		stats[i].reset();
}
Пример #2
0
void HUD::render_speed()
{
	if(!config.tc_speedmeter)
		return;

	// We calculate the speed instead of getting it from character.velocity cause it's buggy when
	// walking in front of a wall or when using the ninja sword
	static float speed;
	static vec2 oldpos;
	static const int SMOOTH_TABLE_SIZE = 16;
	static const int ACCEL_THRESHOLD = 25;
	static float smooth_table[SMOOTH_TABLE_SIZE];
	static int smooth_index = 0;

	smooth_table[smooth_index] = distance(gameclient.local_character_pos, oldpos)/client_frametime();
	if(demorec_isplaying()) {
		float mult = client_demoplayer_getinfo()->speed;
		smooth_table[smooth_index] /= mult;
	}
	smooth_index = (smooth_index + 1) % SMOOTH_TABLE_SIZE;
	oldpos = gameclient.local_character_pos;
	speed = 0;
	for(int i=0; i<SMOOTH_TABLE_SIZE; i++)
		speed += smooth_table[i];
	speed /= SMOOTH_TABLE_SIZE;

	int t = (gameclient.snap.gameobj->flags & GAMEFLAG_TEAMS)? -1 : 1;
	int last_index = smooth_index - 1;
	if(last_index < 0)
		last_index = SMOOTH_TABLE_SIZE - 1;

	gfx_blend_normal();
	gfx_texture_set(-1);
	gfx_quads_begin();
	if(config.tc_speedmeter_accel && speed - smooth_table[last_index] > ACCEL_THRESHOLD)
		gfx_setcolor(0.6f, 0.1f, 0.1f, 0.25f);
	else if(config.tc_speedmeter_accel && speed - smooth_table[last_index] < -ACCEL_THRESHOLD)
		gfx_setcolor(0.1f, 0.6f, 0.1f, 0.25f);
	else
		gfx_setcolor(0.1, 0.1, 0.1, 0.25);
	draw_round_rect(width-40, 245+t*20, 50, 18, 5.0f);
	gfx_quads_end();

	char buf[16];
	str_format(buf, sizeof(buf), "%.0f", speed);
	gfx_text(0, width-5-gfx_text_width(0,12,buf,-1), 246+t*20, 12, buf, -1);
}
Пример #3
0
void GAMECLIENT::on_game_over()
{
	if(config.tc_autoscreen && !demorec_isplaying())
		gfx_screenshot();
}