I am currently working on developing a 2D, top-down RPG game inspired by Zelda for the web...
My plan is to organize dialog in JSON format...
Right now, I have the JSON data stored in an external JavaScript file called js/json.js:
function getJson() {
var json = {
"people" :
[
{//NPC 1 - rescue dog
etc...
To access this data in my main game JavaScript file, I include it using
<script src="js/json.js"></script>
..`
var json = getJson();
Then, I can reference the data like this:
Labels[index].text = json.people[index].dialogs.start.texts[0];
I'm wondering if there would be any benefit to storing the JSON as a separate .txt
file and then parsing it instead of keeping it as a JS file within a function.
Any insights would be greatly appreciated!