Times in SFML are now Uint32 milliseconds instead of float seconds
Added the sf::Uint64 and sf::Int64 types
This commit is contained in:
parent
c1ce16f4d6
commit
e4c6c30e0b
83 changed files with 250 additions and 262 deletions
|
@ -97,9 +97,9 @@ int main()
|
|||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(x, y, -100.f);
|
||||
glRotatef(clock.GetElapsedTime() * 50, 1.f, 0.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime() * 30, 0.f, 1.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime() * 90, 0.f, 0.f, 1.f);
|
||||
glRotatef(clock.GetElapsedTime() * 0.05f, 1.f, 0.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime() * 0.03f, 0.f, 1.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime() * 0.09f, 0.f, 0.f, 1.f);
|
||||
|
||||
// Draw a cube
|
||||
float size = 20.f;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
int main()
|
||||
{
|
||||
std::srand(std::time(NULL));
|
||||
std::srand(static_cast<unsigned int>(std::time(NULL)));
|
||||
|
||||
// Defines PI
|
||||
const float PI = 3.14159f;
|
||||
|
@ -100,15 +100,15 @@ int main()
|
|||
{
|
||||
// Move the player's paddle
|
||||
if (window.GetInput().IsKeyDown(sf::Key::Up) && (leftPaddle.GetPosition().y > 5.f))
|
||||
leftPaddle.Move(0.f, -leftPaddleSpeed * window.GetFrameTime());
|
||||
leftPaddle.Move(0.f, -leftPaddleSpeed * window.GetFrameTime() / 1000.f);
|
||||
if (window.GetInput().IsKeyDown(sf::Key::Down) && (leftPaddle.GetPosition().y < window.GetView().GetSize().y - leftPaddle.GetSize().y - 5.f))
|
||||
leftPaddle.Move(0.f, leftPaddleSpeed * window.GetFrameTime());
|
||||
leftPaddle.Move(0.f, leftPaddleSpeed * window.GetFrameTime() / 1000.f);
|
||||
|
||||
// Move the computer's paddle
|
||||
if (((rightPaddleSpeed < 0.f) && (rightPaddle.GetPosition().y > 5.f)) ||
|
||||
((rightPaddleSpeed > 0.f) && (rightPaddle.GetPosition().y < window.GetView().GetSize().y - rightPaddle.GetSize().y - 5.f)))
|
||||
{
|
||||
rightPaddle.Move(0.f, rightPaddleSpeed * window.GetFrameTime());
|
||||
rightPaddle.Move(0.f, rightPaddleSpeed * window.GetFrameTime() / 1000.f);
|
||||
}
|
||||
|
||||
// Update the computer's paddle direction according to the ball position
|
||||
|
@ -122,7 +122,7 @@ int main()
|
|||
}
|
||||
|
||||
// Move the ball
|
||||
float factor = ballSpeed * window.GetFrameTime();
|
||||
float factor = ballSpeed * window.GetFrameTime() / 1000.f;
|
||||
ball.Move(std::cos(ballAngle) * factor, std::sin(ballAngle) * factor);
|
||||
|
||||
// Check collisions between the ball and the screen
|
||||
|
|
|
@ -214,10 +214,10 @@ test.Create(800, 600);
|
|||
globalShader.Update(mouseX, mouseY);
|
||||
|
||||
// Animate the entity
|
||||
float entityX = (cos(clock.GetElapsedTime() * 1.3f) + 1.2f) * 300;
|
||||
float entityY = (cos(clock.GetElapsedTime() * 0.8f) + 1.2f) * 200;
|
||||
float entityX = (cos(clock.GetElapsedTime() * 0.0013f) + 1.2f) * 300;
|
||||
float entityY = (cos(clock.GetElapsedTime() * 0.0008f) + 1.2f) * 200;
|
||||
entity.SetPosition(entityX, entityY);
|
||||
entity.Rotate(window.GetFrameTime() * 100);
|
||||
entity.Rotate(window.GetFrameTime() * 0.1f);
|
||||
|
||||
// Draw the background and the moving entity to the render image
|
||||
image.Clear();
|
||||
|
|
|
@ -20,9 +20,9 @@ void PlaySound()
|
|||
|
||||
// Display sound informations
|
||||
std::cout << "canary.wav :" << std::endl;
|
||||
std::cout << " " << buffer.GetDuration() << " sec" << std::endl;
|
||||
std::cout << " " << buffer.GetSampleRate() << " samples / sec" << std::endl;
|
||||
std::cout << " " << buffer.GetChannelsCount() << " channels" << std::endl;
|
||||
std::cout << " " << buffer.GetDuration() / 1000.f << " seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetSampleRate() << " samples / sec" << std::endl;
|
||||
std::cout << " " << buffer.GetChannelsCount() << " channels" << std::endl;
|
||||
|
||||
// Create a sound instance and play it
|
||||
sf::Sound sound(buffer);
|
||||
|
@ -32,7 +32,7 @@ void PlaySound()
|
|||
while (sound.GetStatus() == sf::Sound::Playing)
|
||||
{
|
||||
// Leave some CPU time for other processes
|
||||
sf::Sleep(0.1f);
|
||||
sf::Sleep(100);
|
||||
|
||||
// Display the playing position
|
||||
std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << sound.GetPlayingOffset() << " sec ";
|
||||
|
@ -54,9 +54,9 @@ void PlayMusic()
|
|||
|
||||
// Display music informations
|
||||
std::cout << "orchestral.ogg :" << std::endl;
|
||||
std::cout << " " << music.GetDuration() << " sec" << std::endl;
|
||||
std::cout << " " << music.GetSampleRate() << " samples / sec" << std::endl;
|
||||
std::cout << " " << music.GetChannelsCount() << " channels" << std::endl;
|
||||
std::cout << " " << music.GetDuration() / 1000.f << " seconds" << std::endl;
|
||||
std::cout << " " << music.GetSampleRate() << " samples / sec" << std::endl;
|
||||
std::cout << " " << music.GetChannelsCount() << " channels" << std::endl;
|
||||
|
||||
// Play it
|
||||
music.Play();
|
||||
|
@ -65,7 +65,7 @@ void PlayMusic()
|
|||
while (music.GetStatus() == sf::Music::Playing)
|
||||
{
|
||||
// Leave some CPU time for other processes
|
||||
sf::Sleep(0.1f);
|
||||
sf::Sleep(100);
|
||||
|
||||
// Display the playing position
|
||||
std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << music.GetPlayingOffset() << " sec ";
|
||||
|
|
|
@ -46,9 +46,9 @@ int main()
|
|||
|
||||
// Display captured sound informations
|
||||
std::cout << "Sound information :" << std::endl;
|
||||
std::cout << " " << buffer.GetDuration() << " seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetSampleRate() << " samples / seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetChannelsCount() << " channels" << std::endl;
|
||||
std::cout << " " << buffer.GetDuration() / 1000.f << " seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetSampleRate() << " samples / seconds" << std::endl;
|
||||
std::cout << " " << buffer.GetChannelsCount() << " channels" << std::endl;
|
||||
|
||||
// Choose what to do with the recorded sound data
|
||||
char choice;
|
||||
|
@ -79,7 +79,7 @@ int main()
|
|||
std::cout << "\rPlaying... " << std::fixed << std::setprecision(2) << sound.GetPlayingOffset() << " sec";
|
||||
|
||||
// Leave some CPU time for other threads
|
||||
sf::Sleep(0.1f);
|
||||
sf::Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ private :
|
|||
|
||||
// No new data has arrived since last update : wait until we get some
|
||||
while ((myOffset >= mySamples.size()) && !myHasFinished)
|
||||
sf::Sleep(0.01f);
|
||||
sf::Sleep(10);
|
||||
|
||||
// Copy samples into a local buffer to avoid synchronization problems
|
||||
// (don't forget that we run in two separate threads)
|
||||
|
@ -101,9 +101,9 @@ private :
|
|||
/// /see SoundStream::OnSeek
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
virtual void OnSeek(float timeOffset)
|
||||
virtual void OnSeek(sf::Uint32 timeOffset)
|
||||
{
|
||||
myOffset = static_cast<std::size_t>(timeOffset * GetSampleRate() * GetChannelsCount());
|
||||
myOffset = timeOffset * GetSampleRate() * GetChannelsCount() / 1000;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -179,7 +179,7 @@ void DoServer(unsigned short port)
|
|||
while (audioStream.GetStatus() != sf::SoundStream::Stopped)
|
||||
{
|
||||
// Leave some CPU time for other threads
|
||||
sf::Sleep(0.1f);
|
||||
sf::Sleep(100);
|
||||
}
|
||||
|
||||
std::cin.ignore(10000, '\n');
|
||||
|
@ -195,6 +195,6 @@ void DoServer(unsigned short port)
|
|||
while (audioStream.GetStatus() != sf::SoundStream::Stopped)
|
||||
{
|
||||
// Leave some CPU time for other threads
|
||||
sf::Sleep(0.1f);
|
||||
sf::Sleep(100);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,11 +105,11 @@ INT WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, INT)
|
|||
SFMLView2.Clear();
|
||||
|
||||
// Draw sprite 1 on view 1
|
||||
sprite1.SetRotation(clock.GetElapsedTime() * 100);
|
||||
sprite1.SetRotation(clock.GetElapsedTime() * 0.1f);
|
||||
SFMLView1.Draw(sprite1);
|
||||
|
||||
// Draw sprite 2 on view 2
|
||||
sprite2.SetX(cos(clock.GetElapsedTime()) * 100);
|
||||
sprite2.SetX(cos(clock.GetElapsedTime() * 0.001f) * 100.f);
|
||||
SFMLView2.Draw(sprite2);
|
||||
|
||||
// Display each view on screen
|
||||
|
|
|
@ -65,9 +65,9 @@ int main()
|
|||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.f, 0.f, -200.f);
|
||||
glRotatef(clock.GetElapsedTime() * 50, 1.f, 0.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime() * 30, 0.f, 1.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime() * 90, 0.f, 0.f, 1.f);
|
||||
glRotatef(clock.GetElapsedTime() * 0.05f, 1.f, 0.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime() * 0.03f, 0.f, 1.f, 0.f);
|
||||
glRotatef(clock.GetElapsedTime() * 0.09f, 0.f, 0.f, 1.f);
|
||||
|
||||
// Draw a cube
|
||||
glBegin(GL_QUADS);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue