Esempio n. 1
0
// blip is for a target immune to sensors, so cause to flicker in/out with mild distortion
void radar_blip_draw_flicker_std(blip *b)
{
	int xdiff=0, ydiff=0, flicker_index;

	if ( (b-Blips) & 1 ) {
		flicker_index=0;
	} else {
		flicker_index=1;
	}

	if ( timestamp_elapsed(Radar_flicker_timer[flicker_index]) ) {
		Radar_flicker_timer[flicker_index] = timestamp_rand(50,1000);
		Radar_flicker_on[flicker_index] ^= 1;
	}

	if ( !Radar_flicker_on[flicker_index] ) {
		return;
	}

	if ( rand() & 1 ) {
		xdiff = -2 + rand()%4;
		ydiff = -2 + rand()%4;
	}

	radar_draw_circle_std( b->x+xdiff, b->y+ydiff, b->rad ); 
}
Esempio n. 2
0
// Draw all the active radar blips
void draw_radar_blips_std(int blip_type, int bright, int distort)
{
	blip* b = NULL;
	blip* blip_head = NULL;

	Assert((blip_type >= 0) && (blip_type < MAX_BLIP_TYPES));


	// Need to set font.
	gr_set_font(FONT1);


	// get the appropriate blip list
	if (bright)
		blip_head = &Blip_bright_list[blip_type];
	else
		blip_head = &Blip_dim_list[blip_type];


	// draw all blips of this type
	for (b = GET_FIRST(blip_head); b != END_OF_LIST(blip_head); b = GET_NEXT(b))
	{
		gr_set_color_fast(b->blip_color);

		// maybe draw cool blip to indicate current target
		if (b->flags & BLIP_CURRENT_TARGET)
		{
			b->rad = Current_radar_global->Radar_blip_radius_target[gr_screen.res];
			current_target_x = b->x;
			current_target_y = b->y;
		}
		else
		{
			b->rad = Current_radar_global->Radar_blip_radius_normal[gr_screen.res];
		}

		// maybe distort blip
		if (distort)
		{
			radar_blip_draw_distorted_std(b);
		}
		else if (b->flags & BLIP_DRAW_DISTORTED)
		{
			radar_blip_draw_flicker_std(b);
		}
		else
		{
			if (b->radar_image_2d == -1)
				radar_draw_circle_std(b->x, b->y, b->rad);
			else
				radar_draw_image_std(b->x, b->y, b->rad, b->radar_image_2d, b->radar_image_size);
		}
	}
}
Esempio n. 3
0
// radar is damaged, so make blips dance around
void radar_blip_draw_distorted_std(blip *b)
{
	int xdiff, ydiff;
	float scale;
	xdiff = -10 + rand()%20;
	ydiff = -10 + rand()%20;

	// maybe scale the effect if EMP is active
	if(emp_active_local()){
		scale = emp_current_intensity();

		xdiff = (int)((float)xdiff * scale);
		ydiff = (int)((float)ydiff * scale);
	}

	radar_draw_circle_std( b->x+xdiff, b->y+ydiff, b->rad ); 
}
Esempio n. 4
0
void radar_draw_image_std(int x, int y, int rad, int idx, int size)
{
	// this we will move as ships.tbl option (or use for radar scaling etc etc)
	//int size = 24; 

	int w, h, old_bottom, old_bottom_unscaled, old_right, old_right_unscaled;
	float scalef, wf, hf, xf, yf;
	vec3d blip_scaler;

	if (bm_get_info(idx, &w, &h) < 0)
	{
		// Just if something goes terribly wrong
		radar_draw_circle_std(x, y, rad);
		return;
	}

	// just to make sure the missing casts wont screw the math
	wf = (float)w;
	hf = (float)h;
	xf = (float)x;
	yf = (float)y;

	// make sure we use the larger dimension for the scaling
	// lets go case by case to make sure there are no probs
	if (size == -1)
		scalef = 1.0f;
	else if ((h == w) && (size == h))
		scalef = 1.0f;
	else if (h > w)
		scalef = ((float)size) / hf;
	else
		scalef = ((float)size) / wf;

	Assert(scalef != 0);

	// animate the targeted icon - option 1 of highlighting the targets
	if (rad == Current_radar_global->Radar_blip_radius_target[gr_screen.res])
	{
		if (radar_target_id_flags & RTIF_PULSATE)
		{
			scalef *= 1.3f + (sinf(10 * f2fl(Missiontime)) * 0.3f);
		}
		if (radar_target_id_flags & RTIF_BLINK)
		{
			if (Missiontime & 8192)
				return;
		}
		if (radar_target_id_flags & RTIF_ENLARGE)
		{
			scalef *= 1.3f;
		}
	}

	// setup the scaler
	blip_scaler.xyz.x = scalef;
	blip_scaler.xyz.y = scalef;
	blip_scaler.xyz.z = 1.0f;

	old_bottom = gr_screen.clip_bottom;
	old_bottom_unscaled = gr_screen.clip_bottom_unscaled;
	gr_screen.clip_bottom = (int)(old_bottom / scalef);
	gr_screen.clip_bottom_unscaled = (int)(old_bottom_unscaled / scalef);

	old_right = gr_screen.clip_right;
	old_right_unscaled = gr_screen.clip_right_unscaled;
	gr_screen.clip_right = (int)(old_right / scalef);
	gr_screen.clip_right_unscaled = (int)(old_right_unscaled / scalef);

	// scale the drawing coordinates
	x = (int)((xf / scalef) - wf / 2.0f);
	y = (int)((yf / scalef) - hf / 2.0f);

	gr_push_scale_matrix(&blip_scaler);
	gr_set_bitmap(idx, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f);
	gr_aabitmap(x, y);
	gr_pop_scale_matrix();

	gr_screen.clip_bottom = old_bottom;
	gr_screen.clip_bottom_unscaled = old_bottom_unscaled;

	gr_screen.clip_right = old_right;
	gr_screen.clip_right_unscaled = old_right_unscaled;
}