Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SFML/Graphics.hpp>
- class Window {
- public:
- Window();
- void run();
- static int r, g, b;
- private:
- void update();
- void processEvents();
- void render();
- private:
- sf::RenderWindow window;
- sf::Font font;
- sf::Text text;
- };
- Window::Window()
- : window(sf::VideoMode(640, 480), "Meme, haha xDDDD")
- , font()
- , text("Get On My Level", font) {
- font.loadFromFile("arial.ttf");
- text.setCharacterSize(50);
- text.setColor(sf::Color(0, 0, 0));
- }
- void Window::processEvents() {
- sf::Event event;
- while(window.pollEvent(event)) {
- if (event.type==sf::Event::Closed)
- window.close();
- }
- }
- void Window::run() {
- while(window.isOpen()) {
- processEvents();
- update();
- render();
- }
- }
- void Window::update() {
- for (;r!=255&&g==0;r++)
- text.setColor(sf::Color(r, g, b));
- for (;g!=255&&b==0;g++)
- text.setColor(sf::Color(r, g, b));
- for (;r!=0&&g==255;r--)
- text.setColor(sf::Color(r, g, b));
- for (;b!=255&&g==255;b++)
- text.setColor(sf::Color(r, g, b));
- for (;g!=0&&b==255;g--)
- text.setColor(sf::Color(r, g, b));
- }
- void Window::render() {
- window.clear();
- window.draw(text);
- window.display();
- }
- int Window::r=0, Window::g=0, Window::b=0;
- int main() {
- Window win;
- win.run();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement