#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Question Javascript with JSON, HTML5, & CSS/CSS3 - RPG game??


    Hey guys,

    I've been working on (in my opinion) a pretty solid rpg game idea but......I have a few issues...


    I'm pretty good with javascript and I know how to properly code and design a pretty basic JSON document layouts but I'm still pretty new to it.

    I wanted to do it as a text based RPG with graphics, work out the code as best as possible, get the storyline down well, the races/classes stats etc. pretty much get all the key components of the game down to where I like them and see how things go.

    JSON seemed like the perfect thing to implement into game data storage and from what i've seen, game development/storage with JSON isn't heavily documented on the net but I can't really see a reason why given some of it's capabilities and how light weight it is.

    Eventually, my ultimate goal would be to bring the game into Unity and do it as a full 3D MORPG and just transcribe the "text based" code into Unity's form of Javascript.

    BUT...I want the game to rely on JSON heavily as far as data storage goes for the game and even help with some of the layout with the CSS & replacing tables for JSON objects.

    I was wondering is there a way to pretty much use JSON for storing stuff like:

    Races, Classes, & Factions: also stuff like for races, each of their base attributes the player starts with and for classes, the stat modifiers each of them give and for factions, the difference in types of gear and even possibly quests available to you.

    Character Attributes & Profile: use JSON for holding and displaying the players stats & skills on their profile when it it visited. (wins & losses, strength, wisdom, agility, etc)

    Guilds: Same concept as the 'Character Attributes & Profile' idea except for Guilds.

    NPCs & Questgivers: for holding and displaying NPC characters and what they have to say & when also what quests can be given & for what level range and even their image file path. In general, the AI of the game.

    Game Objects: actual in game objects the player can interact with or pick up or equip and their stats.

    Saving your game: holding players data in some sort of secure JSON database if that's even possible.

    Player In-game Stats: Lives, Health, mana, energy, etc.

    GUI & Animation: using JSON array's instead of tables and then placing them with CSS for stuff like the players backpack window or the players run animation while moving using CSS3.

    two other issues I have is,

    A. is this all even possible and if so, how it would run?
    &
    B. how I could keep the code organized?

    If I do it this way their's going to be A LOT of JSON objects in one document. Could I write & save them as arrays and seperate files like Guilds.json, Classes.json, Races.json and than call & store them or certain parts of them as needed like calling a function or a variable using eval()?

    Also, if this IS all possible as far as making a text based browser game goes, how well could the "JSON" theory be implemented within a 3D environment like Unity?


    I hope you guys can help me out with this!


    Thanks,

    Ryan
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    Is your goal to make a single-player / offline RPG or a multi-player / server based RPG?

    JSON is an acceptable (but not great) format for storing static data, but a terrible one for storing dynamic data. Essentially, if the data is read-only you can store it as JSON; otherwise, you should not store it as JSON. JSON isn't intended to be a data storage format, it's just intended to be a data transfer format. However, it does actually work OK for serializing the state of objects as you would do for a game save file, so for a single player game it would be OK for game-save files.

    If there is any ever situation in which one player could need to access any data for another player, then JSON is not suitable at all.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0
    I want the game to go through phases in its development that way by the time i even reach alpha testing of the 3D phase I have a steady footing and everything worked out on what I want and yeah, eventually make it a multiplayer game but that's a separate topic.

    And I understand what you said about JSON, but what I still don't get is the fact that you can store functions and variables in JSON objects and call them so why would JSON be bad for storing things like The players name, stats, arena rank, etc. or guilds for example, they're world rank, honor, amount of members/limit, and a members list or the quest givers and NPCs idea, storing the id and name of quest giver, name and id of quest, quest text, incompleted quest text, completed quest text, reward for completion and stuff like that?

    Like I said, I just want to start it as a text based game with graphics and even graphics come later on. So for an expanding online single player RPG game, would JSON be plausible for what I'm asking? I know user to user interactions need to be secure which cant easily be done with JSON but can be using different methods in Javascript.

    I appreciate any info or feedback
  6. #4
  7. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    You can't store functions or object references in JSON. If you're talking about normal JavaScript objects, then yes it makes sense to have objects for all of those things. The objects would be constructed when the game is loaded and destroyed when the game is unloaded. For long term / server side storage of the data it is not plausible to use JSON UNLESS the data is only access by ONE user ever, which does not sound like the case.

    Things like quest text, quest rewards, and the list of NPCs are logical to store in JSON even on the server side, because that data should almost never change (except when you perform a game code update).

    Things like player name, stats, rank, honor, and quest completion status should not be stored in JSON. These things will change frequently. You could transmit it from the server side to the client side initially using JSON, and on the client side you would load it into a JavaScript object, but on the server side you should never store that type of data as JSON.

    You need a database engine to store data on the server side. Something like MySQL, Postgresql, MSSQL, etc. A storage solution based on JSON would have terrible performance and scalability.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo