+ 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

@@ -2,6 +2,8 @@
import {Vector, VectorInteger} from "../../shared_js/class/Vector.js";
import {Component, GraphicComponent, Moving} from "../../shared_js/class/interface.js";
import { Rectangle, MovingRectangle, Racket, Ball } from "../../shared_js/class/Rectangle.js";
import {soundPong, soundRoblox} from "../audio.js"
import { random } from "../utils.js";
function updateRectangle(this: RectangleClient) {
this.ctx.fillStyle = this.color;
@@ -87,6 +89,14 @@ class BallClient extends Ball implements GraphicComponent {
this.update = updateRectangle;
this.clear = clearRectangle;
}
bounce(collider?: Rectangle) {
this._bounceAlgo(collider);
soundPong[ Math.floor(random(0, soundPong.length)) ].play();
}
/* protected _bouncePlayer(collider: Racket) {
this._bouncePlayerAlgo(collider);
soundRoblox.play();
} */
}
function updateLine(this: Line) {