diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2024-08-26 21:09:12 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2024-08-26 21:09:12 -0700 |
| commit | fe1b9cb708f03d8a78760be698d0f127f196c99e (patch) | |
| tree | b06f5f4ad9861c868141286e1edb286292bcc216 /pongo.go | |
| parent | 1a386dc5ff5cf88182e930d19965dda2692551dc (diff) | |
| download | pongo-fe1b9cb708f03d8a78760be698d0f127f196c99e.tar.zst | |
Handle some more errors.
Diffstat (limited to 'pongo.go')
| -rw-r--r-- | pongo.go | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -195,7 +195,9 @@ func pong() error { ball.pos = ball.pos.add(ball.velocity) switch { case ball.bounds().HasIntersection(paddle1.bounds()) && ball.velocity.x <= 0: - ping.Play(-1, 0) + if _, err := ping.Play(-1, 0); err != nil { + fmt.Fprintln(os.Stderr, err) + } d := ball.pos.y - paddle1.pos if d < 0 { d = -d @@ -207,7 +209,9 @@ func pong() error { speed := ballSpeed * (1 + 4*d/(float64(paddle1.bounds().H)/2+float64(ball.bounds().H))) ball.velocity = vector2{speed * math.Cos(angle), speed * math.Sin(angle)} case ball.bounds().HasIntersection(paddle2.bounds()) && ball.velocity.x >= 0: - ping.Play(-1, 0) + if _, err := ping.Play(-1, 0); err != nil { + fmt.Fprintln(os.Stderr, err) + } d := ball.pos.y - paddle2.pos if d < 0 { d = -d @@ -226,7 +230,9 @@ func pong() error { playerScore++ ball.reset(left) case ball.bounds().Y <= 0 && ball.velocity.y < 0 || rectBottom(ball.bounds()) >= screenHeight && ball.velocity.y > 0: - ping.Play(-1, 0) + if _, err := ping.Play(-1, 0); err != nil { + fmt.Fprintln(os.Stderr, err) + } ball.velocity.y = -ball.velocity.y } } @@ -272,5 +278,6 @@ func pong() error { func main() { if err := pong(); err != nil { fmt.Fprintln(os.Stderr, err) + os.Exit(1) } } |
