From 00cc924a2a5364affd01778c8ebc7b2e47fbe7e9 Mon Sep 17 00:00:00 2001 From: s-prechtl Date: Wed, 14 Dec 2022 12:24:45 +0100 Subject: [PATCH 1/2] pipe gen working --- frontend/game.ts | 2 +- frontend/models/Obstacle.ts | 15 +++++++-------- frontend/models/Raspberry.ts | 8 +++++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/frontend/game.ts b/frontend/game.ts index 12912fc..73f3511 100644 --- a/frontend/game.ts +++ b/frontend/game.ts @@ -1,5 +1,5 @@ const pipeImagePath: string = "resources/raspberry-low-res.png"; -const obstacleWidth: number = 42; +const obstacleWidth: number = 88; let obstacleOffset: number; const backgroundImagePath: string = "resources/raspberry-low-res.png"; let backgroundImage: any; diff --git a/frontend/models/Obstacle.ts b/frontend/models/Obstacle.ts index d239d5e..39df256 100644 --- a/frontend/models/Obstacle.ts +++ b/frontend/models/Obstacle.ts @@ -1,8 +1,8 @@ -class Obstacle extends Entity implements Collidable{ +class Obstacle extends Entity implements Collidable { private pipeTop: Pipe; private pipeBottom: Pipe; private readonly distanceBetweenPipes: number; - private readonly padding: number = 300; + private readonly padding: number = 150; private readonly speed: number = 3; private static startX: number; @@ -23,13 +23,12 @@ class Obstacle extends Entity implements Collidable{ } public resetPosition(resetX: boolean): void { - this.pipeBottom.position.y = - this.distanceBetweenPipes + this.randomRange(0, height - this.padding - 1.2 * this.distanceBetweenPipes); + this.pipeTop.height = this.randomRange(this.padding, height - this.padding - this.distanceBetweenPipes); + this.pipeTop.position.y = 0; + this.pipeBottom.position.y = this.pipeTop.height + this.distanceBetweenPipes; + this.pipeBottom.height = height - this.pipeTop.height - this.padding; - this.pipeTop.position.y = - this.pipeBottom.position.y - this.distanceBetweenPipes - this.pipeTop.height; - - if(resetX){ + if (resetX) { this.pipeBottom.position.x = Obstacle.startX; this.pipeTop.position.x = Obstacle.startX; } diff --git a/frontend/models/Raspberry.ts b/frontend/models/Raspberry.ts index d844175..f2cb1e4 100644 --- a/frontend/models/Raspberry.ts +++ b/frontend/models/Raspberry.ts @@ -58,14 +58,16 @@ class Raspberry extends Entity { public draw(): void { push(); - image(this.image, this.position.x, this.position.y, this.width, this.height); noFill(); + translate(this.position.x, this.position.y); + // rotate((PI/4)*(this.velocity)); + image(this.image, 0, 0, this.width, this.height); if (!this.showHitbox) { noStroke(); } rect( - this.position.x, - this.position.y, + 0, + 0, this.width, this.height ); From 13850368c6361a27037e6fc43bcf6eba196b4ce8 Mon Sep 17 00:00:00 2001 From: s-prechtl Date: Wed, 14 Dec 2022 12:45:01 +0100 Subject: [PATCH 2/2] Rotation for raspi working --- frontend/models/Raspberry.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/models/Raspberry.ts b/frontend/models/Raspberry.ts index f2cb1e4..c8a90d6 100644 --- a/frontend/models/Raspberry.ts +++ b/frontend/models/Raspberry.ts @@ -60,7 +60,7 @@ class Raspberry extends Entity { push(); noFill(); translate(this.position.x, this.position.y); - // rotate((PI/4)*(this.velocity)); + rotate((PI/2)*(this.velocity/Raspberry.maxVelocity)); image(this.image, 0, 0, this.width, this.height); if (!this.showHitbox) { noStroke();