I am new to gamedev, and I have one question about architecture. Where to locate game images? Should I keep this in the class object or in the main function and draw it depending on object variables?

  • 2
    \$\begingroup\$ Can you confirm, are you asking about where to hold a reference to the in-memory texture/sprite asset after it's been loaded? Or where to store the on-disc location from which the image should be read? Or something else? What have you tried so far, and how has that strategy been working for your needs? \$\endgroup\$ – DMGregory Nov 19 '18 at 12:54

There is no correct answer to this question. Fortunately, every programmer can choose any way to organise their project. You can follow the Object Oriented design, or you can pick something you think is better.

It is generally discouraged to put anything low-level in the main function, but it's not impossible to make something this way. Usually you'd want to go from high level to low level, so your main function should handle how the game runs (initialise libraries/tools, initialise the game itself, etc) then each part takes care of more and more details (the game itself contains images, and figures out how to display them).

But that's just one way to do it, there are design architectures out there, for different people. If you are doing this as a hobby, pick one that makes the most sense to you, and stick with it. If this is for a professional environment, learn the popular ones, so it's easier to work with other people.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.