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


C++ UIManager::setUnits方法代码示例

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


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

示例1: main


//.........这里部分代码省略.........
	uM.spawnUnit(turtle, p.playerUnit->x, p.playerUnit->y + 1);
	std::cout << p.playerUnit->x + 1 <<  p.playerUnit->y + 1 << std::endl;
	uM.gatherActions();

	sf::Clock frameClock;
	while (window.isOpen())
	{
		sf::Event event;
		while (window.pollEvent(event))
		{
			if (event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
				window.close();
			if (event.type == sf::Event::MouseButtonPressed)
			{
				mousex = sf::Mouse::getPosition(window).x;
				mousey = sf::Mouse::getPosition(window).y;

			}
			if (sf::Mouse::isButtonPressed(sf::Mouse::Left) && event.type == sf::Event::MouseMoved)
			{
				uimanager.x += event.mouseMove.x-mousex;
				uimanager.y += event.mouseMove.y-mousey;
				mousex = event.mouseMove.x;
				mousey = event.mouseMove.y;
			}
			if (sf::Keyboard::isKeyPressed(sf::Keyboard::P)) 
			{
				uM.gatherActions();
			}
			if (event.type == sf::Event::MouseButtonReleased && event.mouseButton.button == sf::Mouse::Button::Right)
			{
				std::cout << "clicked at " << sf::Mouse::getPosition(window).x-uimanager.x << " " << sf::Mouse::getPosition(window).y-uimanager.y << std::endl;
				//std::cout << "is accessible: " << lvl.isAccessible(sf::Mouse::getPosition(window).x - uimanager.x, sf::Mouse::getPosition(window).y - uimanager.y) << std::endl;
				int xPos = sf::Mouse::getPosition(window).x - uimanager.x;
				int yPos = sf::Mouse::getPosition(window).y - uimanager.y;
				//std::cout << lvl.map[xPos / 128][yPos / 128].pawn << std::endl;
				if (lvl.isAccessible(xPos, yPos)) {
					uM.interact(xPos/128, yPos/128, &p);
					std::cout << xPos/128 << yPos/128 << std::endl;
					
					std::cout << "great success !" << std::endl;
				} else
					std::cout << "no" << std::endl;
			}
			/* Zooming - Experimental
			if (event.type == sf::Event::MouseWheelScrolled)
			{
				uimanager.scale = signbit(event.mouseWheelScroll.delta)?uimanager.scale*0.95:uimanager.scale*1.05;
			}*/
		}
		//UI Movement
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
			uimanager.y += 1;
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
			uimanager.y -= 1;
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
			uimanager.x += 1;
		if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
			uimanager.x -= 1;
		if (sf::Mouse::getPosition(window).x < 20)
			uimanager.x += 1;
		if (sf::Mouse::getPosition(window).x > 1900)
			uimanager.x -= 1;
		if (sf::Mouse::getPosition(window).y < 20)
			uimanager.y += 1;
		if (sf::Mouse::getPosition(window).y > 1060)
			uimanager.y -= 1;

		// lvl.genDrawable(&output);
		// UIManager uimanager;
		// uimanager.setTerrain(output);
		
		sf::Time frameTime = frameClock.restart();

		animatedShibe.update(frameTime);

		window.clear();
		//sf::Sprite output2;
		//lvl.drawUnits(&output);
		//uimanager.setUnits(output2);
		//window.draw(*(uimanager.getUI()));
		//window.draw(*(uimanager.getUnits()));
		uimanager.setUnits(uM.getUnits());
		uimanager.drawEverything(&window);
		window.draw(animatedShibe);
		//window.draw(*sprite);
		//window.draw(output);
		/*sf::Texture texture;
		texture.loadFromFile("Sprites\\PlayerChar.png");
		texture.setSmooth(true);
		sf::Sprite* sprite = (new sf::Sprite(texture));
		(*sprite).setColor(sf::Color(128, 128, 128));
		sprite.setTexture(texture);*/
		//window.draw(*sprite);
		//std::cout << "Current player AP: " << p.playerUnit->currAP << ". Max player AP: " << p.playerUnit->maxAP << "." << std::endl;
		window.display();
	}

	return 0;
}
开发者ID:PhilWimmer,项目名称:MagicFunGame,代码行数:101,代码来源:Quelle.cpp


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