Merge remote-tracking branch 'origin/models' into models
# Conflicts: # frontend/game.ts
This commit is contained in:
commit
d0724e668a
3 changed files with 15 additions and 13 deletions
|
|
@ -48,8 +48,7 @@ function draw() {
|
||||||
obstacle.draw();
|
obstacle.draw();
|
||||||
obstacle.update();
|
obstacle.update();
|
||||||
|
|
||||||
// console.log(obstacle.position.x);
|
if(obstacle.position.x < -obstacleWidth) {
|
||||||
if(obstacle.position.x <= -obstacleWidth) {
|
|
||||||
obstacle.resetPosition(true);
|
obstacle.resetPosition(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ class Obstacle extends Entity {
|
||||||
private pipeBottom: Pipe;
|
private pipeBottom: Pipe;
|
||||||
private readonly distanceBetweenPipes: number;
|
private readonly distanceBetweenPipes: number;
|
||||||
private readonly padding: number = 300;
|
private readonly padding: number = 300;
|
||||||
private readonly speed: number = 8;
|
private readonly speed: number = 3;
|
||||||
|
|
||||||
private static startX: number;
|
private static startX: number;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,19 @@
|
||||||
class Raspberry extends Entity {
|
class Raspberry extends Entity {
|
||||||
private readonly lift: number = -10;
|
private readonly lift: number = -20;
|
||||||
private readonly gravity: number = 1;
|
private readonly gravity: number = 1.314159265358979323846264338;
|
||||||
private _velocity: number = 0;
|
private _velocity: number = 0;
|
||||||
private _image: any;
|
private _image: any;
|
||||||
private static readonly maxVelocity: number = 5;
|
private static readonly maxVelocity: number = 100;
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super(new Position(width / 6, height / 2), 180, 70, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//region Getter & Setter
|
//region Getter & Setter
|
||||||
|
|
||||||
|
|
||||||
get velocity(): number {
|
get velocity(): number {
|
||||||
return this._velocity;
|
return this._velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
set velocity(value: number) {
|
set velocity(value: number) {
|
||||||
this._velocity = (this.velocity > Raspberry.maxVelocity) ? Raspberry.maxVelocity : value;
|
this._velocity = (Math.abs(this.velocity) > Raspberry.maxVelocity) ? Raspberry.maxVelocity : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
get image(): any {
|
get image(): any {
|
||||||
|
|
@ -28,6 +26,10 @@ class Raspberry extends Entity {
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super(new Position(width / 6, height / 2), 180, 70, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public update(): void {
|
public update(): void {
|
||||||
this.applyGravity();
|
this.applyGravity();
|
||||||
this.forceBoundaries();
|
this.forceBoundaries();
|
||||||
|
|
@ -35,11 +37,12 @@ class Raspberry extends Entity {
|
||||||
|
|
||||||
private applyGravity(): void {
|
private applyGravity(): void {
|
||||||
this.velocity += this.gravity;
|
this.velocity += this.gravity;
|
||||||
|
this.position.y += this.velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private forceBoundaries(): void {
|
private forceBoundaries(): void {
|
||||||
if (this.position.y > height) {
|
if (this.position.y+this.height > height) {
|
||||||
this.position.y = height;
|
this.position.y = height-this.height;
|
||||||
this.velocity = 0;
|
this.velocity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue