- Download and install Node.js and npm (comes with Node.js)
- Download this code
- Change to the directory where the source code is (with a terminal)
- Type
npm install
to install module dependencies - Edit
app.js
and edit the "settings" section - Run the app by typing
node app.js
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 Victor = require('victor'); | |
var raf = require('raf'); | |
require('mouse'); | |
var canvas = document.createElement('canvas'); | |
var ctx = canvas.getContext('2d'); | |
ctx.font = '10px sans-serif'; | |
var v1 = new Victor(200, 200); | |
var v2 = new Victor(350, 350); |
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 Promise = require('promise'); | |
var domify = require('domify'); | |
var insertCSS = require('insert-css'); | |
var stage = domify('<div class="stage"><div class="light"></div><div class="road"><div class="crossing"><div></div><div></div><div></div><div></div><div></div></div></div></div>'); | |
var pedestrians = []; | |
var whenGreen = new Promise(function(resolve) { | |
setTimeout(function () { | |
stage.classList.add('green'); | |
resolve(); |
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 whenthen = require('whenthen'); | |
var domify = require('domify'); | |
var insertCSS = require('insert-css'); | |
var stage = domify('<div class="stage"><div class="light"></div><div class="road"><div class="crossing"><div></div><div></div><div></div><div></div><div></div></div></div></div>'); | |
var pedestrians = []; | |
var whenGreen = whenthen(function (resolve) { | |
setTimeout(function () { | |
stage.classList.add('green'); | |
resolve(); |
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 Writable = require('readable-stream/writable'), | |
Readable = require('readable-stream/readable'), | |
QueryStream = require('querystream'); | |
// Some sample data | |
var sampleData = [ | |
{ x : 10, y : 200 }, | |
{ x : 20, y : 190 }, | |
{ x : 30, y : 180 }, | |
{ x : 40, y : 170 }, |
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 ready = require('./ready'); | |
var cdCache = {}; | |
function getDiskData (discId) { | |
cdCache[discId] = cdCache[discId] || ready(function (done) { | |
setTimeout(function () { | |
done(Math.random()); | |
}, 2000); | |
}); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>CodePen · A Pen by maxkueng</title> | |
<!-- | |
Copyright (c) 2012 Max Kueng, http://codepen.io/maxkueng | |
Permission is hereby granted, free of charge, to any person obtaining |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>CodePen · A Pen by maxkueng</title> | |
<!-- | |
Copyright (c) 2012 Max Kueng, http://codepen.io/maxkueng | |
Permission is hereby granted, free of charge, to any person obtaining |
NewerOlder