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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - WaiHak

Pages: [1]
1
System / Re: Why console messages slow time "sf::Clock" ?
« on: November 25, 2013, 07:16:43 pm »
Please you can said me if this is good code?
Clock.h
#ifndef CLOCK_H
#define CLOCK_H

#include <SFML/System.hpp>

class Clock {

public:
        Clock(int);//int mls end

        void Update();
        void Play();
        void Pause();
        void Stop();

        bool isFinish();

        void setTime(int);//int mls end

        sf::Time getTime();
private:
        int Milliseconds;
        sf::Clock Timer;
        sf::Time CurrentTime;
        bool stop;
        bool pause;
};

#endif //CLOCK_H
 
Clock.cpp

#include "Clock.h"

Clock::Clock(int mls)
{
        setTime(mls);
        stop = true;
        pause = true;
}
void Clock::Update()
{
        if (CurrentTime.asMilliseconds() >= Milliseconds)
        {
                stop = true;
        }
        else
        {
                if (pause == false)CurrentTime += Timer.restart();
                else Timer.restart();
        }
}
void Clock::Play()
{
        pause = false;
        stop = false;
}

void Clock::Pause()
{
        pause = true;
}

void Clock::Stop()
{
        stop = true;
        CurrentTime = sf::milliseconds(0);
}

void Clock::setTime(int mls)
{
        Milliseconds = mls;
}

bool Clock::isFinish()
{
        if (CurrentTime.asMilliseconds() >= Milliseconds)return true;
        else return false;
}
sf::Time Clock::getTime()
{
        return CurrentTime;
}
 

2
System / Re: Why console messages slow time "sf::Clock" ?
« on: November 25, 2013, 06:43:59 pm »

Thank you, eXpl0it3r and Nexus

3
System / Re: Why console messages slow time "sf::Clock" ?
« on: November 25, 2013, 06:20:35 pm »
3- Is it better restart () that getElapsed ()?  by what I see it works better
They do different things. You should look at the API documentation before using functions ;)

I do nothing but read this
This function returns the time elapsed since the last call to restart() (or the construction of the instance if restart() has not been called

Now you see this.
loop
        CurrentTime = sf::milliseconds(CurrentTime.asMilliseconds() + Timer.getElapsedTime().asMilliseconds()); // End counting
        Timer.restart();// Start counting
        cout << CurrentTime.asMilliseconds() << endl;
endloop
 
I think I'm understanding you correctly

4
System / Re: Why console messages slow time "sf::Clock" ?
« on: November 25, 2013, 05:32:32 pm »
Not sure if others understand it, but I'm kind of lost in translation.

You might want to write the code like this:
CurrentTime += Timer.restart();
std::cout << CurrentTime.asMilliseconds() << std::endl;
1- Sorry for my translation i know it is bad.

2- Your code is good it works perfect.

3- Is it better restart () that getElapsed ()?  by what I see it works better

Thank You!


5
System / Re: Why console messages slow time "sf::Clock" ?
« on: November 25, 2013, 05:19:54 pm »
Console output is typically very slow, so you can't expect the code to execute at the same speed.
i know it is that but timer is not real?

6
System / Why console messages slow time "sf::Clock" ?
« on: November 25, 2013, 04:49:51 pm »
I have a problem i was testing next code with a timer.
CurrentTime = sf::milliseconds(CurrentTime.asMilliseconds() + Timer.getElapsedTime().asMilliseconds());
Timer.restart();
cout << CurrentTime.asMilliseconds() << endl;
 
With that code the timer was losing much seconds, but with following is not it.
CurrentTime = sf::milliseconds(CurrentTime.asMilliseconds() + Timer.getElapsedTime().asMilliseconds());
        Timer.restart();
 
It should elapse equal?

7
General discussions / Re: Favorite IDE
« on: November 20, 2013, 12:56:11 pm »

1 picture is worth 1000 words

8
General / Re: SFML doesn't want to work...
« on: September 14, 2013, 06:15:55 pm »
Es español como tu -.-  8)

Is spanish like you


Soy español

I am spanish

Try with this : http://en.sfml-dev.org/forums/index.php?topic=12581.msg87885#msg87885

Pages: [1]
anything