#include "/home/danya/raylib/src/raylib.h"
#include <cmath>
#include <vector>
#include <cstdlib>

struct CircleData {
    Vector2 position;
    float radius;
    Color color;
};

int main()
{
    // Initialization
    const int screenWidth = 800;
    const int screenHeight = 450;

    SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_VSYNC_HINT);
    InitWindow(screenWidth, screenHeight, "OpenAge map editor");

    SetTargetFPS(60);

    Camera2D camera = { 0 };
    camera.target = (Vector2){ GetScreenWidth() / 2.0f, GetScreenHeight() / 2.0f };
    camera.offset = (Vector2){ GetScreenWidth() / 2.0f, GetScreenHeight() / 2.0f };
    camera.rotation = 0.0f;
    camera.zoom = 1.0f;

    Texture2D background = LoadTexture("background.png");

    Vector2 mousePosition = { 0.0f, 0.0f };
    float wheelMove = 0.0f;
    float smoothTime = 30.0f;
    float camSmoothTime = 30.0f; // The time it should take to reach the target

    std::vector<CircleData> circles; // Vector to store circle data

    // Main loop
    while (!WindowShouldClose())
    {
        // Update
        mousePosition = GetMousePosition();
        wheelMove = GetMouseWheelMove();

        camera.offset = (Vector2){ GetScreenWidth() / 2.0f, GetScreenHeight() / 2.0f };

        // Draw
        BeginDrawing();

        ClearBackground(RAYWHITE);

        BeginMode2D(camera);

        DrawTextureEx(background, (Vector2){ 0.0f, 0.0f }, 0.0f, 1.0f, WHITE);

        // Draw existing circles
        for (const auto& circle : circles)
        {
            DrawCircleV(circle.position, circle.radius, circle.color);
        }

        // Handle zooming
        if (wheelMove != 0.0f)
        {
            float zoomFactor = (wheelMove < 0) ? 0.9f : 1.1f; // Zoom in decreases by 10%, zoom out increases by 10%
            camera.zoom *= zoomFactor;
            camera.offset = (Vector2){ GetScreenWidth() / (2.0f * camera.zoom), GetScreenHeight() / (2.0f * camera.zoom) };
            if (camera.zoom < 0.20f) camera.zoom = 0.20f;
            if (camera.zoom > 40.0f) camera.zoom = 40.0f;
        }

        // Smooth camera movement
        if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT))
        {
            Vector2 delta = GetMouseDelta();
            Vector2 target = (Vector2){ camera.target.x - delta.x / camera.zoom, camera.target.y - delta.y / camera.zoom };
            // Interpolate the current target towards the new target
            camera.target.x += (target.x - camera.target.x) * smoothTime * GetFrameTime();
            camera.target.y += (target.y - camera.target.y) * smoothTime * GetFrameTime();
            float minX = -camera.offset.x;
            float minY = -camera.offset.y;
            float maxX = background.width + camera.offset.x;
            float maxY = background.height + camera.offset.y;

            // Ensure the target position is within the allowed range
            camera.target.x = (target.x < minX) ? minX : (target.x > maxX) ? maxX : target.x;
            camera.target.y = (target.y < minY) ? minY : (target.y > maxY) ? maxY : target.y;

            // Interpolate the current target towards the new target
            camera.target.x += (camera.target.x - camera.target.x) * smoothTime * GetFrameTime();
            camera.target.y += (camera.target.y - camera.target.y) * smoothTime * GetFrameTime();
        }

        // Handle circle drawing
        if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
        {
            Vector2 worldMousePos = GetScreenToWorld2D(mousePosition, camera);
            // Round the worldMousePos to the nearest integer to get pixel coordinates
            Vector2 pixelPos = { std::round(worldMousePos.x), std::round(worldMousePos.y) };
            CircleData newCircle;
            newCircle.position = pixelPos;
            newCircle.radius = 0.5f; // Set the desired radius for the circle
            newCircle.color = RED; // Set the desired color for the circle
            circles.push_back(newCircle);
        }

        EndMode2D();

        EndDrawing();
    }

    // De-Initialization
    CloseWindow(); // Close window and OpenGL context

    // Unload textures
    UnloadTexture(background);

    std::exit(0);

    return 0;
}

Дополни событие левой кнопки мыши функцией, которая рисует полигон с углами на координатах клика, полигон должен рисоваться не сразу а между поставленными точками, у полигона должна быть заливка случайного полупрозрачного цвета и обводка шириной в 2 пикселя экрана. Обводку можно будет отключать нажатием клавиши 's'