简体   繁体   中英

Organizing project files in Solution Explorer in Visual Studio

I'm making my first D3D simple game. My game uses many images.

This is my organization on disk:

MyGame
|
|-Debug
|-Release
|-Assets
  |-Others
  |-Images
|All cpp and h fiels here

If I launch my game from Visual Studio, thr game is working. But if I launch the game from Windows (by clicking the EXE file in the Release folder), I get an error that my application can't load images. This is because in my app I refer to those images like "Assets\\Images\\image.bmp".

How should I organize my project?

Now I have to make copy of the Assets folder in the Release folder and in the main project folder.

I think your project is organized fine; my suggestion would be instead of relying on a certain directory structure, just have an app.config or other XML .config file setting, or perhaps a registry setting (but don't do that) or an environment variable ( MY_GAME_ASSETS="C:\\path\\to\\assets" ), or perhaps even a command line parameter ( MyGame.exe --assets-dir="c:\\path\\to\\assets\\" ) that you can set on launching your game; then you can point that at the right directory wherever it is.

Another possibility to @shelleybutterfly's answer is to always refer to images relatively, eg as "..\\Assets\\Images\\abcde.bmp". Then when you deploy you could put your executable in the same kind of structure as long as the relative relationship is still the same.

eg Project:

MyGame
|-Debug
|-Release
|-Assets
  |-Others
  |-Images

eg Deployment:

C:\Program Files\MyGame
|-Bin (contains *.exe)
|-Assets
  |-Others
  |-Images

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM