Skip to main content

Posts

Showing posts from September, 2011

0x0002 Dev Diaries - JS Privates

A little experiment / toy I have, which I might use to keep some decoupling attempts straight. Using this, I'll be able to allow the various components to maintain properties on other objects they work with, safely, without interfering with one another. For example, I have a Draggable behavior that can be enabled in a scene and allows objects in the scene to be, obviously, draggable. During this use, the behavior code may often need to set properties on the objects to track dragging state, but needs to do so without interfering with other behaviors setting properties of their own, even other instances of the same behavior. This simple utility enables this. privates(this, entity).dragPath = []; privates(this, entity).dragPath.push(curPos); ... drawPath(privates(this, entity).dragPath); The concept this is trying to express is that the first object owns a set of private properties attached to the second object, and this works much like private attributes in many langua
New post on my game development progress. I've been tinkering on a small Javascript and Canvas engine for the last few weeks, and I'm mostly happy with the results, if not as happy with the progress. Still, it has been steady, so I'll focus on being happy for that part.  I'm starting to split the codebase into two parts: a javascript utility library, very similar to backbone.js, and the game engine on top of it. Read the full post