Created
November 27, 2019 18:36
-
-
Save 0x6d61/6b2baf87662ef18d22293fb243d9e682 to your computer and use it in GitHub Desktop.
CLIで┌(┌^o^)┐を動かすJavaScript
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
'use strict' | |
const sleep = require('sleep') | |
const homo = '┌(┌^o^)┐' | |
const homoleft = '┌(^o^┐)┐' | |
const rightMoveHomo = move => { | |
for( let i = 0;i<move;i++) { | |
console.log(`\x1b[${i}G${homo}`) | |
sleep.msleep(50) | |
console.log("\x1b[H\x1b[J") | |
} | |
} | |
const bottomMoveHomo = move => { | |
for(let i = 0;i<move;i++) { | |
console.log(`\x1b[${i};${move}H${homo}`) | |
sleep.msleep(25) | |
console.log("\x1b[H\x1b[J") | |
} | |
} | |
const leftMoveHome = move => { | |
for(let i = move;i>0;i--) { | |
console.log(`\x1b[${move};${i}H${homoleft}`) | |
sleep.msleep(50) | |
console.log("\x1b[H\x1b[J") | |
} | |
} | |
const topMoveHomo = move => { | |
for(let i = move;i > 0;i--) { | |
console.log(`\x1b[${i};0H${homoleft}`) | |
sleep.msleep(25) | |
console.log("\x1b[H\x1b[J") | |
} | |
} | |
const main = move => { | |
while(1) { | |
rightMoveHomo(move) | |
bottomMoveHomo(move) | |
leftMoveHome(move) | |
topMoveHomo(move) | |
} | |
} | |
main(40) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment