~rockorager/snowflake-term

c07ca3cf0ffb9d272a3fbe72b79b75461b3a064a — Tim Culverhouse 5 months ago 119555c
add cli args: -n and -speed

Both accept an int. n is the number of flakes

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
1 files changed, 14 insertions(+), 14 deletions(-)

M main.go
M main.go => main.go +14 -14
@@ 1,6 1,7 @@
package main

import (
	"flag"
	"math/rand"
	"os"
	"os/exec"


@@ 11,6 12,14 @@ import (
)

func main() {
	var (
		flakes int
		speed  int
	)
	flag.IntVar(&flakes, "n", 10, "number of flakes")
	flag.IntVar(&speed, "speed", 100, "speed of the flakes")
	flag.Parse()

	vx, err := vaxis.New(vaxis.Options{})
	if err != nil {
		panic(err)


@@ 28,22 37,13 @@ func main() {

	width := vx.Window().Width

	snowflakes := []*snowflake{
		newSnowflake(width),
		newSnowflake(width),
		newSnowflake(width),
		newSnowflake(width),
		newSnowflake(width),
		newSnowflake(width),
		newSnowflake(width),
		newSnowflake(width),
		newSnowflake(width),
		newSnowflake(width),
		newSnowflake(width),
		newSnowflake(width),
	snowflakes := []*snowflake{}
	for i := 0; i < flakes; i += 1 {
		snowflakes = append(snowflakes, newSnowflake(width))
	}

	ticker := time.NewTicker(50 * time.Millisecond)
	dur := time.Duration((100 * 50) / speed)
	ticker := time.NewTicker(dur * time.Millisecond)
	events := vx.Events()
	for {
		w, h := vx.Window().Size()