random pipe position working

This commit is contained in:
dhain 2022-12-06 09:45:43 +01:00
parent 4a40175884
commit 8e19fb7cfb
5 changed files with 59 additions and 17 deletions

View file

@ -1,12 +1,15 @@
let obstacle: Obstacle;
let raspberry: Raspberry;
function setup() {
createCanvas(400, 400)
background(187)
line(0,0, 400,400)
createCanvas(1000, 1000);
raspberry = new Raspberry();
obstacle = new Obstacle(new Pipe(new Position(width, 0), 20, 50, 0), new Pipe(new Position(width, 300), 20, 50, 0))
obstacle = new Obstacle(
new Pipe(new Position(width, 0), 32, height),
new Pipe(new Position(width, height - (height / 3)), 32, height),
);
}
function draw() {
@ -15,7 +18,12 @@ function draw() {
raspberry.update();
obstacle.draw();
obstacle.update();
if (obstacle.position.x < 0) {
obstacle.resetPosition();
}
}
//
// function keyPressed() {
//