+ client prediction
This commit is contained in:
LuckyLaszlo
2022-11-22 00:06:07 +01:00
parent 04203f4f9d
commit 2b9058ad49
43 changed files with 53 additions and 15 deletions

View File

@@ -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;