Member_2_2394978
asked on
File Access via exe Location
Hi,
I'm making a simple tile based game so have many different images as the tiles, at the moment i am simply adding them all by typing in the full path location of each image into my code but want to make an editor which will save the location into a string. Ā But because if i save the full path, once the game is run on another machine the full path's will be different, so had the idea of saving the locations of the images in relation to the location of the executable.
For example if my structure was as follows
/game
/game/images
/game/executables
Is it possible to save the location of the images as game/images so it doesn't matter where the game folder is on the hardrive it will allways go up one level then into the images folder to loacte my tile images?!
Thanks for Help
I'm making a simple tile based game so have many different images as the tiles, at the moment i am simply adding them all by typing in the full path location of each image into my code but want to make an editor which will save the location into a string. Ā But because if i save the full path, once the game is run on another machine the full path's will be different, so had the idea of saving the locations of the images in relation to the location of the executable.
For example if my structure was as follows
/game
/game/images
/game/executables
Is it possible to save the location of the images as game/images so it doesn't matter where the game folder is on the hardrive it will allways go up one level then into the images folder to loacte my tile images?!
Thanks for Help
ASKER
Hi thanks for quick reponse.
I get the exePath bit but what is 'GamePath' is that a variable!? Thats the furthest up directory isn't it, but where is it coming from?
Cheers
James
I get the exePath bit but what is 'GamePath' is that a variable!? Thats the furthest up directory isn't it, but where is it coming from?
Cheers
James
Use the following as an example
var ThisDir : String ;
ThisDir := ExtractFilePath(Applicatio n.Exename) + 'games/images'
var ThisDir : String ;
ThisDir := ExtractFilePath(Applicatio
Oops sorry PierreC,
I did not see your post.
I was too slow....
PierreC gets the points.
I did not see your post.
I was too slow....
PierreC gets the points.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for quick help
James
James
Sorry, GamePath Should have been ExePath.
My first example will be fine with the following dir structure
c:\game {exe goes here}
c:\game\images
if you prefer the following dir structure, rather use relative path in loadfromfile:
c:\game
c:\game\exe
c:\game\images
My first example will be fine with the following dir structure
c:\game {exe goes here}
c:\game\images
if you prefer the following dir structure, rather use relative path in loadfromfile:
c:\game
c:\game\exe
c:\game\images
ExePath:= ExtractFilePath(ParamStr(0
ImagePath:= GamePath + 'images\';
regards
Pierre