As of now I structured my games this way:
I made a "game" object where I hold the most important variables and objects, then the main functions such as the game loop and most other routines as "methods" of the game object.
For laziness I put as methods also functions that affect very few of the game objects: should I better rewrite them as functions (passing in the appropriate stuff?)
From my understanding functons are faster than methods because they dont "pass in" all the fields of the object, only the necessary ones: is this correct?
[another question: say I want to pass variable in a function (say an integer) as a pointer/reference (so then I can modify it in the function), how would I do? I know that objects are always passed as a reference, what about variables?
I made a "game" object where I hold the most important variables and objects, then the main functions such as the game loop and most other routines as "methods" of the game object.
For laziness I put as methods also functions that affect very few of the game objects: should I better rewrite them as functions (passing in the appropriate stuff?)
From my understanding functons are faster than methods because they dont "pass in" all the fields of the object, only the necessary ones: is this correct?
[another question: say I want to pass variable in a function (say an integer) as a pointer/reference (so then I can modify it in the function), how would I do? I know that objects are always passed as a reference, what about variables?