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


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

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


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

示例1: starfield

Level::Level( int which ) {
	Starfield starfield( 350 );
	Hud hud;
	Timer *timer = Timer::Instance();
	Video *video = Video::Instance();
	SpriteList *spriteList = SpriteList::Instance();
	Ship *player = new Ship(); // the player sprite
	bool quit = false;
	SDL_Event event;

	camera = Camera::Instance();

	camera->Follow( player );

	player->UseAI( false );
	player->IsPlayer( true );

	player->SetThrust( 5. );
	
	// add player
	spriteList->Add( player );

	Ship *test = new Ship( 15, 15 );
	
	spriteList->Add( test );

	if( SDL_Init( SDL_INIT_JOYSTICK ) != 0 )
		cout << "massive joystick error" << endl; // move to an input class

	timer->Reset();
	
	hud.Message( HUD_MSG_COMMAND, "Good morning, pilot." );
	
	while( !quit ) {
		// erase
		video->Blank();

		// update
		// get user input
		while( SDL_PollEvent( &event ) ) {
			switch( event.type ) {
				case SDL_QUIT:
					quit = true;
					break;
				case SDL_JOYAXISMOTION:
					cout << "joystick motion!" << endl;
					if(event.jaxis.which == 0)
						player->Turn( (float)-20 * 0.15f );
					break;
				case SDL_KEYDOWN:
					switch( event.key.keysym.sym ) {
						case SDLK_ESCAPE:
							quit = true;
							break;
						case SDLK_w:
							player->ThrottleUp();
							break;
						case SDLK_s:
							player->ThrottleDown();
							break;
						default:
							break;
					}
					break;
				case SDL_MOUSEMOTION:
					if(( event.motion.xrel ) && ( event.motion.xrel != 160 )) {
						if( abs(event.motion.xrel) > 20 )
							if(event.motion.xrel < 0)
								player->Turn( (float)-20 * 0.15f );
							else
								player->Turn( (float)20 * 0.15f );
						else
							player->Turn( (float)event.motion.xrel * 0.15f );
					}
					break;
				case SDL_MOUSEBUTTONDOWN:
					if( event.button.button == 1) player->Fire();
					if( event.button.button == 4) player->ThrottleUp();
					if( event.button.button == 5) player->ThrottleDown();
					break;
				default:
					break;
			}
		}

		for( int n = timer->GetLoops(); n ; --n ) {
			// update various systems
			camera->Update();
			starfield.Update();
			spriteList->Update();
			hud.Update();
		}

		// draw
		starfield.Draw();
		spriteList->Draw();
		hud.Draw();

		video->Update();

//.........这里部分代码省略.........
开发者ID:cthielen,项目名称:epsilonfighter,代码行数:101,代码来源:level.cpp

示例2: Update

void DialogCharacter::Update(int delta, string &emotionId, bool finishOneTimeEmotions, bool isInBackground)
{
    if (emotionId.length() == 0)
    {
        emotionId = defaultEmotionId;
    }

    if (characterOneTimeEmotions.count(emotionId) > 0)
    {
        OneTimeEmotion *pOneTimeEmotion = characterOneTimeEmotions[emotionId];

        Video *pVideo = pOneTimeEmotion->GetVideo();

        if (finishOneTimeEmotions)
        {
            pVideo->Finish();
        }
        else
        {
            pVideo->Update(delta);
        }

        if (pVideo->IsFinished() && pOneTimeEmotion->GetTransitionToEmotion().length() > 0)
        {
            pVideo->Reset();
            emotionId = pOneTimeEmotion->GetTransitionToEmotion();
        }
        else
        {
            return;
        }
    }

    vector<Animation *> *pForegroundLayers = GetForegroundLayersForEmotion(emotionId);

    if (pForegroundLayers != NULL)
    {
        for (unsigned int i = 0; i < pForegroundLayers->size(); i++)
        {
            Animation *pAnimation = (*pForegroundLayers)[i];
            pAnimation->Update(delta);
        }
    }

    // If this emotion is currently in the background (e.g., if the character is currently zoomed),
    // then we won't bother updating the eye frame duration list.
    if (isInBackground || characterEmotionEyeSpriteIds.count(emotionId) == 0)
    {
        return;
    }

    if (eyeFrameDurationList.size() == 0 || eyeFrameDurationList.size() != characterEmotionEyeSpriteIds[emotionId].size())
    {
        PopulateEyeFrameDurationList(emotionId);
    }

    msElapsedCurrentEyeFrame += delta;

    while (msElapsedCurrentEyeFrame > eyeFrameDurationList[currentEyeFrame])
    {
        msElapsedCurrentEyeFrame -= eyeFrameDurationList[currentEyeFrame];
        currentEyeFrame++;

        // If we've reached the end, then we'll wrap back around and get a
        // new random number representing the time until the next eye blink.
        if (currentEyeFrame >= eyeFrameDurationList.size())
        {
            currentEyeFrame = 0;
            eyeFrameDurationList[0] = (int)(rand() % 2001) + 2000;
        }
    }
}
开发者ID:GabuEx,项目名称:my-little-investigations,代码行数:72,代码来源:DialogCharacterManager.cpp


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