move: bouncing ball
This commit is contained in:
@ -9,11 +9,9 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/inancgumus/screen"
|
"github.com/inancgumus/screen"
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -26,12 +24,9 @@ func main() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// get the width and height of the terminal dynamically ***
|
// get the width and height of the terminal dynamically ***
|
||||||
width, height, err := terminal.GetSize(int(os.Stdout.Fd()))
|
width, height := screen.Size()
|
||||||
if err != nil {
|
|
||||||
fmt.Println("cannot get width and height", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
width /= 2 // our emoji is 2 chars wide
|
width /= 2 // our emoji is 2 chars wide
|
||||||
|
height-- // for the border
|
||||||
|
|
||||||
var (
|
var (
|
||||||
px, py int // ball position
|
px, py int // ball position
|
Reference in New Issue
Block a user