Created
May 6, 2015 09:07
-
-
Save gre/fadd75d340f183444e44 to your computer and use it in GitHub Desktop.
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
import World from "./World"; | |
import Physics from "./Physics"; | |
// expose all the things | |
window.ENGINE = { World: World, Physics: Physics }; |
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
const Physics = { | |
applyForce: function(x, y) { ... }, | |
processEntity: function(entity) { ... } | |
}; | |
export default Physics; |
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
const World = { | |
the_answer_to_everything: 42 | |
}; | |
export default World; |
ES6 destructuring makes this nice too - you can pull out bits only when you need them
import Engine from './Engine';
const {Lander, Astronaut, WaveCharge} = Engine;
const {Encouter, Mission, Junkyard} = Engine;
Etc... not sure why Junkyard is part of your engine though ;)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Putting some hierarchy into code design should greatly reduce these imports to 5-10.