Beispiel #1
0
void gui_start() {
	
	if (panJetpack == NULL) {
		gui_init();
	}
	
	panJetpackBorder.pos_x = 5;
	panJetpackBorder.pos_y = 5;
	panJetpack.pos_x = 5;
	panJetpack.pos_y = 5;
	
	panHeart1.pos_x = screen_size.x - 5 - 3*bmap_width(bmapZorroLife) - 3 * 2;
	panHeart2.pos_x = screen_size.x - 5 - 2*bmap_width(bmapZorroLife) - 2 * 2;
	panHeart3.pos_x = screen_size.x - 5 - 1*bmap_width(bmapZorroLife) - 1 * 2;
	panHeart1.pos_y = 5;
	panHeart2.pos_y = 5;
	panHeart3.pos_y = 5;
	txtLifes.pos_x = panHeart1.pos_x - 20;
	txtLifes.pos_y = 5;
	
	panA4Cube.pos_x = (screen_size.x / 2) - (bmap_width(bmapA4Cube) / 2);
	panA4Cube.pos_y = 5;
	txtA4Cube.pos_x = panA4Cube.pos_x - 15;
	txtA4Cube.pos_y = 10;
	
	txtGameOver.pos_x = screen_size.x / 2;
	txtGameOver.pos_y = screen_size.y / 2;	
}
/**
 * Calculates the normalization and scaling parameters of a uniformly scaled image
 *
 * bmapImg
 *    The image
 *
 * refNormX & -Y
 *    Double pointers, which receive the normalization factors for non-power-of-2 images
 *
 * refScaleX & -Y
 *    Double pointers, which receive the scaling factors for making the image fit the
 *    screen while being uniformly scaled
 */
void ppImageCalcScaling (BMAP* bmapImg, double* refNormX, double* refNormY, double* refScaleX, double* refScaleY)
{
	if (bmapImg == NULL)
		return;

	double w = bmap_width(bmapImg);
	double h = bmap_height(bmapImg);

	// normalization factor for non-power-of-2 images
	*refNormX = w / ppTrinary(bmapImg->finalwidth < 1, 1, bmapImg->finalwidth+2);
	*refNormY = h / ppTrinary(bmapImg->finalheight < 1, 1, bmapImg->finalheight+2);

	// bitmap- and screen aspect ratio
	double bmapAspect = w / h;
	double screenAspect = (double)screen_size.x / (double)screen_size.y;

	// the aspect ratios are compared to determine if the image is relatively wider or
	// taller than the screen. If the image is taller, it will be fitted on the x-axis and
	// will be centered on the y-axis; and vice versa.

	if (bmapAspect < screenAspect) // taller
	{
		*refScaleX = 1;
		*refScaleY = bmapAspect / screenAspect;
	}
	else // wider
	{
		*refScaleX = screenAspect / bmapAspect;
		*refScaleY = 1;
	}
}
Beispiel #3
0
void game_hotkeys() {
	panMute = pan_create("", 200);
	panMute.bmap = bmapMute;
	
	while(1) {
		if (key_f9) {
			while(key_f9) wait(1);
			
			// Reposition because of possible resolution change
			panMute.pos_x = screen_size.x - bmap_width(bmapMute) - 10;
			panMute.pos_y = screen_size.y - bmap_height(bmapMute) - 10;
			
			if ((master_vol == -1) || (master_vol > 0)) {
				set(panMute, SHOW);
				master_vol = 0;
			} else {
				reset(panMute, SHOW);
				master_vol = 100;
			}
		}
		wait(1);
	}
}
Beispiel #4
0
void gameOver() {
	isGameOver = 1;
	endIngameGUI();
	ent_remove(player);
	panGameOver.pos_x = screen_size.x / 2 - bmap_width(bmapGameOver) / 2;
	panGameOver.pos_y = screen_size.y / 2 - bmap_height(bmapGameOver) / 2;
	set(panGameOver, SHOW);
	
	vec_set(vecCamTmp, entHut.x);
	int counter = 1000;
	while(counter > 0) {
		cam_angle +=0.005 * time_step;
		camera.x = cos(cam_angle) * 768;
		camera.y = sin(cam_angle) * 768;
		vec_diff(vecCamTmp.x, nullvector, camera.x);
		vec_to_angle(camera.pan, vecCamTmp);
		counter--;
		wait(1);
	}
	
	reset(panGameOver, SHOW);
	isGameOver = 2;
	//backToMenu();
}