I am making a game using C++ with SFML lib and in my main I created couple functions. I know it is a bad manner to do that in main but yeah. when I try to compile the code I am getting error:
src/main.cpp: In function 'void create_platforms(std::vector<std::unique_ptr<sf::Sprite> >&)':
src/main.cpp:12:6: error: no previous declaration for 'void create_platforms(std::vector<std::unique_ptr<sf::Sprite> >&)' [-Werror=missing-declarations]
void create_platforms(std::vector<std::unique_ptr<sf::Sprite>>& platforms)
^~~~~~~~~~~~~~~~src/Player.cpp:
In member function 'void Player::gravity(sf::Time&, sf::FloatRect&)':
same goes to create_items and create_interface. I am not using any header file for main.cpp, can I just declare those in main.cpp? If so I would be glad if someone would help me how to do it.
void create_platforms(std::vector<std::unique_ptr<sf::Sprite>>& platforms)
{
[...]
}
void create_items(std::vector<std::unique_ptr<sf::Sprite>>& healing_items)
{
auto small_heart = std::make_unique<sf::Sprite>();
small_heart->setTexture(*TextureManager::getTexture("heart"));
small_heart->setPosition(320, 180);
small_heart->setScale(0.4, 0.4);
healing_items.emplace_back(std::move(small_heart));
}
void create_interface(std::vector<std::unique_ptr<sf::Sprite>>& interface)
{
auto life = std::make_unique<sf::Sprite>();`enter code here`
life->setTexture(*TextureManager::getTexture("life"));
life->setPosition(10, 530);
interface.emplace_back(std::move(life));
}
int main()
{
[...]
}