Merge remote-tracking branch 'origin/models' into models
This commit is contained in:
commit
fafbfa1b32
3 changed files with 13 additions and 12 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
const pipeImagePath: string = "resources/raspberry-low-res.png";
|
const pipeImagePath: string = "resources/raspberry-low-res.png";
|
||||||
const obstacleWidth: number = 42;
|
const obstacleWidth: number = 88;
|
||||||
let obstacleOffset: number;
|
let obstacleOffset: number;
|
||||||
const backgroundImagePath: string = "resources/raspberry-low-res.png";
|
const backgroundImagePath: string = "resources/raspberry-low-res.png";
|
||||||
let backgroundImage: any;
|
let backgroundImage: any;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
class Obstacle extends Entity implements Collidable{
|
class Obstacle extends Entity implements Collidable {
|
||||||
private pipeTop: Pipe;
|
private pipeTop: Pipe;
|
||||||
private pipeBottom: Pipe;
|
private pipeBottom: Pipe;
|
||||||
private readonly distanceBetweenPipes: number;
|
private readonly distanceBetweenPipes: number;
|
||||||
private readonly padding: number = 300;
|
private readonly padding: number = 150;
|
||||||
private readonly speed: number = 3;
|
private readonly speed: number = 3;
|
||||||
|
|
||||||
private static startX: number;
|
private static startX: number;
|
||||||
|
|
@ -23,13 +23,12 @@ class Obstacle extends Entity implements Collidable{
|
||||||
}
|
}
|
||||||
|
|
||||||
public resetPosition(resetX: boolean): void {
|
public resetPosition(resetX: boolean): void {
|
||||||
this.pipeBottom.position.y =
|
this.pipeTop.height = this.randomRange(this.padding, height - this.padding - this.distanceBetweenPipes);
|
||||||
this.distanceBetweenPipes + this.randomRange(0, height - this.padding - 1.2 * 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 =
|
if (resetX) {
|
||||||
this.pipeBottom.position.y - this.distanceBetweenPipes - this.pipeTop.height;
|
|
||||||
|
|
||||||
if(resetX){
|
|
||||||
this.pipeBottom.position.x = Obstacle.startX;
|
this.pipeBottom.position.x = Obstacle.startX;
|
||||||
this.pipeTop.position.x = Obstacle.startX;
|
this.pipeTop.position.x = Obstacle.startX;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,14 +58,16 @@ class Raspberry extends Entity {
|
||||||
|
|
||||||
public draw(): void {
|
public draw(): void {
|
||||||
push();
|
push();
|
||||||
image(this.image, this.position.x, this.position.y, this.width, this.height);
|
|
||||||
noFill();
|
noFill();
|
||||||
|
translate(this.position.x, this.position.y);
|
||||||
|
rotate((PI/2)*(this.velocity/Raspberry.maxVelocity));
|
||||||
|
image(this.image, 0, 0, this.width, this.height);
|
||||||
if (!this.showHitbox) {
|
if (!this.showHitbox) {
|
||||||
noStroke();
|
noStroke();
|
||||||
}
|
}
|
||||||
rect(
|
rect(
|
||||||
this.position.x,
|
0,
|
||||||
this.position.y,
|
0,
|
||||||
this.width,
|
this.width,
|
||||||
this.height
|
this.height
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue