2021-12-12 02:12:56 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-02-12 02:12:00 +03:00
|
|
|
"log"
|
2021-12-12 02:12:56 +03:00
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
|
2022-02-12 02:12:00 +03:00
|
|
|
ui "github.com/gizak/termui/v3"
|
|
|
|
"github.com/gizak/termui/v3/widgets"
|
|
|
|
"morozovad.ddns.net/lnd212/go-roflcopter/roflcopter"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
count time.Duration = 0
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
frame1 = " ROFL:ROFL: \n _^____ \n L __/ [] \\ \n O ===__ \\ \n L \\________] \n I I \n --------/ \n"
|
|
|
|
frame2 = " :ROFL:ROFL\n _^____ \n __/ [] \\ \nLOL===__ \\ \n \\________] \n I I \n --------/ \n"
|
2021-12-12 02:12:56 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
|
2022-02-12 02:12:00 +03:00
|
|
|
func copter(delay time.Duration) {
|
|
|
|
if err := ui.Init(); err != nil {
|
|
|
|
log.Fatalf("failed to initialize termui: %v", err)
|
|
|
|
}
|
|
|
|
defer ui.Close()
|
|
|
|
|
|
|
|
p := widgets.NewParagraph()
|
|
|
|
p.Text = frame1
|
|
|
|
p.SetRect(0, 0, 25, 10)
|
|
|
|
|
|
|
|
ui.Render(p)
|
|
|
|
nextframe := 2
|
|
|
|
|
|
|
|
count = 15 * time.Second
|
|
|
|
go timecounter(1 * time.Second)
|
|
|
|
|
|
|
|
for {
|
|
|
|
switch nextframe {
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
p.Text = frame1 + count.String()
|
|
|
|
ui.Render(p)
|
|
|
|
time.Sleep(delay * time.Millisecond)
|
|
|
|
nextframe = 2
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
p.Text = frame2 + count.String()
|
|
|
|
ui.Render(p)
|
|
|
|
time.Sleep(delay * time.Millisecond)
|
|
|
|
nextframe = 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func timecounter(step time.Duration) {
|
|
|
|
for count > 0 {
|
|
|
|
count -= step
|
|
|
|
time.Sleep(step)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func player() {
|
|
|
|
roflcopter.Sound(&wg, false)
|
2021-12-12 02:12:56 +03:00
|
|
|
wg.Wait()
|
|
|
|
player()
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2022-02-12 02:12:00 +03:00
|
|
|
//fmt.Println("HW")
|
|
|
|
//roflcopter.Sound(&wg, false)
|
2021-12-12 02:12:56 +03:00
|
|
|
go player()
|
2022-02-12 02:12:00 +03:00
|
|
|
go copter(120)
|
|
|
|
time.Sleep(15 * time.Second)
|
2021-12-12 02:12:56 +03:00
|
|
|
}
|