Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inheritance / composition #15

Closed
Ben2303 opened this issue Sep 2, 2011 · 7 comments
Closed

inheritance / composition #15

Ben2303 opened this issue Sep 2, 2011 · 7 comments
Milestone

Comments

@Ben2303
Copy link

Ben2303 commented Sep 2, 2011

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...

@melonjs
Copy link
Collaborator

melonjs commented Sep 2, 2011

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 :

  1. Object -> Rect -> SpriteObject
  2. AnimationSheet (that would implement various texture/sprite format)
  3. 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 :):)

@Ben2303
Copy link
Author

Ben2303 commented Sep 2, 2011

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.

@melonjs
Copy link
Collaborator

melonjs commented Sep 2, 2011

That would be great, thank you very much :)
We could then put this in the repository and complete it over the time !

@greghouston
Copy link

Lots of info for optimizing for Chrome:
http://www.youtube.com/watch?v=XAqIpGU8ZZk

@melonjs
Copy link
Collaborator

melonjs commented Sep 27, 2012

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)

melonjs pushed a commit that referenced this issue Feb 13, 2013
melonjs pushed a commit that referenced this issue Mar 3, 2013
Ticket #15 - inheritance / composition
@melonjs
Copy link
Collaborator

melonjs commented Mar 3, 2013

@parasyte probably still need some improvements here and there, but one more done :)

@melonjs
Copy link
Collaborator

melonjs commented Mar 18, 2013

I'm closing this one :)

hornta pushed a commit to hornta/melonJS that referenced this issue Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants