Пример #1
0
package main

import (
	flag "github.com/neeee/pflag"
	"github.com/neeee/termbox-go"
	"math/rand"
	"time"
)

var d = flag.DurationP("duration", "d", 0, "sleepy time")

func ch() rune {
	if rand.Int31n(2) == 0 {
		return '╱'
	}
	return '╲'
}

func mod(x int, y int) int {
	if x < 0 {
		return x + y
	}
	return x % y
}

type pair struct{ x, y int }

var dirs = [9]pair{
	{1, 1}, {-1, -1},
	{1, -1}, {-1, 1},
	{1, 0}, {-1, 0},
Пример #2
0
package main

import (
	"math/rand"
	"time"

	flag "github.com/neeee/pflag"
	"github.com/neeee/termbox-go"
)

const bg = termbox.ColorDefault

var (
	in = flag.IntP("intensity", "i", 65,
		"intensity on randomly chosen spots at the bottom")
	d = flag.DurationP("delay", "d",
		time.Millisecond*30, "set lower to go faster")
	dim = flag.Bool("dim", false, "don't use bold")
)

var timeoutc = make(chan struct{})

func ticker(ch chan struct{}) {
	for {
		time.Sleep(*d)
		ch <- struct{}{}
	}
}

func min(x, y int) int {
	if x > y {
		return y