Fixed bug in pong bounds handling
This commit is contained in:
parent
ae48ce9de2
commit
2eade7a21b
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,3 @@
|
||||
.idea/
|
||||
.DS_Store
|
||||
dist/
|
||||
node_modules/
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user