Skip to main content
edited tags
Link
Simon Forsberg
  • 59.7k
  • 9
  • 160
  • 312
added 6 characters in body; edited tags
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

When I intercept the properties, I currently wrap intercepted function calls into a closure (see basecomponent.intercept()) so that the 'this'this object can refer to the component itself. Without that the 'this'this object was still being referred to as the attachedEntityattachedEntity (from within the components version of that function), so to get the components properties I had to run a query.

Things I've used as reference:
http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/ http://gameprogrammingpatterns.com/component.html
http://blog.bengarney.com/2010/06/12/composition-vs-inheritance/

Full source code can be found here.

JumpPadComponentJumpPadComponent attached to a couple of standard entities:

Full source code can be found here: https://github.com/onedayitwillmake/ChuClone

When I intercept the properties, I currently wrap intercepted function calls into a closure (see basecomponent.intercept()) so that the 'this' object can refer to the component itself. Without that the 'this' object was still being referred to as the attachedEntity (from within the components version of that function), so to get the components properties I had to run a query.

Things I've used as reference:
http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/ http://gameprogrammingpatterns.com/component.html
http://blog.bengarney.com/2010/06/12/composition-vs-inheritance/

JumpPadComponent attached to a couple of standard entities:

Full source code can be found here: https://github.com/onedayitwillmake/ChuClone

When I intercept the properties, I currently wrap intercepted function calls into a closure (see basecomponent.intercept()) so that the this object can refer to the component itself. Without that the this object was still being referred to as the attachedEntity (from within the components version of that function), so to get the components properties I had to run a query.

Things I've used as reference:

Full source code can be found here.

JumpPadComponent attached to a couple of standard entities:

added 8 characters in body; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Component based-based system for javascriptJavaScript game

Hi I'm creating a javascriptJavaScript/webglWebGL based game and would like you guysall to take a look at the current entity component system which I created for it. I've used it once before on another project, and while I was very happy with the results, there were parts of it iI did not feel 100% good about.

In particular, sometimes a component needs to call the attachedEntitiesattachedEntities version of a function it has overridden. For example handleInput, ithandleInput might call the attachedEntities handleInputattachedEntities handleInput functions and then with the new movementVectormovementVector multiply them by negative 1 so now all input while this component is active is reversed.

When I intercept the properties, currently I currently wrap intercepted function calls into a closure (see basecomponent.intercept()basecomponent.intercept()) so that the 'this' object can refer to the component itself. Without that the 'this' object was still being referred to as the attachedEntity (from within the components version of that function), so to get the components properties I had to run a query.

Things II've used as reference:
http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/ http://gameprogrammingpatterns.com/component.html
http://blog.bengarney.com/2010/06/12/composition-vs-inheritance/

** ENTITY SUPPORT FOR COMPONENTS **Entity support for components

I'm curious to get other'sabout others' thoughts on this implementation of such a component based-based system for a javascriptJavaScript game.

JumpPadComponent attached to a couple of standard entities JumpPad component toggle:

JumpPad component toggle

Full source code can be found here:
   https://github.com/onedayitwillmake/ChuClone

Component based system for javascript game

Hi I'm creating a javascript/webgl based game and would like you guys to take a look at the current entity component system which I created for it. I've used it once before on another project, and while I was very happy with the results there were parts of it i did not feel 100% about.

In particular, sometimes a component needs to call the attachedEntities version of a function it has overridden. For example handleInput, it might call the attachedEntities handleInput functions and then with the new movementVector multiply them by negative 1 so now all input while this component is active is reversed.

When I intercept the properties, currently I wrap intercepted function calls into a closure (see basecomponent.intercept()) so that the 'this' object can refer to the component itself. Without that the 'this' object was still being referred to as the attachedEntity (from within the components version of that function), so to get the components properties I had to run a query.

Things I used as reference:
http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/ http://gameprogrammingpatterns.com/component.html
http://blog.bengarney.com/2010/06/12/composition-vs-inheritance/

** ENTITY SUPPORT FOR COMPONENTS **

I'm curious to get other's thoughts on this implementation of such a component based system for a javascript game.

JumpPadComponent attached to a couple of standard entities JumpPad component toggle

Full source code can be found here:
 https://github.com/onedayitwillmake/ChuClone

Component-based system for JavaScript game

I'm creating a JavaScript/WebGL based game and would like you all to take a look at the current entity component system which I created for it. I've used it once before on another project, and while I was very happy with the results, there were parts of it I did not feel 100% good about.

In particular, sometimes a component needs to call the attachedEntities version of a function it has overridden. For example handleInput might call the attachedEntities handleInput functions and then with the new movementVector multiply them by negative 1 so now all input while this component is active is reversed.

When I intercept the properties, I currently wrap intercepted function calls into a closure (see basecomponent.intercept()) so that the 'this' object can refer to the component itself. Without that the 'this' object was still being referred to as the attachedEntity (from within the components version of that function), so to get the components properties I had to run a query.

Things I've used as reference:
http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/ http://gameprogrammingpatterns.com/component.html
http://blog.bengarney.com/2010/06/12/composition-vs-inheritance/

Entity support for components

I'm curious about others' thoughts on this implementation of such a component-based system for a JavaScript game.

JumpPadComponent attached to a couple of standard entities:

JumpPad component toggle

Full source code can be found here:  https://github.com/onedayitwillmake/ChuClone

added 221 characters in body
Source Link
Loading
Forgot to add the entity portion of the system
Source Link
Loading
Forgot to add the entity portion of the system
Source Link
Loading
deleted 614 characters in body
Source Link
Loading
Source Link
Loading