Fixed game

This commit is contained in:
s-prechtl 2023-01-10 10:34:53 +01:00
parent 98dd3720ae
commit 6927ba9e85
2 changed files with 6 additions and 6 deletions

View file

@ -37,17 +37,16 @@ class Obstacle extends Entity implements Collidable {
*/
public resetPosition(): void {
this.randomizeHeight();
this.pipeBottom.position.x = Obstacle.startX;
this.pipeTop.position.x = Obstacle.startX;
this.pipeBottom.position.x = Obstacle._startX;
this.pipeTop.position.x = Obstacle._startX;
}
/**
* Randomizes the height of the pipes
*/
public randomizeHeight(): void {
this.pipeTop.height = this.randomRange(this.padding, height - this.padding - Obstacle.distanceBetweenPipes);
this.pipeBottom.position.y = this.pipeTop.height + Obstacle.distanceBetweenPipes;
this.pipeTop.height = this.randomRange(this.padding, height - this.padding - Obstacle._distanceBetweenPipes);
this.pipeBottom.position.y = this.pipeTop.height + Obstacle._distanceBetweenPipes;
this.pipeBottom.height = height - this.pipeTop.height - this.padding;
}

View file

@ -5,7 +5,7 @@ class Raspberry extends Entity {
private _image: any;
private static readonly maxVelocity: number = 100;
private static readonly POSITION: Position = new Position(width / 6, height / 2);
private static POSITION: Position;
private static readonly WIDTH: number = 180;
private static readonly HEIGHT: number = 70;
private static readonly FILL: number = 0;
@ -33,6 +33,7 @@ class Raspberry extends Entity {
* Constructs the Raspberry with fixed sizes
*/
constructor(image: string) {
Raspberry.POSITION = new Position(width / 6, height / 2)
super(Raspberry.POSITION, Raspberry.WIDTH, Raspberry.HEIGHT, Raspberry.FILL);
this.image = image;
}