Projects Inventory

Drawing Application Gaming Project in C++

Explanation:

  1. SFML Library:
    • The program uses the SFML library to create a graphical window and handle drawing operations. Ensure you have SFML installed and linked to your project.
    • Advertisement
  2. Window Creation:
    • sf::RenderWindow is used to create a window with a specified size (800×600) and a title (“Simple Drawing Application”).
  3. Drawing Data:
    • vector<sf::VertexArray> stores all the lines that have been drawn.
    • Advertisement
    • sf::VertexArray is used to represent a line being drawn. It is initialized with sf::LinesStrip, which allows the drawing of a continuous line.
  4. Drawing Logic:
    • isDrawing tracks whether the mouse button is pressed and whether a line is being drawn.
    • When the left mouse button is pressed, the program starts a new line and continues appending points to it as the mouse moves.
    • When the button is released, the current line is finalized and added to the vector of lines.
  5. Event Handling:
    • The program polls for events such as window closure. When the window is closed, the application exits.
  6. Rendering:
    • The window is cleared each frame with a white background.
    • Advertisement
    • All previously drawn lines and the current line being drawn are rendered to the window.
    • window.display() updates the window with the drawn content.

Possible Enhancements:

Exit mobile version