added Obstacle.ts
* resetPosition maby done * update done ig
This commit is contained in:
parent
59523f4a41
commit
123f73ff49
1 changed files with 23 additions and 0 deletions
23
frontend/models/Obstacle.ts
Normal file
23
frontend/models/Obstacle.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
class Obstacle {
|
||||
private pipeTop: Entity;
|
||||
private pipeBottom: Entity;
|
||||
private distanceBetweenPipes: number;
|
||||
private padding: number;
|
||||
private speed: number;
|
||||
private static startX: number;
|
||||
|
||||
private resetPosition(){
|
||||
let randomY = Math.random() * (height - this.padding) + this.padding;
|
||||
|
||||
this.pipeTop.height = randomY - this.distanceBetweenPipes / 2;
|
||||
this.pipeTop.position.x = Obstacle.startX;
|
||||
|
||||
this.pipeBottom.height = randomY + this.distanceBetweenPipes / 2;
|
||||
this.pipeBottom.position.x = Obstacle.startX;
|
||||
}
|
||||
|
||||
public update(){
|
||||
this.pipeTop.position.x -= this.speed;
|
||||
this.pipeBottom.position.x -= this.speed;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue