diff --git a/.gitignore b/.gitignore index 8683cf7..84a398b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ .idea/ .DS_Store -dist/ node_modules/ \ No newline at end of file diff --git a/examples/pong/pong.js b/examples/pong/pong.js index 80dee6a..65a3d63 100644 --- a/examples/pong/pong.js +++ b/examples/pong/pong.js @@ -49,11 +49,11 @@ window.onload = function () { this.pos.add(this.state.speed.clone().multiply(pong.lastFrameDelta)); - if ((this.pos.x + baseSize > width) || (this.pos.x < 0)) { + if ((this.pos.x + baseSize > width && this.state.speed.x > 0) || (this.pos.x < 0 && this.state.speed.x < 0)) { this.state.speed.x = -this.state.speed.x; } - if ((this.pos.y + baseSize > height) || (this.pos.y < 0)) { + if ((this.pos.y + baseSize > height && this.state.speed.y > 0) || (this.pos.y < 0 && this.state.speed.y < 0)) { this.state.speed.y = -this.state.speed.y; }