Skip to content
The Chat Archive
gpt-3.5-turbo-1106· OpenAI Arena Human Preference 55K

Can you make a code in C++ that draws a simple face smiling in a new window

  1. User

    Can you make a code in C++ that draws a simple face smiling in a new window

  2. Assistant

    Certainly! You can use the SFML library to create a simple program in C++ that opens a window and draws a smiling face. Here's an example of how you can do it:

    #include <SFML/Graphics.hpp>
    
    int main()
    {
        sf::RenderWindow window(sf::VideoMode(200, 200), "Smiling Face");
    
        sf::CircleShape face(100);
        face.setFillColor(sf::Color::Yellow);
        face.setOutlineThickness(10);
        face.setOutlineColor(sf::Color::Black);
        face.setPosition(50, 50);
    
        sf::CircleShape leftEye(20);
        leftEye.setFillColor(sf::Color::White);
        leftEye.setPosition(80, 70);
    
        sf::CircleShape rightEye(20);
        rightEye.setFillColor(sf::Color::White);
        rightEye.setPosition(140, 70);
    
        sf::ConvexShape mouth;
        mouth.setPointCount(4);
        mouth.setPoint(0, sf::Vector2f(100, 130));
        mouth.setPoint(1, sf::Vector2f(120, 150));
        mouth.setPoint(2, sf::Vector2f(140, 150));
        mouth.setPoint(3, sf::Vector2f(160, 130));
        mouth.setFillColor(sf::Color::White);
        mouth.setOutlineThickness(5);
        mouth.setOutlineColor(sf::Color::Black);
    
        while (window.isOpen())
        {
            sf::Event event;
            while (window.pollEvent(event))
            {
                if (event.type == sf::Event::Closed)
                    window.close();
            }
    
            window.clear();
            window.draw(face);
            window.draw(leftEye);
            window.draw(rightEye);
            window.draw(mouth);
            window.display();
        }
    
        return 0;
    }
    

    This code creates a simple window using the SFML library and draws a smiling face using various shapes. You can compile and run this code to see the smiling face in a new window.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.