Fixed bug in pong bounds handling

This commit is contained in:
Nathan Kunicki 2015-12-21 16:48:55 +00:00
parent 14f7f3e30e
commit c8777e6556
2 changed files with 2 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
.idea/ .idea/
.DS_Store .DS_Store
dist/
node_modules/ node_modules/

View File

@ -49,11 +49,11 @@ window.onload = function () {
this.pos.add(this.state.speed.clone().multiply(pong.lastFrameDelta)); 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; 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; this.state.speed.y = -this.state.speed.y;
} }