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


C++ display::getMouseEventY方法代码示例

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


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

示例1: main

/*
 * This is the main function that starts the driver artifact.
 * This function demonstrates some of the abilities of the Display class
 */
int main(int argc, char* argv[])
{

	// various variable declarations
	char key;
	int numOfComps = 0;
	int coordX = 0;
	int coordY = 0;
	int gameState = 0;
	int cardSelected = 0;

	// enable a interrupt triggered on a window resize
	signal(SIGWINCH, detectResize); // enable the window resize signal

	/* You can uncomment and change the colors for various cards here*/
	//    init_pair(1, COLOR_CYAN, COLOR_BLACK); // for card outline
	//    init_pair(2, COLOR_BLUE, COLOR_BLACK); // for spades and clubs
	//    init_pair(3, COLOR_RED, COLOR_BLACK);  // for hearts and diamonds
	//    init_pair(4, COLOR_GREEN, COLOR_BLACK); // for turned over card
	//    init_pair(5, COLOR_GREEN, COLOR_BLACK); // for box drawing
	//    init_pair(6, COLOR_GREEN, COLOR_BLACK); // for banner display

	//Display the intro and select the amount of computer players.
	gameDisplay.bannerTop("GoFish!");
	gameDisplay.bannerBottom("Select the number of computer players...");
	gameDisplay.displayCard(10,5,1,1, A_BOLD);
	gameDisplay.displayCard(20,5,1,2, A_BOLD);
	gameDisplay.displayCard(30,5,1,3, A_BOLD);
	for(;;)
	{
		key = gameDisplay.captureInput();
		coordX = gameDisplay.getMouseEventX();
		coordY = gameDisplay.getMouseEventY();
		if(coordX >= 10 && coordX <= 15 && coordY >= 5 && coordY <= 9)
		{
			gameDisplay.bannerBottom("1 Computer selected.");
			numOfComps = 1;
			break;
		}
		else if(coordX >= 20 && coordX <= 25 && coordY >= 5 && coordY <= 9)
		{
			gameDisplay.bannerBottom("2 Computers selected.");
			numOfComps = 2;
			break;
		}
		else if(coordX >= 30 && coordX <= 35 && coordY >= 5 && coordY <= 9)
		{
			gameDisplay.bannerBottom("3 Computers selected.");
			numOfComps = 3;
			break;
		}
	}

	//Creates the computer players on the screen.
	gameDisplay.bannerTop("GoFish");
	gameDisplay.eraseBox(2,2,60,10);
	player player1("Player 1",12,40);
	player player2("Computer 1",35,4,7,5);
	player player3("Computer 2",70,8,7,68);
	player player4("Computer 3",5,8,3,32);
	mvprintw(12,32,"(You)");
	mvprintw(12,40,"Score: 0");
	currentGame.addPlayer(player1);
	if(numOfComps > 2)
	{
		gameDisplay.displayCard(5,8,0,0, COLOR_PAIR(4));
		mvprintw(6,5,"Computer 3");
		mvprintw(7,5,"Score: 0");
		currentGame.addPlayer(player4); //add player to game
	}
	if(numOfComps > 1)
	{
		gameDisplay.displayCard(70,8,0,0, COLOR_PAIR(4));
		mvprintw(6,68,"Computer 2");
		mvprintw(7,68,"Score: 0");
		currentGame.addPlayer(player3); //add player to game
	}
	if(numOfComps > 0)
	{
		gameDisplay.displayCard(35,4,0,0, COLOR_PAIR(4));
		mvprintw(2,32,"Computer 1");
		mvprintw(3,32,"Score: 0");
		currentGame.addPlayer(player2); //add player to game
	}
	currentGame.createGame(); //deal out the cards and perform any other configuration
	displayHand(currentGame.getPlayer(0).getHand()); //display the new hand
	updateScore(numOfComps); //update the score in case any pairs off the bat

	for (;;) 
	{
		bool gameOver = false;
		while(!gameOver)
		{
			key = gameDisplay.captureInput();
			coordX = gameDisplay.getMouseEventX();
			coordY = gameDisplay.getMouseEventY();
//.........这里部分代码省略.........
开发者ID:marcochiang,项目名称:RoyalCrowns,代码行数:101,代码来源:main.cpp


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