How can I draw like the picture?
#include <SFML/Graphics.hpp>
#include <iostream>
#include <sstream>
#include <ctime>
static inline std::string int2Str(int x);
int main()
{
int x,y;
int red,green,blue;
std::srand(time(NULL));
int SCREEN_W = 640;
int SCREEN_H = 480;
std::string width = int2Str(SCREEN_W);
std::string height = int2Str(SCREEN_H);
std::string printonscr = "Pixels Program - " + width + " x " + height + " - " + "Press ESC to Quit";
sf::RenderWindow window(sf::VideoMode(SCREEN_W,SCREEN_H), "Test");
sf::Font font;
if(!font.loadFromFile("arial.ttf"))
return EXIT_FAILURE;
sf::Text text(printonscr, font, 15);
text.setStyle(sf::Text::Bold);
while(window.isOpen())
{
x = 10 + rand() % (SCREEN_W);
y = 10 + rand() % (SCREEN_H);
red = rand() % 255;
blue = rand() % 255;
green = rand() % 255;
sf::Image dot;
dot.create(10,10,sf::Color(red,blue,green));
sf::Texture texture;
texture.loadFromImage(dot);
sf::Texture background;
sf::Sprite sprite(texture);
sprite.setPosition(x,y);
sf::Event event;
while(window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
window.close();
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
window.close();
}
window.clear(sf::Color::Black);
window.draw(sprite);
window.draw(text);
window.display();
}
return EXIT_SUCCESS;
}
static inline std::string int2Str(int x)
{
std::stringstream type;
type << x;
return type.str();
}
[attachment deleted by admin]