Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@InternetExplorer
InternetExplorer / scoreboardProjection.example.js
Created April 2, 2012 22:11
Justafriend.ie - Scoreboard Projection Example
function scoreboardProjection(frame_offset) {
if (frame_offset == null) frame_offset = 0;
var canvas, proj;
var score_img_1,
score_img_2,
overlay,
board_canvas,
score_canvas_1,
score_canvas_2;
@InternetExplorer
InternetExplorer / currentFrameFromTimecode.example.js
Created April 2, 2012 22:14
Justafriend.ie - Current Frame from Timecode Example
function getCurrentFrameFromTimecode() {
frame_canvas_ctx.drawImage(video, 961, 0, 1, 16, 0, 0, 1, 16);
var timeBitmap = frame_canvas_ctx.getImageData(0, 0, 1, 16);
var timeData = timeBitmap.data;
var frame = 0;
var value;
for (var i = timeData.length - 1; i >= 0; i -= 4) {
value = (timeData[i - 3] + timeData[i - 2]
+ timeData[i - 1]) > 125 ? 1 : 0;
if (Math.floor(i / 4) == 15) {
@InternetExplorer
InternetExplorer / otterDestruction.example.js
Created April 3, 2012 14:50
Marshmallow People Game - Otter Destruction Example Code
// Otter destruction
// An example of how Underscore.js and Impact make it easy to destroy
// all the enemies on-screen with a giant otter
destroyEverthing: function() {
// Grab all active enemies
_.each(ig.game.getAllEnemies(), function(e){
// Check if an enemy is on screen
if(e.isOnScreen) {
@InternetExplorer
InternetExplorer / draw.example.js
Created April 3, 2012 14:54
Linking Impact and EaselJS Drawing
// Impact's main draw function in the main game file
draw: function() {
// Clear out the main canvas since Easel will have drawn things that Impact doesn’t know about
var ctx = ig.system.context;
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.clearRect(0, 0, ig.system.width, ig.system.height);
// Call draw on the parent object to make sure that all draws to the canvas are finalized
// before telling Easel to update
@InternetExplorer
InternetExplorer / tick.example.js
Created April 3, 2012 14:55
Linking Impact and EaselJS "Tick" Functions
// Create the Easel Stage
this.stage = new Stage(this.canvas);
// Set the stage to not autoClear
// This keeps EaselJS from erasing all of what Impact has already drawn to canvas.
this.stage.autoClear = false;
// Update Easel in sync with Impact
tick: function() {
// Call Easel's update function to draw all of its queued changes