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
// 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 |
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
// 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 |
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
// 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) { |
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 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) { |
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 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; |