Refactor & Bug Fix

`game.ts`
 - fixed score on new game

`Obstacle.ts`
 - made distanceBetweenPipes and startX public
 - moved initialization of distanceBetweenPipes and startX to game.setupGame()

`Pipe.ts`
 - created move() method to move the pipe

 `Raspberry.ts`
  - added constant variables for Raspberry size
This commit is contained in:
dhain 2023-01-10 09:37:12 +01:00
parent a16f1203ff
commit d98cd7b10e
4 changed files with 25 additions and 16 deletions

View file

@ -3,7 +3,12 @@ class Raspberry extends Entity {
private readonly gravity: number = 1.314159265358979323846264338;
private _velocity: number = 0;
private _image: any;
private static readonly maxVelocity: number = 100;
private static readonly POSITION: Position = new Position(width / 6, height / 2);
private static readonly WIDTH: number = 180;
private static readonly HEIGHT: number = 70;
private static readonly FILL: number = 0;
//region Getter & Setter
get velocity(): number {
@ -27,9 +32,9 @@ class Raspberry extends Entity {
/**
* Constructs the Raspberry with fixed sizes
*/
constructor() {
// TODO: Move literals to consta
super(new Position(width / 6, height / 2), 180, 70, 0);
constructor(image: string) {
super(Raspberry.POSITION, Raspberry.WIDTH, Raspberry.HEIGHT, Raspberry.FILL);
this.image = image;
}
public update(): void {