Esempio n. 1
0
BaseGameLogic *CometConquestGameApp::VCreateGameAndView()
{
	BaseGameLogic *game = NULL;
	assert(m_pOptions && _T("The game options object is uninitialized."));

	// Register any game-specific events here.
	RegisterGameSpecificEvents();
	// Need to know if you are client or server before this point?
	if (m_pOptions->m_gameHost.empty())
	{
		game = GCC_NEW CometConquestGame(*m_pOptions);
	}
	else
	{
		game = GCC_NEW CometConquestGame(*m_pOptions);

		//EventListenerPtr listener ( GCC_NEW NetworkEventForwarder( 0 ) );
		//extern void ListenForCometConquestGameCommands(EventListenerPtr listener);
		//ListenForCometConquestGameCommands(listener);

	}

	shared_ptr<IGameView> menuView(GCC_NEW MainMenuView());
	game->VAddView(menuView);

	return game;
}
Esempio n. 2
0
BaseGameLogic* NWNCloneApp::VCreateGameAndView()
{
	m_pGame = GCC_NEW NWNCloneLogic();
	shared_ptr<IGameView> menuView(GCC_NEW MainMenuView());
	m_pGame->VAddView(menuView);
	return m_pGame;
}
Esempio n. 3
0
// on "init" you need to initialize your instance
bool OptionScene::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
	// 화면 사이즈
	SizeW = Director::getInstance()->getWinSize().width;
	SizeH = Director::getInstance()->getWinSize().height;

	iMusic = SimpleAudioEngine::getInstance()->isBackgroundMusicPlaying();

	// 메뉴 배경화면 초기화
	initBackGround();

	// 메뉴 초기화
	initMenu();

	// 라벨 초기화
	initLabel();


	menuView();

    return true;
}
Esempio n. 4
0
//
// TeapotWarsApp::VCreateGameAndView
//
BaseGameLogic *TeapotWarsApp::VCreateGameAndView()
{
	m_pGame = GCC_NEW TeapotWarsLogic();
    m_pGame->Init();

	shared_ptr<IGameView> menuView(GCC_NEW MainMenuView());
	m_pGame->VAddView(menuView);

	return m_pGame;
}
Esempio n. 5
0
BaseGameLogic * Game::VCreateGameAndView()
{
	m_pGame = TYW_NEW GameLogic;
	m_pGame->Init();

	std::shared_ptr<IGameView> menuView(TYW_NEW MainView(g_pRendGL));
	m_pGame->VAddView(menuView);

	return m_pGame;
}
Esempio n. 6
0
//This function checks for errors, and prints them to the screen if any exist.
//Otherwise, it checks for button presses, shows the menu or autonomous stats.
void processLCD()
	{
	static bool errorDismissed=false;
	if (sysError!=ERR_NONE && errorDismissed==false)
		{
		sysLCDBacklight=LCD_BLINK_SLOW;
		switch(sysError)
			{
			case ERR_LOW_CORTEX:
				topLCDLine.curr =    "ERROR--Low";
				bottomLCDLine.curr = "Cortex Battery";
				break;
			case ERR_LOW_POW_EX:
				topLCDLine.curr =    "ERROR--Low Power";
				bottomLCDLine.curr = "Expander Battery";
				break;
			case ERR_ROBOT_IDLE:
				topLCDLine.curr =    "3018  Techna PWN";
				bottomLCDLine.curr = " Robotics  Nora ";
				break;
			}
		if (screenButtonIsPressed()) //Never tested this
			errorDismissed = true;
		}
	else
		{
		if (sysState.curr == DISABLED || sysState.curr == OPERATOR) //Show the menu
			{
			sysLCDBacklight=LCD_ALWAYS_ON;

			if (pressed(btnScreenLeft))		menuItemIndex--;
			if (pressed(btnScreenRight))	menuItemIndex++;
#ifdef MENU_WRAP //ITEM = (ITEM + NUM) % NUM
			menuItemIndex = (menuItemIndex + (NO_MENU_ITEMS)) % (NO_MENU_ITEMS); //Wrap (not tested)
#else
			menuItemIndex = (T_MENU_ITEMS)capIntValue(0, menuItemIndex, M_NO_ITEMS-1); //Don't wrap
#endif
			if (pressed(btnScreenCenter))	menuItemActivated = !menuItemActivated;
			if (menuItemActivated)			menuExecuteActivated();

			menuView();
			}
		else if (sysState.curr == AUTONOMOUS)
			{
			if (btnScreenLeft.curr || btnScreenRight.curr)
				sysAutoMode = false; //Only works when competition switch is unplugged (see State.c)

			sysLCDBacklight=LCD_ALWAYS_ON;
			StringFormat(topLCDLine.curr,"%2d:%8.1f sec ", autoRoutine.curr, ((float)timerAuto/100));
			StringFormat(bottomLCDLine.curr, "Step: %d", autoStep);	//Show step
			}
		}
	}
Esempio n. 7
0
/*------------------------------------------------------------------------------------
| 함 수 명  : menuCallback(Ref *sender)
| 매개변수  : sender = 메뉴 터치 시 넘어오는 값.
| 리 턴 값  :
| 설    명  : 메뉴 터치 시 화면 전환.
|------------------------------------------------------------------------------------*/
void OptionScene::menuCallback(Ref *sender)
{
	auto menu = (MenuItem*)sender;

	switch (menu->getTag())
	{
		// Back
		case TAG_DATA_MENU_BACK:
		{
			if (iEffect == true) SimpleAudioEngine::getInstance()->playEffect("menu/button.mp3");

			auto scene = TransitionFadeTR::create(1.0, MenuScene::createScene());
			Director::getInstance()->replaceScene(scene);
			break;
		}

		case TAG_OPTION_MENU_MUSIC:
		{
			iMusic = !iMusic;
			if (iMusic == true)
			{
				SimpleAudioEngine::getInstance()->playBackgroundMusic("menu/Darker_Thoughts.mp3", true);
			}
			else
			{
				SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
			}
			menuView();
			break;
		}

		case TAG_OPTION_MENU_EFFECT:
		{
			iEffect = !iEffect;

	/*		if (iEffect == true)
			{
				SimpleAudioEngine::getInstance()->resumeAllEffects();
			}
			else
			{
			//	SimpleAudioEngine::getInstance()->stopAllEffects();
				SimpleAudioEngine::getInstance()->resumeAllEffects();
			}*/
				
			menuView();
			break;
		}

		case TAG_OPTION_MENU_DELETE:
		{
			 FNDB.deleteDatabase();
			 break;
		}

		default:
			break;
			
	}

	
}
Esempio n. 8
0
	void GameController::gameLoop() {
		wParams.mFullscreen = false;
		wParams.mHeight = screenHeight;
		wParams.mWidth = screenWidth;
		wParams.mTitle = "Project";
		wParams.mPosX = 0;
		wParams.mPosY = 0;

		if (common.init(wParams)) {

			//Load all textures	
			common.registerSoundResource("soundExplosion", "sound/explosion.ogg");
			common.registerSoundResource("soundShoot", "sound/fire.ogg");

			common.registerTextureResource("shoot", "image/spark.png");
			common.registerTextureResource("plane", "image/plane.png");
			common.registerTextureResource("explosion", "image/explosion.png");

			common.registerTextureResource("asteroid1", "image/asteroid1.png");
			common.registerTextureResource("asteroid2", "image/asteroid2.png");
			common.registerTextureResource("asteroid3", "image/asteroid3.png");
			common.registerTextureResource("asteroid4", "image/asteroid4.png");
			common.registerTextureResource("asteroid5", "image/asteroid5.png");
			common.registerTextureResource("asteroid6", "image/asteroid6.png");
			common.registerTextureResource("background_menu", "image/space_background_menu.png");
			common.registerTextureResource("background_after_game", "image/space_background_after_game.png");
			common.registerTextureResource("health_package", "image/health_package.png");

			common.registerFontResource("sans16", 16, "fonts/ARIAL.ttf");
			common.registerFontResource("sans20", 20, "fonts/OpenSans-Regular.ttf");
			common.registerFontResource("lobsterBold", 30, "fonts/LobsterTWo-Bold.otf");

			EventManager em;
			common.setEventProcessor(&em);

			Graphics *g = common.getGraphics();

			g->setViewport(0, 0, screenWidth, screenHeight);

			HiResTimer timer;
			timer.restart();

			SetAsteroidType(currentLvl);

			Model::MenuModel menuModel;
			View::MenuView menuView(&common, &menuModel);
			menuModel.AddView(&menuView);

			int height, width;
			common.getGraphics()->getContextSize(&width, &height);
			menuModel.Init(Vec2(width, height));

			Model::ManagerModel *managerModel = DBG_NEW Model::ManagerModel;
			View::ManagerView *managerView = DBG_NEW View::ManagerView(&common, managerModel);
			managerModel->AddView(managerView);

			common.getGraphics()->getContextSize(&width, &height);
			managerModel->Init(Vec2(width, height), GetAsteroidType().typ1, GetAsteroidType().type2, maxScore, currentLvl);

			currentState = GAMESTATE_INMENU;

			while (gRunning) {

				timer.tick();

				// Process OS events.
				common.frame();

				if (timerEsc <= 0) {
					timerEsc = 0;
				} else {
					timerEsc -= timer.getDeltaSeconds();
				}

				InputState input;
				common.getInputState(&input);
				if (input.isDown(Button::BUTTON_ESCAPE)) {
					if (timerEsc <= 0) {
						if (currentState == GAMESTATE_INGAME) {
							currentState = GAMESTATE_INMENU;
						} else {
							currentState = GAMESTATE_INGAME;
						}
						timerEsc = coolDownEsc;
					}
				}

				if (managerModel->WonRound() || managerModel->LostRound()) {
					if (timerResultScreen <= 0) {
						timerResultScreen = 0;
					} else {
						timerResultScreen -= timer.getDeltaSeconds();
					}

					if (managerModel->LostRound()) {
						menuModel.ShowLostRound();
						currentState = GAMESTATE_AFTER_GAME;
						timerDelayScreenForExplosion = timeElapsedForExplosion;
					} else {
						if (currentLvl >= 2) {
							menuModel.ShowWonGame();
							currentState = GAMESTATE_AFTER_GAME;
						} else {
							menuModel.ShowWonRound();
							currentState = GAMESTATE_AFTER_GAME;
						}
					}

					if (timerResultScreen == 0) {
						timerResultScreen = timeElapseResultScreen;

						if (currentLvl >= 2) {
							currentState = GAMESTATE_INMENU;
						} else {
							currentState = GAMESTATE_INGAME; //Start new game.
						}

						if (managerModel->WonRound()) {
							++currentLvl;
							SetAsteroidType(currentLvl);
						}

						delete managerModel;
						delete managerView;

						managerModel = NULL;
						managerView = NULL;

						managerModel = DBG_NEW Model::ManagerModel;
						managerView = DBG_NEW View::ManagerView(&common, managerModel);
						managerModel->AddView(managerView);

						common.getGraphics()->getContextSize(&width, &height);
						managerModel->Init(Vec2(width, height), GetAsteroidType().typ1, GetAsteroidType().type2, maxScore, currentLvl);
					}
				}

				if (currentState == GAMESTATE_INMENU) {
					//ShowCursor(TRUE);

					menuModel.OnUpdate(timer.getDeltaSeconds(), isGameStarted);
					menuView.OnUpdate(timer.getDeltaSeconds());
					if (menuModel.IsPaused() && isGameStarted) {
						currentState = GAMESTATE_INGAME;
					} else if (menuModel.IsNewGame()) {
						currentState = GAMESTATE_INGAME;
						currentLvl = 0;
						SetAsteroidType(currentLvl);

						delete managerModel;
						delete managerView;

						managerModel = NULL;
						managerView = NULL;

						managerModel = DBG_NEW Model::ManagerModel;
						managerView = DBG_NEW View::ManagerView(&common, managerModel);
						managerModel->AddView(managerView);

						common.getGraphics()->getContextSize(&width, &height);
						managerModel->Init(Vec2(width, height), GetAsteroidType().typ1, GetAsteroidType().type2, maxScore, currentLvl);
					}

					g->clear(Color::Black, true);

					menuView.OnRenderMenu();

				} else if (currentState == GAMESTATE_INGAME) {
					isGameStarted = true;

					//ShowCursor(FALSE);

					managerModel->OnUpdate(timer.getDeltaSeconds());
					managerView->OnUpdate(timer.getDeltaSeconds());

					g->clear(Color::Black, true);

					managerView->OnRender();

				} else if (currentState == GAMESTATE_AFTER_GAME) {
					timerDelayScreenForExplosion -= timer.getDeltaSeconds();
					if (timerDelayScreenForExplosion <= 0) {
						
						menuModel.OnUpdate(timer.getDeltaSeconds(), isGameStarted);
						menuView.OnUpdate(timer.getDeltaSeconds());

						g->clear(Color::Black, true);

						menuView.OnRenderAfterGame();

					} else if (timerResultScreen > 0) {
						menuModel.OnUpdate(timer.getDeltaSeconds(), isGameStarted);
						menuView.OnUpdate(timer.getDeltaSeconds());

						g->clear(Color::Black, true);

						menuView.OnRenderAfterGame();

					} else {
						managerModel->OnUpdate(timer.getDeltaSeconds());
						managerView->OnUpdate(timer.getDeltaSeconds());

						g->clear(Color::Black, true);

						managerView->OnRender();
					}
				}
				g->present();
			}
		}
	}