I want to make a virtual reality kind of rpg game, which involves using an SD to store the data of the player.
The game will involve a player 'leveling up', so I need to be able to edit files on the SD card.
For example, every xxx attacks, changing the player level on the sd card from 5 to 6. I know you can read and write on an sd card, but can you edit existing files on one?
I know you can read and write on an sd card, but can you edit existing files on one?
Of course. Open the file for read. Locate the data of interest, keeping track of how many characters you have read. Close the file. Open it for write. Seek to the proper location (based on the number of characters read), and write the new data. Close the file.
Note that this technique only works if the new data is the same size (number of characters) as the old data. So, care is needed when setting up the format of data in the file.
Is there a sample code out there that can do that? I don't really know what you mean.
Is there a sample code out there that can do that?
Probably.
I don't really know what you mean.
We should work on that, instead. What part(s) don't you understand?
What do you mean by "open the file for read/write"? Or seeking to the proper location? Aslo, you say that it neds to be the same size. By that, do you mean that the SD card has something like "Level: 9" and the player levels up, would I not be able to edit it and turn it to "Level: 10"