This file contains hidden or 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
// A weird bug when you inherit from a constructor. You shouldn't | |
// inherit from a constructor but when I accidentally did I noticed | |
// this weirdness. | |
function Foo() {} | |
// this should be Object.prototype, or {}, or omitted completely, | |
// but certainly not the Object constructor. Still, what follows | |
// isn't exactly what you'd expect... | |
Foo.prototype = Object; |
This file contains hidden or 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 Parent() {} | |
var parent = new Parent(); | |
function Child() {} | |
Child.prototype = parent; | |
var child = new Child(); | |
// child inherits directly from parent. this makes sense. | |
console.log(child.__proto__ === parent); // true | |
console.log(child.__proto__ === Parent.prototype); // false |
This file contains hidden or 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
// Code from http://lib.ivank.net/?p=demos&d=box2D | |
// These look like imports, but in JavaScript they are just busy-work. | |
var | |
b2Vec2 = Box2D.Common.Math.b2Vec2, | |
b2BodyDef = Box2D.Dynamics.b2BodyDef, | |
b2Body = Box2D.Dynamics.b2Body, | |
b2FixtureDef = Box2D.Dynamics.b2FixtureDef, | |
b2World = Box2D.Dynamics.b2World, | |
b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape; |
This file contains hidden or 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
<dict> | |
<key>name</key> | |
<string>Git Modified Line</string> | |
<key>scope</key> | |
<string>git.changes.x</string> | |
<key>settings</key> | |
<dict> | |
<key>background</key> | |
<string>#212340</string> | |
</dict> |
This file contains hidden or 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
<head> | |
... | |
<!-- source files for development --> | |
<!-- <script src="src/setup.js"></script> --> | |
<!-- <script src="src/player.js"></script> --> | |
<!-- <script src="src/enemy.js"></script> --> | |
<!-- <script src="src/bullet.js"></script> --> | |
<!-- <script src="src/explosion.js"></script> --> | |
<!-- concatenated / minified source for production --> |
This file contains hidden or 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 state = [{ | |
id: 0, | |
transform: { | |
position: { | |
x: 15.290663048624992, | |
y: 2.0000000004989023, | |
z: -24.90756910131313 | |
}, | |
rotation: { | |
x: 0.32514392007855847, |
This file contains hidden or 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 char = new Int8Array( 1 ); | |
// uchar now shares the same ArrayBuffer as char. | |
var uchar = new Uint8Array( char.buffer ); | |
char.buffer === uchar.buffer; // true | |
char[0] = -1; | |
uchar[0] === 255; // true, same data interpreted differently | |
var arr = new Float64Array([15.290663048624992]); |
This file contains hidden or 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
// Compact the state. | |
var slimmerState = new Float64Array([ | |
0, | |
15.290663048624992, | |
2.0000000004989023, | |
-24.90756910131313, | |
0.32514392007855847, | |
-0.8798439564294107, | |
0.32514392007855847, | |
0.12015604357058937, |
This file contains hidden or 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 encodeUint8 = (function() { | |
var arr = new Uint8Array( 1 ); | |
return function( number ) { | |
// If we assume that the number passed in | |
// valid, we can just use it directly. | |
// return String.fromCharCode( number ); | |
arr[0] = number; | |
return String.fromCharCode( arr[0] ); | |
}; | |
}()); |
This file contains hidden or 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
// Shared code | |
var MsgType = { | |
"game start": String.fromCharCode(0), | |
"update state": String.fromCharCode(1), | |
"private message": String.fromCharCode(2) | |
}; | |
var MsgTypeLookup = [ | |
"game start", | |
"update state", |
OlderNewer