Documentation
Hey, might be worth ignoring this for now, its going to be a poorly written wall of text that will make little sense until the code has been uploaded to github.
With any engine you need to be able to customise the gameplay experience, otherwise your just making a game, and calling it an engine. Thorny makes use of jQuery’s trigger and bind functions, allowing you to hook into the execution process and make changes.
Following is a list of fired events, all of these can have custom logic bond to change how the game
Fired events
- throny:init: Fired when thorny is initially initiated, allows you to check that the target browser fully supports everything your game requires.
- thorny:render-enter: When thorny enters its render state this is fired, allowing you to setup any data that is required prior to the main renderer running, for example if your using the vector render plugin this will create its own canvas element.
- thorny:render-draw: This is executed on every render frame, is basically allows you to hook into the internal rendering process, encase you need to make some additional changes to the rendered scene
- thorny:render-exit: When the render state is exited this is called, allows you to rollback any changes to the dom that occurred during the ‘thorny:render-enter’ and ‘thorny:render-draw’ states.
- thorny:world-enter: When thorny enteres its world state this event is fired, basically what you do in here is load all of your content into memory. In addition when loading the levels geometry thorny has to do a bit of processing work to help with the real-time simulation, so if your level is big it could take a few moments.
- thorny:world-update: This is used internally to progress the state of the world object, so any movement that occurs within the game is handled here.
- thorny:world-exit: When the world is exited this is used to upload all content added
- thorny:ai-enter: Called when the ai handler is entered
- thorny:ai-update: Every n number of frames the ai is processed, n being $.thorny.options.aips or ‘artificial intelligence per second’ this is the update frequency for when thorny:ai-update is called, on these events your ai’s controller will be executed, whereby your actor will select a new action to execute. The idea here is that once a second or so your ai will select a new destination which could be an expensive action, then during the thorny:world-update events it will proceed to move to that location.
- thorny:ai-exit: Called when the ai system is exited.