Those little fancy buttons above the textbox you're putting your text in on this forum all have a function. The dropdown box on the outer right which says 'Code' will let you choose 'C++' which will created a code=cpp tag which highlights every code that you put inbetween those tags.
For you problem:
You're calling the draw(), display() function and int to string convertion
outside of your gameloop, which means it will get updated, drawn and displayed once and never more.
Also you should look into classes, so you can understand more of C++ and SFML and could write nicer code (e.g. avoid global variables).
Try this:
#include <string>
#include <sstream>
#include <stdlib.h>
#include <SFML/Graphics.hpp>
int game = 1000;
void HandleMouseClick(sf::Mouse::Button click, int x, int y);
int main()
{
sf::RenderWindow window(sf::VideoMode(1024, 768), "My window");
sf::Text mytext;
// run the program as long as the window is open
while (window.isOpen())
{
// check all the window's events that were triggered since the last iteration of the loop
sf::Event event;
while (window.pollEvent(event))
{
if(event.type == sf::Event::MouseButtonPressed)
HandleMouseClick(event.mouseButton.button, event.mouseMove.x, event.mouseMove.y);
// "close requested" event: we close the window
else if (event.type == sf::Event::Closed)
window.close();
}
// Update the text
std::stringstream ss;
ss << game;
mytext.setString(ss.str());
// Draw the text
window.draw(mytext);
// Show the window
window.display();
}
return 0;
}
void HandleMouseClick(sf::Mouse::Button button, int x, int y)
{
if(x >= 264 && x < 800 && y >= 300 && y < 325)
{
game = game + 100;
}
}