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


C++ Menu::Clicking方法代码示例

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


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

示例1: KeyButtons

//---------------------------- SCREEN/HUD CONTROLS
void KeyButtons(unsigned char key, int y, int z) {


	//--------------------------CHANGE ENEMY' SPEED
	switch (key)
	{
	case '1':
		lvl.SetEnemiesSpeed(15);
		break;
	case '2':
		lvl.SetEnemiesSpeed(20);
		break;
	case '3':
		lvl.SetEnemiesSpeed(30);
		break;
	}


// -------------------------------- PLAYER FIRE
	if (inGame)
	{
		if (key == ' ' && (player.IsFiring() == false)) 
		{
			if (!(player.HasPowderBag())) { // As long has player has no powder bag
				player.Attack();
				lvl.NewFire(player.GetWeapon(), player.GetDir(), player.GetPos());
			}
			else { // consume powder bag and convert cases

				int X = round(player.GetPos().x / TextWidth + 0.4);
				int Y = round(player.GetPos().y / TextWidth + 0.4);

				switch (player.GetDir())
				{
				case 'u':
					for (int i = player.GetPos().y/TextWidth; i > player.GetPos().y/ TextWidth - 5; i--) {
						lvl.SetMap(X, i, 4);
					}
					break;
				case 'd':
					for (int i = player.GetPos().y / TextWidth; i < player.GetPos().y / TextWidth + 5; i++) {
						lvl.SetMap(X, i, 4);
					}
					break;
				case 'r':
					for (int i = player.GetPos().x / TextWidth; i < player.GetPos().x / TextWidth + 5; i++) {
						lvl.SetMap(i, Y, 4);
					}
					break;
				case 'l':
					for (int i = player.GetPos().x / TextWidth; i > player.GetPos().x / TextWidth - 5; i--) {
						lvl.SetMap(i, Y, 4);
					}
					break;
				}
				player.SetPowderBag(false);
			}
		}
	
		if (key == 'p') {
			cout << key << endl;
			menu.Pause();
		}
	}
	else
	{

		if (key == ' ') {
			menu.Clicking();
		}

		if (key == 'p') {
			cout << key << endl;
			menu.Pause();
		}
	}
}
开发者ID:ViolaineF,项目名称:TerraSkweek,代码行数:78,代码来源:Main.cpp

示例2: InterfaceArduino


//.........这里部分代码省略.........
		}
		else if (incomingData[0] == 'W') { // Player is visible
			player.setOpacity(0.70);
			light = 0.70;

		}
		else if (incomingData[0] == 'V') { // Player is visible
			player.setOpacity(1.0);
			light = 1.0;
		}
		else if (incomingData[0] == 'F') { // Player is firing
			if (inGame) {

				if (player.IsFiring() == false)
				{
					if (!(player.HasPowderBag())) { // As long has player has no powder bag
						player.Attack();
						lvl.NewFire(player.GetWeapon(), player.GetDir(), player.GetPos());
					}
					else { // consume powder bag and convert cases

						int X = round(player.GetPos().x / TextWidth + 0.4);
						int Y = round(player.GetPos().y / TextWidth + 0.4);

						switch (player.GetDir())
						{
						case 'u':
							for (int i = player.GetPos().y / TextWidth; i > player.GetPos().y / TextWidth - 5; i--) {
								if (lvl.Map(X, i) == 0)
									lvl.SetMap(X, i, 4);
							}
							break;
						case 'd':
							for (int i = player.GetPos().y / TextWidth; i < player.GetPos().y / TextWidth + 5; i++) {
								if (lvl.Map(X, i) == 0)
									lvl.SetMap(X, i, 4);
							}
							break;
						case 'r':
							for (int i = player.GetPos().x / TextWidth; i < player.GetPos().x / TextWidth + 5; i++) {
								if (lvl.Map(X, i) == 0)
									lvl.SetMap(X, i, 4);
							}
							break;
						case 'l':
							for (int i = player.GetPos().x / TextWidth; i > player.GetPos().x / TextWidth - 5; i--) {
								if (lvl.Map(X, i) == 0)
									lvl.SetMap(X, i, 4);

							}
							break;
						}
						player.SetPowderBag(false);
					}
				}

			}
			else
			{
				menu.Clicking();
			}
		}
		else if (incomingData[0] == 'u') { // Player's Direction
			player.SwitchDir('u');
			player.SetMoving(true);
			player.SetStillMoving(true);
		}
		else if (incomingData[0] == 'd') { // Player's Direction
			player.SwitchDir('d');
			player.SetMoving(true);
			player.SetStillMoving(true);
		}
		else if (incomingData[0] == 'r') { // Player's Direction
			player.SwitchDir('r');
			player.SetMoving(true);
			player.SetStillMoving(true);
		}
		else if (incomingData[0] == 'l') { // Player's Direction
			player.SwitchDir('l');
			player.SetMoving(true);
			player.SetStillMoving(true);
		}
		else if (incomingData[0] == 'A') { // Enemies' speed
			lvl.SetEnemiesSpeed(18);
			cout << "A" << endl;
		}
		else if (incomingData[0] == 'B') { // Enemies' speed
			lvl.SetEnemiesSpeed(12);
			cout << "B" << endl;

		}
		else if (incomingData[0] == 'C') { // Enemies' speed
			lvl.SetEnemiesSpeed(6);
			cout << "C" << endl;

		}
	}

	//Serial.read() ---- pour éteindre / allumer les leds
}
开发者ID:ViolaineF,项目名称:TerraSkweek,代码行数:101,代码来源:Main.cpp


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