Merge remote-tracking branch 'origin/models' into models
This commit is contained in:
commit
2e1e4c3ce9
2 changed files with 23 additions and 23 deletions
|
|
@ -18,19 +18,22 @@ function setup() {
|
||||||
raspberry.image = raspberryImagePath;
|
raspberry.image = raspberryImagePath;
|
||||||
|
|
||||||
obstacles.push(new Obstacle(
|
obstacles.push(new Obstacle(
|
||||||
new Pipe(width, obstacleWidth, height),
|
new Position(width, 0),
|
||||||
new Pipe(width, obstacleWidth, height),
|
obstacleWidth,
|
||||||
pipeImagePath
|
height,
|
||||||
|
pipeImagePath,
|
||||||
));
|
));
|
||||||
obstacles.push(new Obstacle(
|
obstacles.push(new Obstacle(
|
||||||
new Pipe(width + obstacleOffset, obstacleWidth, height),
|
new Position(width + obstacleOffset, 0),
|
||||||
new Pipe(width + obstacleOffset, obstacleWidth, height),
|
obstacleWidth,
|
||||||
pipeImagePath
|
height,
|
||||||
|
pipeImagePath,
|
||||||
));
|
));
|
||||||
obstacles.push(new Obstacle(
|
obstacles.push(new Obstacle(
|
||||||
new Pipe(width + obstacleOffset * 2, obstacleWidth, height),
|
new Position(width + obstacleOffset * 2, 0),
|
||||||
new Pipe(width + obstacleOffset * 2, obstacleWidth, height),
|
obstacleWidth,
|
||||||
pipeImagePath
|
height,
|
||||||
|
pipeImagePath,
|
||||||
));
|
));
|
||||||
|
|
||||||
obstacles.forEach((obstacle) => obstacle.resetPosition(false));
|
obstacles.forEach((obstacle) => obstacle.resetPosition(false));
|
||||||
|
|
@ -38,24 +41,20 @@ function setup() {
|
||||||
|
|
||||||
function draw() {
|
function draw() {
|
||||||
background(backgroundImage)
|
background(backgroundImage)
|
||||||
raspberry.update();
|
|
||||||
raspberry.draw();
|
raspberry.draw();
|
||||||
|
raspberry.update();
|
||||||
|
|
||||||
obstacles.forEach((obstacle) => {
|
obstacles.forEach((obstacle) => {
|
||||||
obstacle.update();
|
|
||||||
obstacle.draw();
|
obstacle.draw();
|
||||||
|
obstacle.update();
|
||||||
|
|
||||||
if(obstacle.position.x < -obstacleWidth) {
|
if(obstacle.position.x < -obstacleWidth) {
|
||||||
obstacle.resetPosition(true);
|
obstacle.resetPosition(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function keyPressed() {
|
//
|
||||||
if (key == "K" || key == "k") {
|
// function keyPressed() {
|
||||||
raspberry.boost();
|
//
|
||||||
console.log("BOOOST")
|
// }
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -11,10 +11,10 @@ class Obstacle extends Entity implements Collidable{
|
||||||
* Constructs the Obstacle using the top and bottom Pipe
|
* Constructs the Obstacle using the top and bottom Pipe
|
||||||
* (fill is not used here)
|
* (fill is not used here)
|
||||||
*/
|
*/
|
||||||
constructor(pipeTop: Pipe, pipeBottom: Pipe, pipeImagePath: string) {
|
constructor(position: Position, obstacleWidth: number, obstacleHeight: number, pipeImagePath: string) {
|
||||||
super(pipeTop.position, pipeTop.width, pipeBottom.height, 0);
|
super(position, obstacleWidth, obstacleHeight, 0);
|
||||||
this.pipeTop = pipeTop;
|
this.pipeTop = new Pipe(position.x, obstacleWidth, obstacleHeight);
|
||||||
this.pipeBottom = pipeBottom;
|
this.pipeBottom = new Pipe(position.x, obstacleWidth, obstacleHeight);
|
||||||
this.pipeTop.image = pipeImagePath;
|
this.pipeTop.image = pipeImagePath;
|
||||||
this.pipeBottom.image = pipeImagePath;
|
this.pipeBottom.image = pipeImagePath;
|
||||||
|
|
||||||
|
|
@ -42,6 +42,7 @@ class Obstacle extends Entity implements Collidable{
|
||||||
public update(): void {
|
public update(): void {
|
||||||
this.pipeTop.position.x -= this.speed;
|
this.pipeTop.position.x -= this.speed;
|
||||||
this.pipeBottom.position.x -= this.speed;
|
this.pipeBottom.position.x -= this.speed;
|
||||||
|
this.position.x = this.pipeTop.position.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public draw(): void {
|
public draw(): void {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue