WIP multiBalls (need refactoring)
This commit is contained in:
@@ -39,6 +39,20 @@ class EventGameUpdate extends ServerEvent {
|
||||
dirY: 0,
|
||||
speed: 0
|
||||
};
|
||||
ball2? = { // ALTERNATIVE POSSIBLE, Array of balls
|
||||
x: 0,
|
||||
y: 0,
|
||||
dirX: 0,
|
||||
dirY: 0,
|
||||
speed: 0
|
||||
};
|
||||
ball3? = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
dirX: 0,
|
||||
dirY: 0,
|
||||
speed: 0
|
||||
};
|
||||
lastInputId = 0;
|
||||
constructor() { // TODO: constructor that take GameComponentsServer maybe ?
|
||||
super(en.EventTypes.gameUpdate);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
import * as c from "../constants.js"
|
||||
import * as en from "../../shared_js/enums.js"
|
||||
import { VectorInteger } from "./Vector.js";
|
||||
import { Rectangle, Racket, Ball } from "./Rectangle.js";
|
||||
|
||||
@@ -9,7 +10,9 @@ class GameComponents {
|
||||
playerLeft: Racket;
|
||||
playerRight: Racket;
|
||||
ball: Ball;
|
||||
constructor()
|
||||
ball2?: Ball;
|
||||
ball3?: Ball;
|
||||
constructor(options: en.MatchOptions)
|
||||
{
|
||||
let pos = new VectorInteger;
|
||||
|
||||
@@ -26,6 +29,15 @@ class GameComponents {
|
||||
pos.assign(-c.ballSize, -c.ballSize); // ball out =)
|
||||
this.ball = new Ball(pos, c.ballSize, c.ballSpeed, c.ballSpeedIncrease);
|
||||
this.ball.dir.assign(-0.8, +0.2);
|
||||
|
||||
if (options & en.MatchOptions.multiBalls)
|
||||
{ // ALTERNATIVE POSSIBLE, Array of balls
|
||||
pos.assign(-c.ballSize, -c.ballSize); // ball out =)
|
||||
this.ball2 = new Ball(pos, c.ballSize, c.ballSpeed, c.ballSpeedIncrease);
|
||||
this.ball2.dir.assign(-0.8, +0.2);
|
||||
this.ball3 = new Ball(pos, c.ballSize, c.ballSpeed, c.ballSpeedIncrease);
|
||||
this.ball3.dir.assign(-0.8, +0.2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ class Racket extends MovingRectangle {
|
||||
|
||||
class Ball extends MovingRectangle {
|
||||
readonly speedIncrease: number;
|
||||
ballInPlay: boolean = false;
|
||||
constructor(pos: VectorInteger, size: number, baseSpeed: number, speedIncrease: number) {
|
||||
super(pos, size, size, baseSpeed);
|
||||
this.speedIncrease = speedIncrease;
|
||||
|
||||
Reference in New Issue
Block a user