This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Simple, colorful logging! | |
Setup | |
===== | |
Somewhere really early in your code do a: | |
Log.init(); | |
This will setup the logger methods and coloring stuff. | |
Logging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function test() | |
{ | |
var myBigObject = {}; | |
setTimeout( function() | |
{ | |
console.log('' + myBigObject); | |
}, 1000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var list = new gamecore.LinkedList(); | |
list.add(gunship); | |
var next = list.first(); | |
while( next ) | |
{ | |
next.obj.draw( ... ); | |
next = next.nextLinked; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// derive from gamecore.Pooled, instead of gamecore.Base | |
var Fighter = gamecore.Pooled.extend('Fighter', | |
{ | |
create: function(hp) | |
{ | |
var n = this._super(); // acquire from the pool | |
n.hp = hp; // (re)setup the object instance | |
return n; | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// inherit from the fighter class | |
var HeavyFighter = Fighter.extend('HeavyFighter', | |
{ | |
// override the (static) firing delay (rapid fire) | |
firingSpeed: 300 | |
}, | |
{ }); | |
var heavyGunship = new HeavyFighter(500); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Fighter = gamecore.Base.extend('Fighter', | |
{ | |
// static (this is inherited as well) | |
firingSpeed: 1000 | |
}, | |
{ | |
// instance | |
hp: 0, | |
init: function(hp) // instance constructor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// check to see if the bullet needs to go away | |
if (bullet.collidesWith(wall)) | |
bullet.release(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// construct a new bullet | |
var newBullet = Bullet.create(10, 10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bullet = gamecore.Pooled('Bullet', | |
{ | |
// Statics | |
// factory constructor -- a static function | |
create: function(x, y) | |
{ | |
// sweet static inheritance that comes with gamecore.class | |
var newBullet = this._super(); | |
newBullet.x = x; | |
newBullet.y = y; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var newBullet = Bullet(10, 10); |