Ok, so basically I need to create a simple game using Allegro 5 and C++. I want to split it into separate modules so it's easier to manage. My question is: what is the proper way to manage "moving" between different files? Specifically, I'd like to have a file called Menu.cpp, which would be the main file and then depending on what the user selects, it does things specified in other files, like Singleplayer.cpp or Options.cpp (is this even a good approach?). My idea is to do it like this:
//Menu.cpp
#include "Singleplayer.h"
int main()
{
int parameter;
if(user_selects_singleplayer) singleplayer(parameter);
return 0;
}
//Singleplayer.cpp
void singleplayer(int parameter)
{
...
handle_singleplayer
...
}
//Singleplayer.h
#ifndef SINGLEPLAYER_H
#define SINGLEPLAYER_H //or maybe #pragma once ?
void singleplayer(int parameter);
#endif
I'd like to know if it's a proper way to do that, and if so, if I should have a main() function in Singleplayer.cpp (and how to change the file to make it work) and if I need to include Singleplayer.h in Singleplayer.cpp .
In my example i omitted some stuff like including allegro libraries, initializing more variables etc. to make the general idea clearer. Also I'd like to note that I can't use classes and streams (I know it's stupid, but it's a requirement as this project is a homework assignment for a programming class).
EDIT: the question linked by @Leiaz is relevant and answers to it are certainly helpful to understand how headers work, but my question was more about correct design approaches. Anyways, thanks for the answers, I will certainly read up on the subject.