summaryrefslogtreecommitdiffstats
path: root/pongo.go
diff options
context:
space:
mode:
Diffstat (limited to 'pongo.go')
-rw-r--r--pongo.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/pongo.go b/pongo.go
index 2a68a0d..01c6a8d 100644
--- a/pongo.go
+++ b/pongo.go
@@ -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)
}
}