Created
October 17, 2011 15:43
-
-
Save iaincarsberg/1292900 to your computer and use it in GitHub Desktop.
Demos of two possible level loading syntaxes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Less pretty syntax, super simple to implement, generic reusable implementation | |
flow.exec( | |
function () { | |
new Entity().addComponent('level', this) | |
}, | |
function (err, level) { | |
level.addComponent('level-segment', 'something.json', this) | |
}, | |
function (err, level) { | |
level.addComponent('level-segment', 'something-else.json', this) | |
}, | |
function (err, level) { | |
renderer.draw(level); | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Nicer syntax, but the implementation is bound to the solution | |
var map = new Entity() | |
.addComponent('level') | |
.addComponent('level-segment', 'something.json') | |
.addComponent('level-segment', 'something-else.json') | |
.triggers(function () { | |
renderer.map(map); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Entity() | |
.exec( | |
function (entity) { | |
entity.addComponent('level', entity, this) | |
}, | |
function (entity) { | |
entity.addComponent('level-segment', 'something.json', this) | |
}, | |
function (entity) { | |
entity.addComponent('level-segment', 'something-else.json', this) | |
}, | |
function (entity) { | |
renderer.draw(entity); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment