Skip to content

Instantly share code, notes, and snippets.

@rlemon
Created December 21, 2018 16:30
Show Gist options
  • Save rlemon/3cba9ac9116b6f3dbb91270438f2ba2d to your computer and use it in GitHub Desktop.
Save rlemon/3cba9ac9116b6f3dbb91270438f2ba2d to your computer and use it in GitHub Desktop.
ascii starwars. data from https://www.asciimation.co.nz/
/* eslint-disable */
import filmData from './filmData';
const devTools = /./;
devTools.toString = function() {
this.opened = true;
};
const linesPerFrame = 14;
const timeoutBase = 100;
let currentFrame = 0;
function renderFrame() {
console.log( '%c', devTools ); // test for dev tools.
if( !devTools.opened ) {
return setTimeout( renderFrame, 1000 );
} else {
devTools.opened = false;
}
console.clear();
let str = '';
let timeout = timeoutBase;
for( let i = 0; i < linesPerFrame; i++ ) {
const index = ( linesPerFrame * currentFrame ) + i;
if( !i ) { // first line is the delay modifier
timeout *= parseInt( filmData[index], 10 );
continue;
}
str += filmData[index] + '\n';
}
console.log( '%s', str );
currentFrame += 1;
setTimeout( renderFrame, timeout );
}
renderFrame();
This file has been truncated, but you can view the full file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment