Last active
October 4, 2016 10:10
-
-
Save kdxu/5eaaa6351cfb8811f5d1f0957a6e5b64 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env node | |
var optimist = require('optimist'); | |
var fs = require('fs'); | |
var path = require('path'); | |
var blessed = require('blessed'); | |
function run () { | |
var frames = getFrames(); | |
var screen = blessed.screen(); | |
play(screen, frames); | |
} | |
function getFrames (dir) { | |
var dir = __dirname + '/bombs'; | |
var files = fs.readdirSync(dir), | |
out = []; | |
files.forEach(function (file, i) { | |
if (file.substr(0, 1) === '.') { | |
return files.splice(i, 1); | |
} | |
out.push(fs.readFileSync(path.resolve(dir, file), 'utf8')); | |
}); | |
return out; | |
} | |
function play(screen, frames) { | |
var size = { width: 10, height: 10 }; | |
box = blessed.box({ | |
top: 'center', | |
left: 'center', | |
width: size.width, | |
height: size.height | |
}), | |
cur = 0; | |
screen.append(box); | |
setInterval(function () { | |
if (cur == frames.length) process.exit(); | |
box.setContent(frames[cur]); | |
screen.render(); | |
cur += 1; | |
}, 100); | |
} | |
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment