Simple Paint Application Gaming Project in C++

Explanation

  1. Dependencies:
    • This program uses the SFML library for creating the graphical user interface (GUI). Ensure SFML is installed and properly linked in your project.
  2. Drawing Function:
    • drawOnWindow(RenderWindow& window, const std::vector<CircleShape>& points): Clears the window and draws all circles (points) stored in the points vector.
      • Parameters:
        • window: The SFML window where drawing occurs.
        • points: A vector of CircleShape objects representing the points drawn on the window.
  3. Main Function:
    • Initialization: Sets up the SFML window with a size of 800×600 pixels and the title “Simple Paint Application”.
    • Event Handling:
      • Closes the window when the close event is triggered.
    • Drawing Logic:
      • Checks if the left mouse button is pressed (Mouse::isButtonPressed(Mouse::Left)).
      • If the button is pressed and not currently drawing (drawing flag), it creates a new CircleShape to represent a point and adds it to the points vector.
      • The position of the circle is set to the mouse position minus the radius to center the circle on the cursor.
      • If the mouse button is not pressed, the drawing flag is set to false.
    • Drawing on Window: Continuously calls drawOnWindow() to render all points in the window.

Notes:

  • This program allows users to draw on the window by clicking and dragging the mouse. Each click creates a small black circle at the cursor position.
  • For more advanced features, such as color selection or line thickness, you would need to add additional UI elements and logic.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top