aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Powers <markppowers0@gmail.com>2020-05-15 17:39:43 -0500
committerMark Powers <markppowers0@gmail.com>2020-05-15 17:39:43 -0500
commitc4fc7e2056db1ca0c5fdead9751c5e3d15cf99ab (patch)
tree416d94f03cad95fa0f4a483a68a6f4420623b12d
parent3f7179f88deba4dfb0441cd414cec6db6f2d8cc0 (diff)
Add moving drip obstacle
-rw-r--r--src/paperflight/static/draw.js23
-rw-r--r--src/paperflight/static/items.js8
-rw-r--r--src/paperflight/static/levels.js23
-rw-r--r--src/paperflight/static/update.js5
4 files changed, 54 insertions, 5 deletions
diff --git a/src/paperflight/static/draw.js b/src/paperflight/static/draw.js
index 0be9ae9..4ba138b 100644
--- a/src/paperflight/static/draw.js
+++ b/src/paperflight/static/draw.js
@@ -68,6 +68,29 @@ function drawVent() {
ctx.fillRect(w.x, w.y, 1, w.height)
})
}
+function drawDrip(){
+ ctx.fillStyle = "#00F"
+ if (t % this.frequency == 0) {
+ this.drips.push({
+ x: this.x,
+ y: this.y,
+ radius: 8
+ })
+ }
+ this.drips.forEach(drip => {
+ drip.y += 3
+ })
+ // Remove all wind higher than certain height
+ this.drips = this.drips.filter(drip => {
+ return drip.y < height
+ })
+ // Finally draw each wind
+ this.drips.forEach(drip => {
+ ctx.beginPath()
+ ctx.arc(drip.x, drip.y, drip.radius, 0, Math.PI * 2)
+ ctx.fill()
+ })
+}
function drawBlock() {
ctx.fillStyle = "#0d0"
ctx.fillRect(this.x, this.y, this.width, this.height)
diff --git a/src/paperflight/static/items.js b/src/paperflight/static/items.js
index 14ec8eb..c368f81 100644
--- a/src/paperflight/static/items.js
+++ b/src/paperflight/static/items.js
@@ -54,4 +54,12 @@ function constructText(x, y, text, font){
style: "black",
x, y, text, font
}
+}
+function constructDrip(x, y, frequency){
+ return {
+ draw: drawDrip,
+ update: updateDrip,
+ drips: [],
+ x, y, frequency
+ }
} \ No newline at end of file
diff --git a/src/paperflight/static/levels.js b/src/paperflight/static/levels.js
index 2f0d172..75a63af 100644
--- a/src/paperflight/static/levels.js
+++ b/src/paperflight/static/levels.js
@@ -41,20 +41,33 @@ levels[5].items.push(
constructSwitch(115, 90, 40, 40, 4),
constructBlock(0, 200, 250, 10),
constructSwitchRect(250, 50, 10, 150, 0),
-
constructSwitch(500, 165, 40, 40, 4),
-
constructSwitch(115, 240, 40, 40, 4),
constructBlock(0, 350, 250, 10),
constructSwitchRect(250, 200, 10, 150, 1),
-
constructBlock(250, 350, 10, 100),
-
constructVent(0, 550, 250, 150, 3)
)
-levels[6] = createLevel("Downwards Dash", 5, 40, 460)
+levels[6] = createLevel("Gentle Breeze", 2, 750, 150)
levels[6].items.push(
+ constructVent(100, 550, 100, 500),
+ constructVent(600, 550, 100, 500),
+ constructCoin(275, 500),
+ constructCoin(525, 500)
+)
+
+levels[7] = createLevel("Looks like rain", 2, 750, 150)
+levels[7].items.push(
+ constructVent(100, 550, 100, 500),
+ constructVent(600, 550, 100, 500),
+ constructCoin(275, 500),
+ constructCoin(525, 500),
+ constructDrip(400, 40, 30)
+)
+
+levels[8] = createLevel("Downwards Dash", 5, 40, 460)
+levels[8].items.push(
constructVent(420, 580, 60, 600),
constructCoin(40, 80),
constructVent(120, 100, 280, 100),
diff --git a/src/paperflight/static/update.js b/src/paperflight/static/update.js
index 642e993..8dec8e6 100644
--- a/src/paperflight/static/update.js
+++ b/src/paperflight/static/update.js
@@ -33,6 +33,11 @@ function updateVent() {
plane.y -= 2
}
}
+function updateDrip(){
+ if(this.drips.some(drip => isPlaneInCircle(drip))){
+ gameOver()
+ }
+}
function updateBlock() {
if (isPlaneInBox(this)) {
gameOver()