update: bouncing ball exercise only uses the screen package

This commit is contained in:
Inanc Gumus
2020-11-26 16:29:13 +03:00
parent 6f8e099d39
commit b48a7c538a
2 changed files with 12 additions and 50 deletions

View File

@ -10,13 +10,11 @@ package main
import (
"fmt"
"os"
"time"
"github.com/mattn/go-runewidth"
"github.com/inancgumus/screen"
"golang.org/x/crypto/ssh/terminal"
)
func main() {
@ -35,15 +33,8 @@ func main() {
cell rune // current cell (for caching)
)
// get the width and height
width, height, err := terminal.GetSize(int(os.Stdout.Fd()))
if err != nil {
fmt.Println(err)
return
}
// you can get the width and height using the screen package easily:
// width, height := screen.Size()
width, height := screen.Size()
// get the rune width of the ball emoji
ballWidth := runewidth.RuneWidth(cellBall)