WIP multiBalls (need refactoring)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
import * as c from "../constants.js"
|
||||
import * as en from "../../shared_js/enums.js"
|
||||
import { Vector, VectorInteger } from "../../shared_js/class/Vector.js";
|
||||
import { TextElem, TextNumericValue } from "./Text.js";
|
||||
import { RectangleClient, RacketClient, BallClient, Line } from "./RectangleClient.js";
|
||||
@@ -11,14 +12,21 @@ class GameComponentsExtensionForClient extends GameComponents {
|
||||
playerLeft: RacketClient;
|
||||
playerRight: RacketClient;
|
||||
ball: BallClient;
|
||||
constructor(ctx: CanvasRenderingContext2D)
|
||||
ball2?: BallClient;
|
||||
ball3?: BallClient;
|
||||
constructor(options: en.MatchOptions, ctx: CanvasRenderingContext2D)
|
||||
{
|
||||
super();
|
||||
super(options);
|
||||
this.wallTop = new RectangleClient(this.wallTop.pos, this.wallTop.width, this.wallTop.height, ctx, "grey");
|
||||
this.wallBottom = new RectangleClient(this.wallBottom.pos, this.wallBottom.width, this.wallBottom.height, ctx, "grey");
|
||||
this.playerLeft = new RacketClient(this.playerLeft.pos, this.playerLeft.width, this.playerLeft.height, this.playerLeft.baseSpeed, ctx, "white");
|
||||
this.playerRight = new RacketClient(this.playerRight.pos, this.playerRight.width, this.playerRight.height, this.playerRight.baseSpeed, ctx, "white");
|
||||
this.ball = new BallClient(this.ball.pos, this.ball.width, this.ball.baseSpeed, this.ball.speedIncrease, ctx, "white");
|
||||
if (options & en.MatchOptions.multiBalls)
|
||||
{ // ALTERNATIVE POSSIBLE, Array of balls
|
||||
this.ball2 = new BallClient(this.ball2.pos, this.ball2.width, this.ball2.baseSpeed, this.ball2.speedIncrease, ctx, "white");
|
||||
this.ball3 = new BallClient(this.ball3.pos, this.ball3.width, this.ball3.baseSpeed, this.ball3.speedIncrease, ctx, "white");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +43,9 @@ class GameComponentsClient extends GameComponentsExtensionForClient {
|
||||
h_grid_mid: RectangleClient;
|
||||
h_grid_u1: RectangleClient;
|
||||
h_grid_d1: RectangleClient;
|
||||
constructor(ctx: CanvasRenderingContext2D)
|
||||
constructor(options: en.MatchOptions, ctx: CanvasRenderingContext2D)
|
||||
{
|
||||
super(ctx);
|
||||
super(options, ctx);
|
||||
let pos = new VectorInteger;
|
||||
// Scores
|
||||
pos.assign(c.w_mid-c.scoreSize*1.6, c.scoreSize*1.5);
|
||||
|
||||
Reference in New Issue
Block a user