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


C++ GameScene::Update方法代码示例

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


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

示例1: WinMain

// プログラムは WinMain から始まります
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	GameScene* mGameScene;		//ゲームシーンの作成 こいつが画面を見ている
	mGameScene = new GameScene;	//インスタンス生成 GameSceneのコンストラクタでタイトルシーンをを入れている
	
	SetGraphMode(640, 480, 16);	//画面の解像度
	ChangeWindowMode(TRUE);
	if (DxLib_Init() == -1)		// DXライブラリ初期化処理
	{
		return -1;			// エラーが起きたら直ちに終了
	}
	// 描画先画面を裏画面にセット
	SetDrawScreen(DX_SCREEN_BACK);
	// ループ
	while (ProcessMessage() == 0 && CheckHitKey(KEY_INPUT_ESCAPE) == 0)
	{
		// 画面を初期化する
		ClearDrawScreen();

		//画面動作処理
		mGameScene->Update();

		//画面描画処理
		mGameScene->Draw();

		// 裏画面の内容を表画面に反映させる
		ScreenFlip();
	}
	DxLib_End();				// DXライブラリ使用の終了処理
	return 0;				// ソフトの終了 
}
开发者ID:saitousann,项目名称:Shooting,代码行数:32,代码来源:Main.cpp

示例2: main


//.........这里部分代码省略.........

		for (auto && entity : loadedLevel->currentEntities) {
			// draw all active entities in the level
			window.draw(entity.Sprite);
		}

		// Show text of talking NPCs
		if (playerQuests->triggerShowText) {

			if (playerQuests->clock.getElapsedTime().asSeconds() < 10)
				window.draw(playerQuests->talkText);

			if (playerQuests->clock.getElapsedTime().asSeconds() > 10)
				playerQuests->triggerShowText = false;
		}

		window.draw(PlayerImage);
		window.draw(playerQuests->currentQuestText);

		for (auto && item : playerInventory->currentItems) {
			// draw all items in the player invneotry
			window.draw(item.itemIconSprite);
		}

		// initiate the final draw call
		window.display();

		// Switch level, if 5 tasks have been accomplished in every map
		if (playerQuests->currentQuestId > 5 && loadedLevelIndex <= 3) {
			delete loadedLevel;
			delete playerQuests;

			loadedLevelIndex++;
			loadedLevel = levels[loadedLevelIndex];
			playerQuests = new Quests(loadedLevel);
			PlayerImage.setPosition(0.0f, 100.0f);
		}

		// Execute the Game Loop in each individual level constantly
		loadedLevel->Update(playerQuests->currentQuestId);

		//Check for left mouse clicks
		if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
		{
			sf::Vector2i localPosition = sf::Mouse::getPosition(window);
			sf::Vector2f worldPos = window.mapPixelToCoords(localPosition);
			// Move player, if cursor is in game world
			if (localPosition.y < 380 && !dragging) {
					Target1.x = worldPos.x - 100;
					Target1.y = worldPos.y - 100;
			}
			// Use item and init dragging, if cursor is in menu (bottom screen part)
			if (localPosition.y > 380 && !dragging) {

				for (auto && item : playerInventory->currentItems) {
					if (localPosition.y < item.itemIconSprite.getPosition().y + item.itemIconSprite.getGlobalBounds().height && localPosition.y   > item.itemIconSprite.getPosition().y && localPosition.x  < item.itemIconSprite.getPosition().x + item.itemIconSprite.getGlobalBounds().width && localPosition.x  > item.itemIconSprite.getPosition().x) {
						item.itemIconSprite.setPosition(localPosition.x - 32, localPosition.y - 32);
						dragging = true;
						draggeditem = &item;

					}

				}

			}


			if (draggeditem) {
				if (dragging) {
					//Set the item position to the mouse cursor position if the user is dragging it
					draggeditem->itemIconSprite.setPosition(localPosition.x - 32, localPosition.y - 32);
				}



			}
			// MOVE TO POINT via CURSOR
			float k = 1;
			// Speed Constant
			float px = PlayerImage.getPosition().x;
			float py = PlayerImage.getPosition().y;
			float ex = Target1.x;
			float ey = Target1.y;

			// "clicked" is used to not allow the player to just drag his charachter across the screen,
			// but instead the player has to confirm each charachter movement by mouse click.

			if (!clicked) {
				PlayerImage.setPosition(Target1.x, Target1.y);
			}

			clicked = true;

		}

	}


	return 0;
}
开发者ID:gotwig,项目名称:DonkeyIsland,代码行数:101,代码来源:main.cpp


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