Floor & Positioning & small Obstacle rework

- added images for pipes and floor
- floor is now working
- raspberry is falling on floor correctly
- images are now getting preloaded
- font ia getting preloaded
- obstacle and pipe constructor now take p5.Image instead of a string with the path
- removed everything to do with drawing background posters

- started working on pipe tiling instead of streching
This commit is contained in:
dhain 2023-01-17 11:10:26 +01:00
parent d069987bb0
commit f1babb7c13
10 changed files with 68 additions and 80 deletions

View file

@ -56,6 +56,12 @@ class Raspberry extends Entity {
*/
private static readonly FILL: number = 0;
/**
* Offset off of the floor so that the raspberry looks like it's falling on the floor
* @private
*/
private static BOTTOM_FLOOR_OFFSET: number;
//region Getter & Setter
/**
@ -97,6 +103,7 @@ class Raspberry extends Entity {
constructor(image: string) {
Raspberry.position = new Position(width / 6, height / 2);
super(Raspberry.position, Raspberry.WIDTH, Raspberry.HEIGHT, Raspberry.FILL);
Raspberry.BOTTOM_FLOOR_OFFSET = (height / 5) - (height / 15 / 2);
this.image = image;
}
@ -117,7 +124,7 @@ class Raspberry extends Entity {
}
/**
* Limits the raspberry's movement to the shown canvas.
* Limits the Raspberry's movement to the shown canvas.
* @private
*/
private forceBoundaries(): void {
@ -141,8 +148,8 @@ class Raspberry extends Entity {
* @private
*/
private boundaryBottom(): void {
if (this.position.y + this.height > height) {
this.position.y = height - this.height;
if (this.position.y + this.height + Raspberry.BOTTOM_FLOOR_OFFSET > height) {
this.position.y = height - this.height - Raspberry.BOTTOM_FLOOR_OFFSET;
this.velocity = 0;
}
}