1 decade ago by Neeko
I want to avoid deep class hierarchies while I DRY up and share similar behavior code throughout my entities. I've started following an entity framework (http://www.richardlord.net/blog/what-is-an-entity-framework), though I admit so far what I've done isn't the canonical definition of an entity framework, but similar.
Here's how I've broken out behavioral code and how each specific entity composes that behavior. Note that some of the classes are abbreviated.
entityController.js
https://gist.github.com/MadballNeek/95e8ad8a8b30561d6f0d
playerController.js
https://gist.github.com/MadballNeek/ef5ce88adc1952e24e9a
player.js
https://gist.github.com/MadballNeek/a3d755add6354723a749
enemyController.js
https://gist.github.com/MadballNeek/7576c1b52678b7346ff4
spike.js
https://gist.github.com/MadballNeek/22b172835620f18a680d
I would just like to get any comments and criticisms on what I've done so far. One improvement I can see is passing just the data that the controllers need instead of a reference to the entire entity. I'd also like to avoid having to extend the EntityController class completely, but I think it's necessary due to the specific behavior required by both the player (direct input) and enemy (AI) entities.
Thanks for looking!
Here's how I've broken out behavioral code and how each specific entity composes that behavior. Note that some of the classes are abbreviated.
entityController.js
https://gist.github.com/MadballNeek/95e8ad8a8b30561d6f0d
playerController.js
https://gist.github.com/MadballNeek/ef5ce88adc1952e24e9a
player.js
https://gist.github.com/MadballNeek/a3d755add6354723a749
enemyController.js
https://gist.github.com/MadballNeek/7576c1b52678b7346ff4
spike.js
https://gist.github.com/MadballNeek/22b172835620f18a680d
I would just like to get any comments and criticisms on what I've done so far. One improvement I can see is passing just the data that the controllers need instead of a reference to the entire entity. I'd also like to avoid having to extend the EntityController class completely, but I think it's necessary due to the specific behavior required by both the player (direct input) and enemy (AI) entities.
Thanks for looking!