aboutsummaryrefslogtreecommitdiff
path: root/src/paperflight/static/update.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/paperflight/static/update.js')
-rw-r--r--src/paperflight/static/update.js21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/paperflight/static/update.js b/src/paperflight/static/update.js
index 3a61647..2a2a949 100644
--- a/src/paperflight/static/update.js
+++ b/src/paperflight/static/update.js
@@ -14,7 +14,6 @@ function update() {
currLevel.items.forEach(item => {
item.update()
})
- currLevel.items = currLevel.items.filter(item => !item.collected)
if (atExit()) {
console.log("exit!")
}
@@ -22,10 +21,11 @@ function update() {
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})) {
+ x: this.x,
+ y: this.y - this.height,
+ width: this.width,
+ height: this.height
+ })) {
plane.y -= 2
}
}
@@ -43,15 +43,16 @@ function updateRamp() {
}
}
function updateCoin() {
- if (Math.sqrt(Math.pow(plane.x - this.x, 2) + Math.pow(plane.y - this.y, 2)) < this.radius
- || Math.sqrt(Math.pow(plane.x + plane.width - this.x, 2) + Math.pow(plane.y - this.y, 2)) < this.radius) {
+ if (!this.collected
+ && (Math.sqrt(Math.pow(plane.x - this.x, 2) + Math.pow(plane.y - this.y, 2)) < this.radius
+ || Math.sqrt(Math.pow(plane.x + plane.width - this.x, 2) + Math.pow(plane.y - this.y, 2)) < this.radius)) {
this.collected = true
collected++
}
}
function updateSwitch() {
- if(isPlaneInBox(this)){
- if(!this.inBox){
+ if (isPlaneInBox(this)) {
+ if (!this.inBox) {
this.inBox = true
switchState = (switchState + 1) % this.stateCount
}
@@ -60,7 +61,7 @@ function updateSwitch() {
}
}
function updateSwitchRect() {
- if(isPlaneInBox(this) && switchState == this.state){
+ if (isPlaneInBox(this) && switchState == this.state) {
gameOver()
}
} \ No newline at end of file