aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Powers <markppowers0@gmail.com>2020-05-14 11:27:58 -0500
committerMark Powers <markppowers0@gmail.com>2020-05-14 11:27:58 -0500
commit67d08e1f07d6eb261b98e90e6c803d64c22c1969 (patch)
treead1b3b0f67cecb9dadb9a95b50f8fa7d74ec9b12 /src
parent0ec9047997e3ecaf7c4973baaa2e7b6b52e8144c (diff)
Add text item, create tutorial stages
Diffstat (limited to 'src')
-rw-r--r--src/paperflight/index.html2
-rw-r--r--src/paperflight/static/draw.js14
-rw-r--r--src/paperflight/static/items.js8
-rw-r--r--src/paperflight/static/levels.js29
4 files changed, 47 insertions, 6 deletions
diff --git a/src/paperflight/index.html b/src/paperflight/index.html
index 62763be..8628f49 100644
--- a/src/paperflight/index.html
+++ b/src/paperflight/index.html
@@ -73,6 +73,7 @@
plane.y = 100
plane.dir= 1
currLevelIndex = to
+ collected = 0
if (to in levels) {
currLevel = levels[currLevelIndex]
currLevel.items = currLevel.items.slice()
@@ -81,7 +82,6 @@
item.collected = false
}
})
- collected = 0
switchState = 0
startLevel = false
} else {
diff --git a/src/paperflight/static/draw.js b/src/paperflight/static/draw.js
index 5dd919f..a4d5310 100644
--- a/src/paperflight/static/draw.js
+++ b/src/paperflight/static/draw.js
@@ -14,7 +14,7 @@ function draw() {
ctx.fillStyle = "#222"
ctx.font = "20px Courier"
ctx.fillText(`Level ${currLevelIndex} (${collected}/${currLevel.coinsNeeded}) - ${currLevel.title} - Time ${Math.round(t / fps / 60)}:${Math.round(t / fps) % 60}`, 20, 20)
-
+
if(gameIsOver){
ctx.font = "20px Courier"
ctx.fillStyle = "black"
@@ -94,7 +94,12 @@ function drawCoin() {
}
}
function drawExit(exit) {
- ctx.fillStyle = "green"
+ if(collected >= currLevel.coinsNeeded){
+ ctx.fillStyle = "green"
+ } else {
+ ctx.fillStyle = "red"
+ }
+
ctx.beginPath()
ctx.arc(exit.x, exit.y, 20, 0, Math.PI * 2)
ctx.fill()
@@ -119,4 +124,9 @@ function drawSwitchRect() {
ctx.stroke()
ctx.setLineDash([]);
}
+}
+function drawText(){
+ ctx.fillStyle = this.style
+ ctx.font = this.font
+ ctx.fillText(this.text, this.x, this.y)
} \ No newline at end of file
diff --git a/src/paperflight/static/items.js b/src/paperflight/static/items.js
index 47a434e..09c9888 100644
--- a/src/paperflight/static/items.js
+++ b/src/paperflight/static/items.js
@@ -46,4 +46,12 @@ function constructRect(x, y, width, height, state){
update: updateSwitchRect,
x, y, width, height, state
}
+}
+function constructText(x, y, text, font){
+ return {
+ draw: drawText,
+ update: () => {},
+ style: "black",
+ x, y, text, font
+ }
} \ No newline at end of file
diff --git a/src/paperflight/static/levels.js b/src/paperflight/static/levels.js
index e1628b1..70bd326 100644
--- a/src/paperflight/static/levels.js
+++ b/src/paperflight/static/levels.js
@@ -13,8 +13,31 @@ function createLevel(title, coinsNeeded, exitX, exitY) {
}
}
var levels = {}
-levels[1] = createLevel("Downwards Dash", 5, 40, 460)
+levels[1] = createLevel("Welcome", 0, 400, 250)
levels[1].items.push(
+ constructText(30, 60, "Use left and right to fly into the exit", "30px Courier")
+)
+
+levels[2] = createLevel("Controls!", 0, 400, 250)
+levels[2].items.push(
+ constructText(30, 60, "Press down or up to change speed", "30px Courier")
+)
+
+levels[3] = createLevel("Coins!", 1, 400, 250)
+levels[3].items.push(
+ constructText(30, 60, "Collect the needed coins to continue", "30px Courier"),
+ constructCoin(400, 200)
+)
+
+levels[4] = createLevel("Getting harder...", 0, 700, 200)
+levels[4].items.push(
+ constructText(30, 60, "Avoid walls, use the vent", "30px Courier"),
+ constructBlock(600, 120, 10, 500),
+ constructVent(500, 550, 90, 600)
+)
+
+levels[5] = createLevel("Downwards Dash", 5, 40, 460)
+levels[5].items.push(
constructVent(420, 580, 60, 600),
constructCoin(40, 80),
constructVent(120, 100, 280, 100),
@@ -27,8 +50,8 @@ levels[1].items.push(
constructCoin(170, 405),
)
-levels[2] = createLevel("Switch madness", 0, 40, 460)
-levels[2].items.push(
+levels[6] = createLevel("Switch madness", 0, 40, 460)
+levels[6].items.push(
constructSwitch(120, 400, 60, 60, 3),
constructRect(300, 400, 60, 60, 0),
constructRect(400, 400, 60, 60, 1),