#include <stdexcept>
#include "utils.hpp"
#include "SDL_image.h"
#include "data/hills.hpp"


std::vector<SDL_Surface *> get_hills() {
    std::vector<SDL_Surface *> surfaces;

    for (int i = 0; i < hills_length; i++) {
        HillData png = hills[i];
        SDL_RWops *rw = SDL_RWFromMem(const_cast<unsigned char *>(png.data), png.length);
        if (!rw)
            throw std::runtime_error("Failed to create RWops from memory");

        SDL_Surface *surface = IMG_Load_RW(rw, 1);
        if (!surface) {
            SDL_RWclose(rw);
            throw std::runtime_error("Failed to load image from memory: " + std::string(IMG_GetError()));
        }
        surfaces.push_back(surface);
    }

    return surfaces;
}
