How to include assets in build

I get asset for player straightforwardly like so:

SDL_Surface* temp_surface = IMG_Load("assets/player.png");

Naturally, the player will only load if player.png exists, in a folder called assets that also has to exist inside the project directory.
When the program is build, this remains the case. Assets has to be there, sitting next to the .dlls and the .exe. This is very sub-optimal. I would not like for a casual user (one without the means and intention to data-mine) to see the assets of my project (what if it’s a story driven game? That would be spoilers!)

Unsure if this is an SDL problem per se, but I’m putting it in the SDL Dev category just in case there’s something about this in the SDL documentation that I missed.

I’m using Code::Blocks v17.12.
I am writing the game in C. I will switch to C++ if that would lead to the only feasible means of solving this issue.
I am very early in development (which is to say, I haven’t started actually developing anything.) I am just scoping out my environment and my tools, and so am willing to be very flexible and adaptive in order to get something to build properly.

You could put the assets in some kind of archive and load the game data from there.
The simplest solution might be a .zip archive (maybe with a different filename if you want to confuse the less clever of your players). can help accessing the files in zips or also from the FS in a unified way and can be integrated with SDL and its helper libs with SDL_RWops (see
(PhysFS doesn’t only support zip but also other kind of archives, see its homepage)

So all a user would have to do is notice the .zip folder and then unzip it in order to see the assets?

You could convert your files to binary and include them in your project as a file.

Stopping ppl from stealing your assets is a lost cause. Ppl will rip, extract, datamine your assets if they really want them.

1 Like