Skip to content

Instantly share code, notes, and snippets.

View iaincarsberg's full-sized avatar

Iain Carsberg iaincarsberg

View GitHub Profile
@iaincarsberg
iaincarsberg / app.js
Created July 5, 2011 15:11
Example of a possible solution when adding components that require an asynchronous operation to attach to an entity, for example when loading a level.
require('./thorny/base')('./config/default.json', function ($) {
// Register a component so we can use it below.
$.es().registerComponent('load-level', function () {
return {
// Used to enable the isReady function.
asynchronousAttachEvent: 'world-loaded',
// Called in response to .addComponent()
attach: function (entity, filename) {
$.ajax({
@iaincarsberg
iaincarsberg / app.js
Created July 1, 2011 09:06
Thorny: De-verbos-ing the api
require('./thorny/base')('./config/default.json', function ($) {
if ($.dooooom().makeHappen() === $('thorny some-dooms-day-feature').makeHappen()) {
// serve cake, because cake and dooooom is an ideal pairing.
}
});
[
"thorny math vector2",
"./config/other.json"
]
@iaincarsberg
iaincarsberg / gist:1007712
Created June 4, 2011 08:03
Example of thornys entity system interaction
require('thorny/base')('./config/default.json')(function ($) {
// Grab a copy of the entity system object
var entitySystem = $('thorny entity-system');
// Make the actor template
entitySystem.makeEntity($.defined('template'))
.addTag('actor')
.addComponent('position')
.addComponent('keys')
.addComponent('render-2d');