This repository has been archived by the owner on Jul 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·45 lines (33 loc) · 2.6 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict'
class Animate {
constructor(animation) {
if (!animation) {
animation = [" __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)=\n \\_~_)\n", " __(o)<\n \\_~_)\n", " __(o)<\n \\_~_)\n", " __(o)<\n \\_~_)\n", " >(o)\n /( )\\\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", " =(o)__\n (_~_/\n", "=(o)__\n (_~_/\n", "=(o)__\n (_~_/\n", "=(o)__\n (_~_/\n", ">(o)__\n (_~_/\n", ">(o)__\n (_~_/\n", " (o)=\n/( )\\\n"]
}
this.animation = animation
this.start()
}
start() {
this.animate(this.animation, 0)
}
animate(animation, frame) {
if (!frame) frame = 0
this.animation = animation
this.next(frame)
}
next(frame) {
let sprite = this.animation[frame]
frame = ((this.animation.length - 1) === frame) ? 0 : (frame + 1)
setTimeout(() => {
this.clear()
this.display(sprite)
this.next(frame)
}, 100)
}
display(sprite) {
console.log(sprite)
}
clear() {
console.log('\x1B[2J\x1B[0f\x1B[3J')
}
}