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


C++ Levels::setLevels方法代码示例

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


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

示例1: main

int main(int argc, char* argv[])
{
	sf::RenderWindow WINDOW(sf::VideoMode(1280, 720, 32), "Arctic", sf::Style::Close);
	WINDOW.SetFramerateLimit(60);

	Levels* levels;
	levels->setLevels();
	sf::Clock clock;
	float time = clock.GetElapsedTime();
	state = Ingame;
	prevState = Menu;

	/* Main Menu Buttons */
	BUTTON play(440, 200, "PLAY");
	BUTTON options(440, 320, "OPTIONS");
	BUTTON quit(440, 440, "QUIT");

	/* Pause Buttons */
	BUTTON resume(440, 200, "RESUME");
	BUTTON pauseOptions(440, 320, "OPTIONS");
	BUTTON quitToMenu(440, 440, "QUIT TO MENU");	

	/* Strings */
	STRING str("Arctic - Sprite Testing", 5, 2, sf::Color(255, 255, 255));

	while(WINDOW.IsOpened())
	{
		sf::Event event;
		sf::Vector2i mouse(WINDOW.GetInput().GetMouseX(), WINDOW.GetInput().GetMouseY());
		time = clock.GetElapsedTime();

		while(WINDOW.GetEvent(event))
		{
			switch(event.Type)
			{
			case sf::Event::Closed:
				WINDOW.Close();
				break;
			case sf::Event::KeyPressed:
				if(event.Key.Code == sf::Key::Escape)
				{
					if(state == Menu)
					{					
						WINDOW.Close();		
					}
					else if(state == Ingame)
					{
						state = Paused;
						prevState = Ingame;
					}
					else if(state == Options)
					{
						state = prevState;
						prevState = Options;
					}
					else if(state == Paused)
					{
						state = prevState;
						prevState = Paused;
					}
				}
				if(event.Key.Code == sf::Key::Space)
				{
					for(int i = 0; i < ice.size(); i++)
					{
						if(ice[i]->state != Ice::IceState::Rock)
						{
							ice[i]->state = Ice::IceState::Reg;
						}
					}
				}
				break;
				case sf::Event::MouseButtonReleased:
				if(event.MouseButton.Button == sf::Mouse::Button::Left)
				{
					if(state == Menu)
					{
						if(play.contains(mouse))
						{
							state = Ingame;
						}
						else if(options.contains(mouse))
						{
							state = Options;
							prevState = Menu;
						}
						else if(quit.contains(mouse))
						{
							WINDOW.Close();
						}
					}
					else if(state == Paused)
					{
						if(resume.contains(mouse))
						{
							state = Ingame;
						}
						else if(pauseOptions.contains(mouse))
						{
							state = Options;
//.........这里部分代码省略.........
开发者ID:FoamyPop,项目名称:Arctic,代码行数:101,代码来源:main.cpp


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