inheritance / composition
First Im really not familliar with javascript, got several years of object modeling and C++ dev, but I'm a complete beginner in js... So excuse me if I'm completly out of bound...
Looking at your inheritance model, I feel like there are some oddities : For example ObjectEntity extends AnimationSheet extends AnimatedSpriteObject extends SpriteObject extends Rect extends Object
I thinkk it should be something like that : ObjectEntity is composed with AnimatedSpriteobject and entity related data AnimatedSpriteobject extends SpriteObect and is composed with AnimationSheet SpriteObject extends Rect Rect extends Object
That may just sound like purist gibberish though...
Hi Ben,
You are completely, completely, completely right ! What you should know also is that although melonJS is a couple of months old in github, It’s actually one more year older, and some code are still “suffering” from the old bad architecture I had back then.
Concerning the AnimatedSpriteObject, I was actually waiting to implement a proper sheet format (like texturepacker, or anything else), before breaking/rewrite this and make it nicer. But yes, but Ideally it should be something like that :
- Object -> Rect -> SpriteObject
- AnimationSheet (that would implement various texture/sprite format)
- ObjectEntity, that implements, SpriteObject & AnimationSheet
But until there is some real changes in the code, I don’t see the need to break the actual inheritance model (even if not particularly clean, it’s still functionally, and for what it does, working fine).
Olivier.
[EDIT] not to mention that rewrite this would allow me to better define the InvisibleEntity Object as well... in case you didn't notice (yet) it :):)
Hi, Didn't looked at the InvisibleEntity until you pointed it out :D I totally understand history of melonJs went through some awkward paths, been there a little too often.... If I have some spare time this afternoon, I can make a class map (using freemind, don't have many options on the office computer :p ). As I will make it for me to understand and begin to code a few things, I can share it with you if it can help you.
That would be great, thank you very much :) We could then put this in the repository and complete it over the time !
Lots of info for optimizing for Chrome: http://www.youtube.com/watch?v=XAqIpGU8ZZk
Target for 0.9.6 :
- break the current inheritance scheme between SpriteObject and ObjectEntity
- make of SpriteObject an optional property object of Object Entity
In a few words : In case the property is defined, Object Entity update and draw function will call respectively the sprite property object update and draw function. In case the property is not defined, object Entity will act as an invisible entity (which means that the Invisible Entity Object can be removed)
@parasyte probably still need some improvements here and there, but one more done :)
I'm closing this one :)