code review
This commit is contained in:
parent
ba2d9f17e1
commit
7d84f51d91
3 changed files with 9 additions and 12 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
class Obstacle extends Entity {
|
class Obstacle extends Entity {
|
||||||
private pipeTop: Pipe;
|
private pipeTop: Pipe;
|
||||||
private pipeBottom: Pipe;
|
private pipeBottom: Pipe;
|
||||||
private distanceBetweenPipes: number;
|
private readonly distanceBetweenPipes: number;
|
||||||
private padding: number = 300;
|
private readonly padding: number = 300;
|
||||||
private speed: number = 8;
|
private readonly speed: number = 8;
|
||||||
|
|
||||||
private static startX: number;
|
private static startX: number;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ class Pipe extends Entity {
|
||||||
public update(): void {}
|
public update(): void {}
|
||||||
|
|
||||||
public draw(): void {
|
public draw(): void {
|
||||||
// @ts-ignore
|
|
||||||
image(this.image, this.position.x, this.position.y, this.width, this.height);
|
image(this.image, this.position.x, this.position.y, this.width, this.height);
|
||||||
noFill();
|
noFill();
|
||||||
rect(
|
rect(
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
class Raspberry extends Entity {
|
class Raspberry extends Entity {
|
||||||
private lift: number = -10;
|
private readonly lift: number = -10;
|
||||||
private gravity: number = 1;
|
private readonly gravity: number = 1;
|
||||||
private _velocity: number = 0;
|
private _velocity: number = 0;
|
||||||
private _image: any;
|
private _image: any;
|
||||||
private static maxVelocity: number = 5;
|
private static readonly maxVelocity: number = 5;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(new Position(width / 6, height / 2), 180, 70, 0);
|
super(new Position(width / 6, height / 2), 180, 70, 0);
|
||||||
|
|
@ -17,7 +17,7 @@ class Raspberry extends Entity {
|
||||||
set velocity(value: number) {
|
set velocity(value: number) {
|
||||||
this._velocity = (this.velocity > Raspberry.maxVelocity) ? Raspberry.maxVelocity : value;
|
this._velocity = (this.velocity > Raspberry.maxVelocity) ? Raspberry.maxVelocity : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
get image(): any {
|
get image(): any {
|
||||||
return this._image;
|
return this._image;
|
||||||
}
|
}
|
||||||
|
|
@ -34,9 +34,7 @@ class Raspberry extends Entity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private applyGravity(): void {
|
private applyGravity(): void {
|
||||||
if (this.position.y - this.height > 0) {
|
this.velocity += this.gravity;
|
||||||
this.velocity += this.gravity;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private forceBoundaries(): void {
|
private forceBoundaries(): void {
|
||||||
|
|
@ -54,7 +52,7 @@ class Raspberry extends Entity {
|
||||||
public boost(): void {
|
public boost(): void {
|
||||||
this.velocity += this.lift;
|
this.velocity += this.lift;
|
||||||
}
|
}
|
||||||
|
|
||||||
public draw(): void {
|
public draw(): void {
|
||||||
image(this.image, this.position.x, this.position.y, this.width, this.height);
|
image(this.image, this.position.x, this.position.y, this.width, this.height);
|
||||||
noFill();
|
noFill();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue