Пример #1
0
void SPlayer::renderScene(SDL_Event *event) {
    player_types::key key;
    Status gameStatus;
	
    if (menu) {
	if (menu->handleEvent(event)) {

	    handlePauseEvent(menu->getSelected());
	}

    } else {
	//All Logic hapens here
	Uint8 *keystate = SDL_GetKeyState(NULL);
	if (event && event->type == SDL_KEYDOWN) {
	    for (int i = 0; i < 6; i++) {
		//cast sdl key to own virtual key mapping
		if (keystate[keys[i]]) {
		    key = static_cast<player_types::key> (i);
		    handleKeys(key);
		    break;
		}
	    }
	}
    }

    if (menu)
	game->renderScene(NULL);
    else
	game->renderScene(event);
    gameStatus = game->getStatus();

    if (menu)
	menu->render();
    else
	switch (gameStatus){

	case WIN:
	    Mix_HaltMusic();
	    menu = new MenuWindow(width, height, "You Win!!", NULL);
	    menu->addOption("New Game");
	    menu->addOption("Main Menu");
	    break;

	case LOSS:
	    game->setPaused(true);
	    Mix_HaltMusic();
	    menu  = new MenuWindow(width,height,"GAME OVER",NULL);
	    menu->addOption("New Game");
	    menu->addOption("Main Menu");
	    break;

	default:
	    break;


	}

}
Пример #2
0
void AutoplayUmaHelper::handleEvent(ExecutionContext* executionContext,
                                    Event* event) {
  if (event->type() == EventTypeNames::playing)
    handlePlayingEvent();
  else if (event->type() == EventTypeNames::pause)
    handlePauseEvent();
  else if (event->type() == EventTypeNames::unload)
    handleUnloadEvent();
  else
    NOTREACHED();
}