Drawing/Displaying sprites from another functionI've been learning c++ and recently started learning how to use SFML (I'm a newbie).
I made this game (see attachment) with Code::Blocks and came over this question.
When i'm using the term "main function" i refer to the "mainLoop function" in the attachment.Can i draw/display anything in my window from another function?
like, if i had a main function that rendered a window and contained the main loop of my game, Could i make an "Enemy" function that displayed/drew anything in my main functions window?
If my function was returning anything, i would just have a value, which is not what i am looking for. I want the function to display something on my window and therefore i set it as a "void" type of function. However, if the function contains AI that interacts with other functions (eg. the Player) in the game, i would need to connect all the variables for all the sprites on the screen together so that they can interact with each other.
Is there any easy solution for this?
If not, i would love to have some suggestions on how to organize all of my sprites in the main function
it gets kinda messy in my main function
[attachment deleted by admin]