I want to make efect like in WOW. When skill is not ready he has a black rect. Rect is disappears like clock. From 12:00 to 12:15 to 12:30, to 12:45, 12:00, but smoothly. I have something like this:
#include <iostream>
#include <conio.h>
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow oknoAplikacji( sf::VideoMode( 800, 600, 32 ), "Craftsman" );
// Left top point in rect
float x1 = 150;
float y1 = 50;
// Right down point in rect
float x2 = 650;
float y2 = 550;
// Coords of moving point
float ax = (x1+x2)/2;
float ay = y1;
// stopien - size of move for moving point
int stopien = 10;
// time - time from break to next step
int time = 0;
// how meny point will not draw
int point=0;
while(1)
{
oknoAplikacji.Clear( sf::Color( 255, 0, 0 ) );
sf::Shape Polygon;
Polygon.SetColor(sf::Color(0,0,0,100));
// When my moving point (ax, ay) is in one of nine points
// that point must be deletet (or not draw)
if (ax == x2 && ay == y1)
point = 1;
else if (ax == x2 && ay == (y1+y2)/2)
point = 2;
else if (ax == x2 && ay == y2)
point = 3;
else if (ax == (x1+x2)/2 && ay == y2)
point = 4;
else if (ax == x1 && ay == y2)
point = 5;
else if (ax == x1 && ay == (y1+y2)/2)
point = 6;
else if (ax == x1 && ay == y1)
point = 7;
else if (ax == (x1+x2)/2 && ay == y1 && point == 7)
{
// starts from begin
ax = (x1+x2)/2;
ay = y1;
point = 0;
}
// behavior of moving point (when go left, when down etc.)
if (time >= 5)
{
if (point == 0)
{
ax+=stopien;
if (ax > x2)
ax = x2;
}
else if (point == 1)
{
ay+=stopien;
if (ay > (y2+y1)/2)
ay = (y2+y1)/2;
}
else if (point == 2)
{
ay+=stopien;
if (ay > y2)
ay = y2;
}
else if (point == 3)
{
ax-=stopien;
if (ax < (x2+x1)/2)
ax = (x2+x1)/2;
}
else if (point == 4)
{
ax-=stopien;
if (ax < x1)
ax = x1;
}
else if (point == 5)
{
ay-=stopien;
if (ay < (y2+y1)/2)
ay = (y2+y1)/2;
}
else if (point == 6)
{
ay-=stopien;
if (ay < y1)
ay = y1;
}
else if (point == 7)
{
ax+=stopien;
if (ax > (x2+x1)/2)
ax = (x2+x1)/2;
}
time = 0;
}
// Points of my Polygon
// my movin point to...
Polygon.AddPoint(ax,ay, sf::Color(0,0,0));
// ...next pionts (if exists)
if ( point <= 0 )
Polygon.AddPoint(x2,y1, sf::Color(0,0,0));
if ( point <= 1 )
Polygon.AddPoint(x2,(y1+y2)/2, sf::Color(0,0,0));
if ( point <= 2 )
Polygon.AddPoint(x2,y2, sf::Color(0,0,0));
if ( point <= 3 )
Polygon.AddPoint((x1+x2)/2,y2, sf::Color(0,0,0));
if ( point <= 4 )
Polygon.AddPoint(x1,y2, sf::Color(0,0,0));
if ( point <= 5 )
Polygon.AddPoint(x1,(y1+y2)/2, sf::Color(0,0,0));
if ( point <= 6 )
Polygon.AddPoint(x1,y1, sf::Color(0,0,0));
// always being, middle top point (we start from this point, and end hear)
Polygon.AddPoint((x1+x2)/2,y1, sf::Color(0,0,0));
// middle of rect
Polygon.AddPoint((x1+x2)/2,(y1+y2)/2+70, sf::Color(0,0,0));
// for safety ( i don`t whant to have time biger than range int
if (time < 5)
time++;
oknoAplikacji.Draw(Polygon);
// drawing ALL POINTS OF POLYGON!
for (unsigned int i=0;i<Polygon.GetNbPoints();i++)
oknoAplikacji.Draw(sf::Shape::Circle(Polygon.GetPointPosition(i).x, Polygon.GetPointPosition(i).y, 5, sf::Color(255,255,255)));
oknoAplikacji.Display();
}
return 0;
}
But... WTF is this :
I draw all Points in my poly so why i have else?
for (unsigned int i=0;i<Polygon.GetNbPoints();i++)
oknoAplikacji.Draw(sf::Shape::Circle(Polygon.GetPointPosition(i).x, Polygon.GetPointPosition(i).y, 5, sf::Color(255,255,255)));