raspberry flies
This commit is contained in:
parent
dbff8cfb56
commit
7dd557f968
3 changed files with 19 additions and 19 deletions
|
|
@ -1,9 +1,9 @@
|
|||
class Raspberry extends Entity {
|
||||
private readonly lift: number = -10;
|
||||
private readonly gravity: number = 1;
|
||||
private readonly lift: number = -20;
|
||||
private readonly gravity: number = 1.314159265358979323846264338;
|
||||
private _velocity: number = 0;
|
||||
private _image: any;
|
||||
private static readonly maxVelocity: number = 5;
|
||||
private static readonly maxVelocity: number = 100;
|
||||
|
||||
//region Getter & Setter
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ class Raspberry extends Entity {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
|
@ -37,11 +37,12 @@ class Raspberry extends Entity {
|
|||
|
||||
private applyGravity(): void {
|
||||
this.velocity += this.gravity;
|
||||
this.position.y += this.velocity;
|
||||
}
|
||||
|
||||
private forceBoundaries(): void {
|
||||
if (this.position.y > height) {
|
||||
this.position.y = height;
|
||||
if (this.position.y+this.height > height) {
|
||||
this.position.y = height-this.height;
|
||||
this.velocity = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue