Sign in to follow this  
programwizard

Hiding Resources

Recommended Posts

How is it that comercial PC games are able to keep you from seeing their graphics and sound files? Whenever I build a game that uses external files, all files have to be in the same directory as the executable, otherwise the program just crashes.

Share this post


Link to post
Share on other sites
They normally keep thier resources in some sort of custom file format. Resource Files Explained seems to give a good explanation of it along with a sample implementation you can look at - I'm sure you can find plenty of other articles if you try, that was the first one I came across with a quick Google on the topic.

A quick way of doing this that people often use is to write code to load your resources from a zip (or other compressed) file, and then simply rename the extension to something else. You can also try encrypting your resources, but if someone wants to get to them they will, so don't spend too much time worrying about it for that reason - the better reason why you'd want to do it is because it's neater, and you may be able to reduce your overall filesize a bit.

Share this post


Link to post
Share on other sites
Well they may use proprietary formats for their resources which you'll be unable to open unless you have the right tools. Many games also use a pak-style file which is basically just like a big zip file that contains a whole load of files. PhysicsFS is a library that you can use to setup this kind of system.

Quote:
all files have to be in the same directory as the executable, otherwise the program just crashes.


All programs have what's called a working directory, when you specify a path in your program unless it's absolute (e.g. C:\Dir\File or in Unix /dir/file) it's relative to the current working directory. So if your program is run from a directory which has subdirectories named music and graphics you can access the files in those directories within your program by using paths like 'music\file' and 'graphics\file'.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this