I am working on a project and I need tips (JavaScript/Html)
1 20 Dec 2015 09:52 by u/Puffycheeses
I am making an "RPG" Its more like a book but with quests and stuff. I am using JSON to store all places, monsters, items and stuff. There has to be an easier way to store lots of data and call it. My code is messy and incomplete, I just wanted for some people who know what there doing to have a look over the code to see if I could simplify or clean up the code.
And the HTML is simple, Doesn't need a link:
<html>
<body>
<span id="place">Null Place</span><br>
<span id="desc">Null Desc</span><br>
<span id="health"></span><br>
<span id="buttons"></span><br>
</body>
</html>
<script src="script.js"></script>
Here is a link to look at the actual working project
IMPORTANT NOTE: These links go to dropbox so if someone tries to help me the links will show the edited code
2 comments
0 u/Master_Foo 21 Dec 2015 00:27
Presuming you are only programming for the front end... and presuming "store lots of data and call it" means you are storing "state" variables.
Use Cookies instead of json.
As for defining the places, monsters, etc... Just create a class for those. JSON is literally "javasript object notation" which means it's a text version of an object. You might as well just make a class and use it.