aboutsummaryrefslogtreecommitdiff
path: root/src/paperflight/static/update.js
diff options
context:
space:
mode:
authorMark Powers <markppowers0@gmail.com>2020-05-14 10:29:07 -0500
committerMark Powers <markppowers0@gmail.com>2020-05-14 10:29:07 -0500
commitc5d5990eecd254f3d5daf33a6c9cd394dcba2058 (patch)
tree60cc8a229afe44fa4b4189e1016895fadee58ef9 /src/paperflight/static/update.js
parentae74d0d38196c14ea79cef2444f508c649c57580 (diff)
Fix coin not respawning on reset
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