Hey All,
I'll be the first to admit I don't know much about javascript programming but I did use it to create my entry of the week of awesome 2 competition. Now that competition is close I'd like to continue developing my game but before I continue to build on to what I've already got I'm looking for advice on how to better structure my code base. As how things currently stand I have one js file consisting of a 1000+ line controller.
Its made up of several sections:
- Game Data - Holding all the variable related to the current game state.
- Actions Lits - These are list of all the available actions in each room, along with descriptions of the actions, whether they are enabled, how many times its been called and a maximum number of times it can be called, not relevant to every action.
- Story Data - This is just arrays containing text displayed at different times to the user, and any accompanying image data to go with the text.
- Action Methods - There is a set methods that deal with performing an action, enabling, and disabling actions, and resolving the action and whatever the success and failure results.
- Popup methods - These methods deal with displaying and handling input from popup boxes displayed to the user.
- Combat methods - The methods that deal with combat.
- Stat Change methods - This is set of methods that wrap the common functionality around changing any of the main character stats.
If I was doing this c# or java I'd be able to break all of those into different classes or spread the functionality across multiple partial files without a problem. But when using them inside an angularJS controller I haven't go a scooby as to how to go about it.
Any good tips on how to proceed? I don't want to end up with one file that's over 5000 lines long.