Hello
I'm trying to make a counter from 0 to 170 and then from 170 to 0. I got it working but its counting very fast. Is there a way to slow the counting down a bit.
I tried to use Clock.GetTime(); but the problem is that the clock count from 0 to 170 for example but i want it to also count backwords from 170 to 0.
here what i got
#include <SFML\Graphics.hpp>
#include <iostream>
int main()
{
sf::RenderWindow Window(sf::VideoMode(800, 632, 32), "Tower Defence");
sf::Image Image;
sf::Sprite Sprite;
Image.LoadFromFile("light.png");
Sprite.SetImage(Image);
Sprite.SetPosition(0, 32);
Sprite.SetColor(sf::Color(14,25,52));
sf::Clock Clock;
int Time = 0;
bool up = true;
while(Window.IsOpened())
{
sf::Event Event;
Window.SetFramerateLimit(150);
Window.UseVerticalSync(true);
while (Window.GetEvent(Event))
{
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
Window.Close();
}
if( up )
{
++Time;
}
else
{
--Time;
}
if( Time >= 170 )
up = false;
if( Time <= 0 )
up = true;
Sprite.SetColor(sf::Color(15,10,63, Time));
std::cout<<Time<<"\n";
Window.Clear();
Window.Draw(Sprite);
Window.Display();
}
return 0;
}
[quote][/quote]