Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: My Time is broken  (Read 3647 times)

0 Members and 1 Guest are viewing this topic.

Halsys

  • Jr. Member
  • **
  • Posts: 66
  • Halsys like Hal.sys
    • View Profile
    • Email
My Time is broken
« on: November 28, 2012, 04:27:47 am »
*Sigh*.... Alright I want to keep a certain thing to keep drawing for 3 seconds & have my player move on a delta, but! When I try to do all this it ignores time itself. So when I try to do a std::cout to see whats going on, it tells me 3e-006 or some other number and never changes.


I got 2 scenarios here trying to show the time as a example and it does the same thing for me:
it will display on the console like: 3e-006 3e-006

#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <iostream>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Keyboad Events");
    window.setFramerateLimit(60);
    sf::Clock Clock;
    sf::Time Time = Clock.getElapsedTime();

    while(window.isOpen())
    {
        sf::Event event;
        while(window.pollEvent(event))
        {
            float time = Time.asSeconds();
            std::cout << Time.asSeconds() << " "<< time << std::endl;
            if(event.type == sf::Event::Closed)
                window.close();

        }

        window.clear();
        window.display();
    }
}
 

Some major help is required here...
« Last Edit: November 28, 2012, 07:54:13 am by Laurent »
If you notice I put "....", in my sentences way too much... I'm sorry.

cf

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: My Time is broken
« Reply #1 on: November 28, 2012, 05:03:38 am »
sf::Time just represents a given time-value, in your case the time as returned by Clock.getElapsedTime() before the while-loop. Try printing Clock.getElapsedTime(); inside the loop to see the current time incrementing.

Halsys

  • Jr. Member
  • **
  • Posts: 66
  • Halsys like Hal.sys
    • View Profile
    • Email
Re: My Time is broken
« Reply #2 on: November 28, 2012, 05:08:07 am »
*Head Desk*
Thank YOU! :D
For some reason I thought it would remember I like my sandwiches(Time) like that but I guess not.
Other than that,Thank you!
If you notice I put "....", in my sentences way too much... I'm sorry.

 

anything