About
Whilst working on this pebbl rewrite I've been developing a system to help me sketch object structures in JavaScript, considering it seems to have worked quite well, I thought I'd write a bit about the power of describing what you want; rather than maybe actually having it perfect right away.
For me, there are two main issues with regard to getting anything developed. The first is normally the amount of time I have free to devote to the project—gone are the days where I had weeks and weeks to code and experiment—this in itself is the main cause of my second issue; which is to always make sure code can be easily remerged, revamped and made, basically, future-indifferent... all because by the time I've started to get anywhere, it's normally time to reassess available technologies again.
CURSE YOU PROGRESS!
The plan...
So the above are my main reasons for gravitating towards scripting languages, and those specifically that allow for greater sketching and expression -- like JavaScript, Python, Lisp -- because they allow me to move faster in this crazy world. However there is always room for improvement, and after having worked on a large number of projects over the last 13 years I've been slowly aggregating a list of all the features that I expect to have in my new projects:
- Constructors should be easily described in a standardised way.
- Constructors should support multiple inheritance.
- Constructors should support method overloading.
- Constructors should support a way to "categorise" methods, taking on the power of "tagging"
- Constructors should support the power of collections, like how jQuery can "select" multiple elements and apply methods as a group.
- The structure of constructors should be separate from their implementation.
- The system should tie into some kind of tearDown management.
- The system should be extendable and have future support for the new object methods i.e. getters, setters and proxies
So, with the above in mind I constructed a system that allowed me to describe what I wanted before I had actually implemented everything.
Sorry, the phrase "cargo bay doors" is not in my lexicon
I had already decided that I wanted method overloading despite the obvious drain on performance. But then I've never liked optimising when it detracts from development speed, and considering one of my most repeated tasks was writing headers for functions that could accept a gaggle of differing arguments (Is there a collective noun for arguments?), I wasn't about to let a few milliseconds get in the way of happier coding. Besides, compared to other faux-overloading implementations I've seen around, I thought this one had merit and was possibly a fast way of doing type-based overloading:
var Example = describe.make({
/// called when a new instance is created
'construct': function(){
},
/// called if passed an object and a number
'method [object,number]': function(obj,num){
return 1;
},
/// called if passed a function and a number
'method [function,number]': function(fun,num){
return 2;
},
/// called if passed a function and anything else
'method [function,*]': function(fun,any){
return 3;
}
});
var a = new Example();
a.method({},123); /// returns 1
a.method(function(){},123) /// returns 2
a.method(function(){},{}) /// returns 3
a.method() /// trips a console error
- useful note :- basically the system works by processing each 'method key' and creating a lookup hash object, keyed on the string of types. Then whenever a method is called the arguments are converted into their own string of types - using a mixture of duck typing, typeof and instanceof - which is then used to look the function up from the hash. I have yet to put some real optimisation work in yet, but it already seems to operate quick enough for my needs.
As the dangerously astute may notice, the above constructor design ticks quite a few of my requested features. The structure is kept separate from the actual constructor implementation (that happens behind the scenes and means it's readily changeable), the construction follows a standard, the method key containing type definitions allows me to very visibly build overloaded methods whilst still allowing for easy change of implementation later on—basically if JS2 is ever released ;)
2X4B
What the above design doesn't make obvious is that by using a framework to construct my constructors, I can easily tie in tearDown management (e.g. introduce a 'deconstruct' standard), plus I can extend how the method keys are parsed, for example another extra that comes with the describe system—in it's current form—is the following:
var Example2 = describe.make({
/// all methods are "public" by default, unless otherwise stated
'public publicMethod': function(){
},
/// "static" methods are added to the constructor instead
'static staticMethod': function(){
},
/// kept away from the public object so as to keep a clean interface
/// not truly private however - although is open to future support.
'private privateMethod': function(){
/// to call this method access the ._ attribute
this._.privateMethod();
},
});
var b = new Example2();
b.publicMethod(); /// all methods are "public" by default
p.privateMethod(); /// will be undefined so will trigger an error
Example2.staticMethod(); /// "static" adds to the constructor instead
Whilst many may frown at the very suggestion of needing to "parse" anything, especially strings, I can at least argue in my defence that this parsing only occurs at set-up time. Once the constructor has been built I try an minimise the amount of processing that occurs. Obviously if you are looking for blistering performance, you don't try and bend a language to do things it's not designed for. For my own piffling forays into the scripting world though, this system works, and that's all I'm bothered about.
Back to reality
Ok, before you reach for whatever your preferred social commenting medium is, I've already thought about the problem you're first thinking of... probably not the second or third, but hey.... The first thing I'm sure others may point out is that you can't rely on typeof in all situations—those who've tried type checking arrays will be well aware of JavaScript's fickleness when it comes to types. That's why, in the spirit of future-indifference, all the type checking is run through describe.type - a function that mainly relies on duck testing (faster in my opinion that type checking, I'm not a processor though, so my opinion probably doesn't count). By keeping this check as an exposed function it is in-keeping with extensibility and will allow anyone to override it's workings—if they like.
- useful note :- describe.type checks all objects for a .toDescribe() method. This operates just like .toString() save for the fact it should return the type of the object - rather than it's value - as a string. If this method exists describe.type will use it's returned value instead of calculating the value itself.
In fact I've tried to keep every part of describe exposed so that it's easy to override. All I want is the framework, filled out with code that I'm happy with. Others may still find the framework useful, but hate my implementation. Therefore they can override whatever they like, this also includes how the private, public and static handling is implemented. They need look no further that the describe.tags object:
describe.tags = {
'public': function( obj, data, workings ){
obj.prototype[data.name] = data.prop;
},
'private': function( obj, data, workings ){
if ( !obj.prototype._ ) {
obj.prototype._ = workings._ = {};
}
obj.prototype._[data.name] = data.prop;
},
'static': function( obj, data, workings ){
obj[data.name] = data.prop;
}
};
As you might have discerned from the above, all you need to invent a new method "tag" is to add it to this object. At the point of creating the constructor these tag methods are called on each method that is tagged, obj refers to the constructor, data is a simple collection that describes the method or property being added; workings is a private object that can be used between tag methods as the constructor is formulated. Put simply, this system really does allow for quite a lot of control over how your constructors are put together. For example, in one of my projects I've developed a new tag called 'on' which automatically bind's each method as an event handler to the new instance being created.
Download and documentation
Describe.js is still a work in progress. In the not-too-distant-future I hope to have the following merged into the codebase:
- Allow for instances to be easily be grouped together and manipulated simultaneously i.e. just like jQuery can wrap multiple elements.
- Better implementation of multiple inheritance - describe.make does currently support this, but I'm looking to improve the implementation.
- Re-implement support for optional arguments. I had this in a previous version, however it got removed in the last rewrite.
For the moment though, describe.js works. So, if you're interested, you may wish to know about a few other useful methods bundled into the 8Kb that currently makes up describe.min.js:
describe( object ) /* [string] */ describe( object, mode /* [number] */ ) /* [string] */ describe( object, options /* [object] */ ) /* [mixed] */ describe( object, options, mode ) /* [mixed] */ /** * describe() the core function is first and foremost a * type guessing function. Pass in an object and it'll try * and tell you what it is, in string form. Currently supports * the following: * * string, number, boolean, function * array, object * event, window, document, element * * jQuery objects are treated as arrays, but it would be easy * to create a version that explicitly reported 'jquery' * * describe() also supports subtle changes in mode. For example: * * describe([123]) /// returns 'array' * describe([123], describe.ARRAYS) /// returns '[number]' * describe([[123]], describe.ARRAYS) /// returns '[[number]]' * describe([[123]], describe.ARGS) /// returns '[array]' */
describe.make( descriptor /* [object] */ ) describe.make( extensions /* [array] */, descriptor /* [object] */ ) /** * describe.make() as shown above constructs constructors. * * describe.make() uses describe's power but wraps it in a * constructor/class-like object. The result is that it becomes * easy to describe class-like constructors that support method * overloading and 'method tagging' which allows you to create * methods with different abilities. * * describe.make() supports inheritance using the extensions * array. Just pass the constructors listed in an array that you * wish your new constructor to extend. I hope to rework this * implementation shortly, as it's not quite what I want atm. * * returns the a constructor method [function] */
describe.construct( constructor /* [function] */, arguments /* [array] */ ) /** * describe.construct() allows for the creation of new instances * of a constructor in a programmatical way, allowing for variable * arguments. * * returns a new instance of the constructor [object] */
describe.proxy( source /* [object] */, method /* [string] */, returnFunction /* [function] */, augmentFunction /* [function] */ ) /** * describe.proxy() returns a method that proxies a method * from the source object. You also have the option of * passing a function that can be used to modify the return * value (returnFunction), or passing a method that can * modify the way the proxy method is called (augmentFunction). * describe.proxy is used to power describe.borrow() * * returns the proxied method [function] */
describe.borrow( source /* [object] */, methods /* [array|string] */, returnFunction /* [function] */, augmentFunction /* [function] */, destination /* [object] */ ) /** * describe.borrow() allows a destination object to "borrow" * a method or methods from another source object. A simple * example would be to have a describe'd class borrow the * bind and unbind methods of jQuery. * * If no destination object is specified borrow works on the * current 'this' object. * * returns [undefined] */ describe.merge
describe.merge( source /* [function] */, additional /* [function] */ ) /** * describe.merge() is a relatively experimental idea at the * moment. It allows for a method to be merged with other * method(s). At the time of calling, all methods are fired. * currently it is only the original method's return-value that * gets returned, but in the future I may improve this to handle * a collection of return values at request. * * A simple usage example would be to late-bind an additional * function of code to a constructors 'construct' method. * * returns the merged [function] */
Example usage
Just to get the ball rolling, here is a quick example. This shows the use of namespacing to keep your describe configuration local to your code:
<script src="describe.min.js"></script>
<script>
(function(describe){
var MyConstructor = describe.make({
'construct': function(){},
'exampleMethod [string]': function(str){},
'exampleMethod [number]': function(num){},
'exampleMethod [object,array]': function(obj,arr){},
'exampleMethod [*]': function(anything){}
});
})(describe.namespaced('my_name'));
</script>
- Leave your comment • Category: Coding, JavaScript
- Share on Twitter, Facebook, Delicious, Digg, Reddit
It's rather unbelivable, but I've actually managed to make some headway on Pebbl during the Christmas festivities... Oh aaaaand a merry new year by the way! So in preparation of my birthday happening in a galaxy not too far away I'd though I'd actually put something up to show that I haven't been sitting on my hands, or at least not consistently.
Be warned this is just a code demo
Obviously it doesn't appear like much at the moment--I didn't want to give too much away--but the astute of you out there will notice a few things.
- There isn't a shred of the original code powering this demo page.
- There are many shreds of original ideas woven together and put to good use.
- The code has evolved and benefited from another year of on/off development.
- The game will still be JS/HTML5 powered.
- The hybridisation between canvas and the DOM is even more involved.
- It supports Box2D for it's physical interactions!
- It supports require.js for the asyncronous loading.
- The backend (that you don't see here yet) is powered by node.js.
- I've ripped out my previous 'class-like' system, burnt it, blended it, spread it on toast, stuck it to the ceiling... and brought it back from the edge of the cornicing in the form of describe.js
As I stated in a previous post, the idea of this rewrite is to try and pull things away from being purely canvas based. Mainly because I found that the canvas wasn't fast enough across all the devices I tested -- whereas the dom allowed for quite smooth and fast animation. This I've achieved whilst still leaving room to switch back to a full canvas render if the future processors of this world decide to get any faster... it's likely that they will.
So now the system operates at quite a few different levels:
- The Box2D Physics world powers most movement.
- For non-physics based animation jQuery dom manipulation is used.
- For key-frame based animation background images and spritesheets are used on dom elements
- For sprites that can benefit from cloning, canvas is used instead of DOM.
- For masked content, pixel and lighting effects, separate canvas elements are used like dom elements.
- Everything is tied into jQuery's bespoke event system.
- With a few homemade jQuery plugins Sprites can be grouped and controlled via CSS selectors.
- Where possible I will try and use the up and coming CSS filters to achive effects in the game, and possibly fall back to SVG effects in older versions of FireFox.
- All sprites support controller objects that can be user, animation or bot controlled.
All I have left now is to rework the Map loading code so that pages can be loaded (just like in the original demo, by walking off screen) and then tie in the backend Node.js code so that a user can have an account and their progress can be logged. All in all 2012 was quite a good year ;)
It's a similar pattern that arises in many programming languages - the need for a function to accept differing structures of arguments - and is the reason why certain languages have built-in support for this behaviour, with the use of functional overloading.
In JavaScript however, no such ability exists - and with each of my pure js projects over the last 4 or 5 years, I kept getting rather bored with writing and rewriting the same kind of checks at the top of a function to handle a range of different ways the entity could be called.
So I've been playing with a solution to this idea for a while, but each of my implementations always felt like over coding the issue. JavaScript should be light, quick and powerful - most of what I came up with wasn't.
However, having reached the same situation for the umpteenth time. I finally threw together a solution that seems to be exactly what I've needed, so far at least, and is a lot simpler than previous versions:
var describe = (function(){
var describe = function( obj, opt, mod, looped ){
var m,i,s,t = describe.type(obj), w = describe.type(opt);
if ( w === 'number' || w === 'array' ) {
mod = opt; w = opt = null;
}
if ( describe.type( mod ) == 'number' ) {
m = mod
}
else {
m = describe.TYPES
};
if ( (t === 'array') && (!looped || m & describe.ARRAYS) ) {
s = '';
for ( i in obj ) {
if ( obj.hasOwnProperty && !obj.hasOwnProperty(i) ) {continue;};
s += (s?',':'')
+ describe(obj[i], mod && mod[i] ? mod[i] : m, null, true);
}
t = '['+s+']';
m = null;
}
if ( w === 'object' ) {
if ( opt[t] ) {
opt[t].apply(describe,obj);
}
else if (opt['*']) {
opt['*'].apply(describe,obj);
}
}
else if ( m ) {
s = '';
if ( m & describe.VALUES ) {
s += String(obj);
}
else {
s += (s?':':'') + t;
}
t = s;
}
return t;
}
describe.TYPES = 1;
describe.VALUES = 2;
describe.ARRAYS = 4;
describe.type = function(obj,t){
if (
(t = typeof obj) &&
t === 'string' ||
t === 'number' ||
t === 'boolean' ||
t === 'function' ) {
/// ILB
}
else if ( t == 'undefined' || obj === null ) {
t = 'null';
}
else if(
(t == 'array') ||
(window.Array && obj instanceof Array) ||
(obj.join && obj.slice && obj.unshift) ||
(obj[0] && obj.length) ||
(window.jQuery && obj instanceof jQuery)
){
t = 'array';
}
else if (
(obj.call && obj.apply) ||
(window.Function && obj instanceof Function)
){
t = 'function';
}
else if ( obj.location && obj.open ){
t = 'window';
}
else if ( obj.getElementById ){
t = 'document';
}
else if ( obj.getElementsByTagName ){
t = 'element';
}
return t;
}
return describe;
})();
The idea is a simple one, which could (and will) be improved over time. It's based mainly on type checking, but it can also handle value checking. A basic implementation would be as follows:
var my_function_to_call = function(a,b,c,d){
describe(arguments,{
'[object,object]':function(a,b){
/// do what you need to set-up if you get two objects
},
'[string,object,number]':function(a,b,c){
/// do what you need to set-up given a string, object and a number
}
'*':function(a,b){
/// fallback for anything else
}
});
}
The above makes for much easier reading, and even though this example does create and destroy several temporary functions with each my_function_to_call() -- for most of my core functions that might only get called once or twice it works very well. Obviously you could optimise by keeping your second parameter for describe defined outside of my_function_to_call, but if you are really looking for optimal high-frequency code you should be using the standard js methods of type checking.
A few other ways the code can be used:
var test = function(name, step){
describe(arguments,{
'[helloworld:string,123:number]':function(a,b){
/// do something when specific values and types are passed
},
}, describe.VALUES | describe.TYPES);
describe(arguments,{
'[helloworld,123]':function(a,b){
/// do something when specific values are passed
},
}, describe.VALUES);
describe(arguments,{
'[helloworld,number]':function(a,b){
/// do something when a specific value and specific type is passed
},
}, [describe.VALUES, describe.TYPES]);
}
test('helloworld', 10);
The astute readers out there will notice that this function basically just describes whatever object is passed into it, in simple terms. The secondary parameter is a bonus, as it allows the generated descriptive string to be checked against an object of methods. So you can use the above function just to aid in type checking:
if ( describe(param) == 'array' ) {
/// do something with an array - the code uses a duck test
/// so if something quacks like an array - i.e. jQuery it'll
/// be called an array. I do have another version of this code
/// that is specifically designed to return jQuery for jQuery objs.
}
This is just a starting out point, but so far I like the way things are working, so I shall continue...
Below you will find a minimized version of the above code:
var describe=(function(){var a=function(b,c,d,e){var f,g,h,i=a.type(b),j=a.type(c);
if(j==="number"||j==="array"){d=c;j=c=null}if(a.type(d)=="number"){f=d}
else{f=a.TYPES}if(i==="array"&&(!e||f&a.ARRAYS)){h="";
for(g in b){if(b.hasOwnProperty&&!b.hasOwnProperty(g)){continue}
h+=(h?",":"")+a(b[g],d&&d[g]?d[g]:f,null,true)}i="["+h+"]";f=null}
if(j==="object"){if(c[i]){c[i].apply(a,b)}else if(c["*"]){c["*"].apply(a,b)}}
else if(f){h="";if(f&a.VALUES){h+=String(b)}else{h+=(h?":":"")+i}i=h}
return i};a.TYPES=1;a.VALUES=2;a.ARRAYS=4;a.type=function(a,b){
if((b=typeof a)&&b==="string"||b==="number"||b==="boolean"||b==="function"){}
else if(b=="undefined"||b===null){b="null"}
else if(b=="array"||window.Array&&a instanceof Array||
a.join&&a.slice&&a.unshift||a[0]&&a.length||
window.jQuery&&a instanceof jQuery){b="array"}
else if(a.call&&a.apply||window.Function&&a instanceof Function){b="function"}
else if(a.location&&a.open){b="window"}else if(a.getElementById){b="document"}
else if(a.getElementsByTagName){b="element"}return b};return a})();
- One comment • Category: Coding, JavaScript
- Share on Twitter, Facebook, Delicious, Digg, Reddit
Bug with PHPUnit_Extensions_SeleniumTestCase
by Developer @ pebbl.co.uk on Wednesday, 26 September 2012
Over the last few years I've been constantly surrounded by chatter with regard to Selenium, but had never been in a position to try it out. Yesterday that changed when Tate stated the need to have as near to continous integration as possible with the on-going enhancements to their core website.
So, this has led to lots of interesting learning and reading up on something that has - until now - only really been a buzzword for me :)
Unfortunately my first foray into this area led me straight to a rather annoying bug in a particular PHPUnit extension designed to integrate a PHP script with Selenium. Basically I set about doing what most coders would do when presented with an Object Orientated architecture, I attempted to extend PHPUnit_Extensions_SeleniumTestCase with my own functionality.
Initially everything seemed to work as expected... that is until one of my Selenium tests generated an error. Rather than a helpful error message, my script bugged out with the following unhelpful error:
Argument 5 passed to PHPUnit_Framework_Error::__construct() must be an instance of Exception, array given
On a closer look into the problem it seems that PHPUnit_Framework_Error.php has been upgraded, however the code in PHPUnit_Extensions_SeleniumTestCase.php hasn't.
class PHPUnit_Framework_Error extends Exception
{
/**
* Constructor.
*
* @param string $message
* @param integer $code
* @param string $file
* @param integer $line
* @param Exception $previous
*/
public function __construct($message,
$code,
$file,
$line,
Exception $previous = NULL)
{
parent::__construct($message, $code, $previous);
$this->file = $file;
$this->line = $line;
}
}
The fifth argument has been changed to expect an Exception object, whereas, whenever a new PHPUnit_Framework_Error is called into existence from PHPUnit_SeleniumTestCase.php, you get:
throw new PHPUnit_Framework_Error($buffer,
$e->getCode(),
$e->getFile(),
$e->getLine(),
$e->getTrace());
The last parameter is incorrect, it should be:
throw new PHPUnit_Framework_Error($buffer,
$e->getCode(),
$e->getFile(),
$e->getLine(),
$e);
Or at least changing it to the above fixes the issues I was experiencing, now my code warns about errors correctly. Just in case it's useful to anyone out there :)
Ok, so this isn't a tech post... I just felt the need to complain - please ignore me if you don't give a damn about the environment.
http://www.bbc.co.uk/news/uk-scotland-scotland-business-19708915
If you read the article above, it is written with the view that "isn't this great, a renewable source of energy that will be good for everyone!". But aren't renewables supposed to be produced and used with little or no negative impact to the environment?
From what I've read butanol (and ethanol) still burn producing quite a bit of CO2, true, they burn cleaner that typical petrol (gasoline), but they still produce gases that we are supposed to be cutting down on... and now they've found a never ending way to produce a fuel that pollutes in this way. A fuel that will run on existing car systems, so there will be no reason for peope to change their habits or invest in better alternatives (i.e. hydrogen fuel cells).
How is that good news?
Actually, whether this is good news or not is probably all down to how Tullibardine was already "disposing" of it's by-products... If they were just chucking them into a never-ending bonfire then not much is lost.
I guess we don't really believe in all this CO2 "nonsense" after all, do we...?
It's been a while since I last uttered a word on this here platform. Just so you know, I haven't given up... and I am still working away at Pebbl behind the scenes of this rather lacking yet odd demo site.
On another note though - outside of Pebbl world - I've been focusing quite a bit again on good ol' PHP... I'd manage to escape real PHP work for a little bit, but now it is back with 'a vengeance' and is involving me in all sorts of situations where I need to search through large structures to find small bits of information... Small bits of information that could be anywhere (long story).
To save myself a lot of manual labour - something which computers are supposed to help with - I came up with a nice little function to help me out, hence the reason for the post, and the reason for the Pastie link below:
http://pastie.org/4694918 (found a bug! fixed in the next link)
Yes, it is true... and no I haven't converted Pebbl from a JavaScript game in to a bespoke CMS platform or anything mad... Instead I've decided to modify my Canvas Theory library so that it no longer uses Canvas as it's primary rendering system. Now this might seem a little bit illogical for something that started out as a Canvas & HTML5 experiment, but trust me I know what I'm doing ;) The new off-shoot library will be known as SpriteTheory.
Reasons?
Why? you may ask... well actually you most probably wont, but considering Blogs are a bit pointless if there is no need for explanation I'll ignore that statistical likelihood. The main reason for the change is purely due to optimisation, and also so I can prove wrong those out there who deem Flash (and it's contemporaries) to be extinct.
Most coders who claim Flash to be a dead parrot, and that HTML5 is the saving grace of all, have not tried to recreate what is achievable with Flash in HTML5. They have most probably just bundled together a nice slideshow and said "Hey... what was it we needed Flash for again?"... worryingly, some may not have even got that far and prefer to just mimic statements made by others. The fact of the matter is that Flash does a hell of a lot more that what is possible with pure HTML5 & JS - and it does it a hell of a lot faster. But anyways, before I start going off on one, I'll get to the point. I am not pro any particular technology, I just state what is and isn't possible at the moment (that may change of course). What seems not to be acceptably possible currently is to get good performance when running a sprite system using a full-screen canvas element across all the top browsers.
Excuses...
What...? I hear the non-existent critics expel in chorus. Not fast enough? But what about all the game emulators out on the web... or the 3D demos? Well, it seems that nearly all the emulators I've seen operate on a pixel by pixel basis (or small sprites) and usually on canvas elements with dimensions of about 320x200... tiny. This is not what I wanted for Pebbl, I wanted the full area of the browser to be in-use. And well, any 3D environment I've come across using Canvas is either hardware excelerated (using 3D context) or put together in a very specific and limited way... I wanted Pebbl to be 2D and not limited at all.
After spending some time developing a Canvas specific library, I found that no matter how optimal my code was, the clearRect and drawImage methods of the Canvas Element were taking most of the rendering time. So no matter how good I was with my code, I'd still always be limited by something I couldn't alter. As I said before this may change in the future, we shall see. But after finding this out, and making sure I was using my own "only draw what's needed" and "only clear what's changed" system, I was still finding slow-down after implementing less than half of what I wanted to. I was also finding that the frame-rate was wildly different across each browser. This was not good enough, plus it also seemed a bit pointless, when browsers implement their own redraw system anyway.
Conclusions...
So, after a bit of kicking myself for trying to re-invent the wheel and not going for the more elegant solution in the first place, my new library now works based on old-school absolutely positioned HTML Elements with CSS Transformations and Canvas enhancements. The Sprite interface is nearly almost the same, so I shouldn't have to do to much rewriting, all I have to do is dump most of the Canvas draw stuff, and optimise for dealing with HTML Elements instead. No more redraw problems, or slow-down. My main reason for going down the Canvas route in the first place was because I wanted to have pixel-perfect collisions and pixel affects. Considering most browsers handle the creation of many small Canvas elements with ease, and allow these Elements to be treated like any old DIV Element, I don't need to use a full Canvas "Stage" as-it-were and can instead treat each Sprite that needs the advanced methods as a separate Canvas element.
- Leave your comment • Category: Coding, Game Dev, JavaScript
- Share on Twitter, Facebook, Delicious, Digg, Reddit