When I run the following, the buffer0 prints out the movement of the mouse in the Y direction and the buffer1 prints a constant. When I stop mouse movement and press it's button, buffer0 prints the current X location and buffer1 prints the current Y location. Can someone please tell me what I am doing incorrectly? Thanks a million.
Warren Trammell
#include <iostream>
#include <SFML/Graphics.hpp>
int main()
{
char buffer0[25],buffer1[25];
sf::RenderWindow window(sf::VideoMode(2300, 1300), "SFML window");
sf::Font font;
if (!font.loadFromFile("/users/warren/programming/projects/impact.ttf")) return EXIT_FAILURE;
sf::Text text;
text.setFont(font);
text.setCharacterSize(50);
text.setColor(sf::Color::Red);
window.clear(sf::Color(128,128,128));
window.display();
// Start the game loop
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event::Closed:
window.close();
break;
}
}
window.clear(sf::Color(128,128,128));
sprintf(buffer0,"%i",event.mouseWheel.x);
sprintf(buffer1,"%i",event.mouseWheel.y);
text.setString(buffer0);
text.setPosition(500,600);
window.draw(text);
text.setString(buffer1);
text.setPosition(1000,600);
window.draw(text);
window.display();
}
return EXIT_SUCCESS;
}