|
Allegro in the file management. |
keprast
Member #16,794
January 2018
|
Not quite understand how the location of resource files (such as pictures) is expressed? |
binary_brain
Member #16,810
February 2018
|
// variable initialization // get location of // if you have only one image you can write as well (before al_load_bitmap) |
keprast
Member #16,794
January 2018
|
@binary_brain Thanks! For example, I have a picture in c / abc, I need to set the file path to: Is that right? |
binary_brain
Member #16,810
February 2018
|
I don't really know what do you mean. However: - you need the location of exacutable if you run your executable from another location than you're currently in. Providing that you have a folder "./docs/c/games/_your_game_/_your_executable_" than if you will be in your_game folder the default location will be the same as the location of executable - "./img/_some_img_" will become "./docs/c/games/_your_game_/img/_some_img_", but if you were in ex. "games" folder your images simply won't load. - al_set_path_filename ( path, "img/image.png" ) is kind of a trick and I cannot grant you that it will work on any supported OS. |
Audric
Member #907
January 2001
|
bb's code is what you need when the game file are stored like : (Here's the same code he posted, formatted for line numbers) 1// variable initialization
2ALLEGRO_PATH *path;
3ALLEGRO_BITMAP *image;
4
5// get location of
6path = al_get_standard_path ( ALLEGRO_RESOURCES_PATH ); // get location of your executable
7al_append_path_component ( path, "img" ); // the folder containing your images
8al_set_path_filename ( path, "image.png" ); // set the image name
9image = al_load_bitmap ( al_path_cstr (path, ALLEGRO_NATIVE_PATH_SEP) );
10
11// if you have only one image you can write as well (before al_load_bitmap)
12al_set_path_filename ( path, "img/image.png" );
Beginning : path is an empty path Line 12 is a way to combine line 7 and 8, but it only works is path is the "root" of your game. Otherwise, it will create paths like "img/img/img"... |
keprast
Member #16,794
January 2018
|
So this is, I understand. |
|