I m trying to make a menu for a simple snake game.
I ve got 2 photos,one for the normal menu,and one for when the mouse goes through a particular area of a text from the menu(simple makes the text look different ).
The problem is that the image "vibrates" ,simply the first image wont change into second to enlighten the text,it will change just for very short time (0,1 ms 0,2 ms)
Also ,on click ,i tried to make the game start.
So let's get straight.
If the mouse just goes through a specific area,i want the image to change.
If then the mouse clicks,i also want the game to start.
there is the code from the main function
int main()
{
sf::RenderWindow window(sf::VideoMode(size*length+size, size*width+size), "SFML works!");
Texture t4,t5;
t4.loadFromFile("images/men.jpg");
t5.loadFromFile("images/men2.jpg");
Sprite nebunie(t4);
Sprite nebunie2(t5);
while (window.isOpen())
{window.draw(nebunie);
window.display();
Event Event;
while (window.pollEvent(Event))
{sf::Vector2i position = sf::Mouse::getPosition();
cout<<position.x<<" "<<position.y<<"\n";
if (position.x>583&&position.x<820&&position.y>293&&position.y<319)
{
window.draw(nebunie2);window.display();
if (Event::MouseButtonPressed)
if (Event.mouseButton.button==Mouse::Left) game();
}
}
}
This is my first sfml project,i m sorry if i haven't explained quite well.