Updated examples

It is now possible to pause the animation in AnimatedMesh demo with the
P key


Former-commit-id: 98d1b5196007dd524e2257157d6e7fd3171fb070
This commit is contained in:
Lynix 2012-10-04 09:36:56 +02:00
parent 41bfaf6941
commit defbb0f1a6
2 changed files with 13 additions and 7 deletions

View File

@ -247,6 +247,7 @@ int main()
// Quelques variables
bool camMode = true;
bool paused = false;
bool thirdPerson = false;
bool windowOpen = true;
@ -338,6 +339,8 @@ int main()
}
else if (event.key.code == NzKeyboard::Escape)
windowOpen = false;
else if (event.key.code == NzKeyboard::P)
paused = !paused;
break;
@ -433,7 +436,9 @@ int main()
drfreak.matrix = NzMatrix4f::Rotate(modelOrient) * NzMatrix4f::Translate(modelPos);
// Animation
AnimateModel(drfreak, elapsedTime);
if (!paused)
AnimateModel(drfreak, elapsedTime);
updateClock.Restart();
}

View File

@ -1,12 +1,13 @@
#include <Nazara/Audio.hpp>
#include <Nazara/Core/Clock.hpp>
#include <Nazara/Core/Thread.hpp> // Thread::Sleep
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Utility/Keyboard.hpp>
#include <iostream>
int main()
{
// NzKeyboard ne nécessite pas l'initialisation d'Utility
// NzKeyboard ne nécessite pas l'initialisation du module Utilitaire
NzInitializer<NzAudio> audio;
if (!audio)
{
@ -32,11 +33,11 @@ int main()
// On fait en sorte de répéter le son
sound.EnableLooping(true);
// La source du son se situe en (50, 0, 5)
sound.SetPosition(50, 0, 5);
// La source du son se situe vers la gauche (Et un peu en avant)
sound.SetPosition(NzVector3f::Left()*50.f + NzVector3f::Forward()*5.);
// Et possède une vitesse de -10 par seconde sur l'axe X
sound.SetVelocity(-10, 0, 0);
// Et possède une vitesse de 10 par seconde vers la droite
sound.SetVelocity(NzVector3f::Left()*-10.f);
// On joue le son
sound.Play();
@ -58,7 +59,7 @@ int main()
std::cout << "Sound position: " << pos << std::endl;
// Si la position de la source atteint une certaine position, ou si l'utilisateur appuie sur echap
if (pos.x < -50.f || NzKeyboard::IsKeyPressed(NzKeyboard::Escape))
if (pos.x > NzVector3f::Left().x*-50.f || NzKeyboard::IsKeyPressed(NzKeyboard::Escape))
sound.Stop(); // On arrête le son (Stoppant également la boucle)
clock.Restart();