From 7e469de9bc435b622eb415bf403727780ff95f4c Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Thu, 14 May 2020 22:30:41 -0500 Subject: Add switchable vents --- src/paperflight/static/update.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/paperflight/static/update.js') diff --git a/src/paperflight/static/update.js b/src/paperflight/static/update.js index 0b44089..642e993 100644 --- a/src/paperflight/static/update.js +++ b/src/paperflight/static/update.js @@ -8,7 +8,7 @@ function update() { plane.x += plane.vx * plane.dir plane.y += plane.vy } - if (!isPlaneInBox({ x: plane.width, y: plane.height, width: width - (2*plane.width), height: height - (2*plane.height) })) { + if (!isPlaneInBox({ x: plane.width, y: plane.height, width: width - (2 * plane.width), height: height - (2 * plane.height) })) { gameOver() } currLevel.items.forEach(item => { @@ -17,18 +17,19 @@ function update() { if (atExit()) { setLevel(currLevelIndex + 1) } - if(gameIsOver){ + if (gameIsOver) { window.clearInterval(gameInterval) } } function updateVent() { // Custom box since vent height is upwards - if (isPlaneInBox({ - x: this.x, - y: this.y - this.height, - width: this.width, - height: this.height - })) { + if ((this.state == -1 || this.state == switchState) + && isPlaneInBox({ + x: this.x, + y: this.y - this.height, + width: this.width, + height: this.height + })) { plane.y -= 2 } } -- cgit v1.2.3