audio
+ client prediction
This commit is contained in:
@@ -69,6 +69,9 @@ class Ball extends MovingRectangle {
|
||||
super(pos, size, size, baseSpeed);
|
||||
}
|
||||
bounce(collider?: Rectangle) {
|
||||
this._bounceAlgo(collider);
|
||||
}
|
||||
protected _bounceAlgo(collider?: Rectangle) {
|
||||
/* Could be more generic, but testing only Racket is enough,
|
||||
because in Pong collider can only be Racket or Wall. */
|
||||
if (collider instanceof Racket) {
|
||||
@@ -87,10 +90,13 @@ class Ball extends MovingRectangle {
|
||||
this.move(delta);
|
||||
}
|
||||
}
|
||||
private _bounceWall() { // Should be enough for Wall
|
||||
protected _bounceWall() { // Should be enough for Wall
|
||||
this.dir.y = this.dir.y * -1;
|
||||
}
|
||||
private _bouncePlayer(collider: Racket) { // WIP
|
||||
protected _bouncePlayer(collider: Racket) {
|
||||
this._bouncePlayerAlgo(collider);
|
||||
}
|
||||
protected _bouncePlayerAlgo(collider: Racket) { // WIP
|
||||
// Bounce for Racket need to be more complexe than this
|
||||
this.speed += this.baseSpeed/20;
|
||||
this.dir.x = this.dir.x * -1;
|
||||
|
||||
Reference in New Issue
Block a user