diff options
author | Mark Powers <markppowers0@gmail.com> | 2020-05-14 11:27:58 -0500 |
---|---|---|
committer | Mark Powers <markppowers0@gmail.com> | 2020-05-14 11:27:58 -0500 |
commit | 67d08e1f07d6eb261b98e90e6c803d64c22c1969 (patch) | |
tree | ad1b3b0f67cecb9dadb9a95b50f8fa7d74ec9b12 /src/paperflight/static | |
parent | 0ec9047997e3ecaf7c4973baaa2e7b6b52e8144c (diff) |
Add text item, create tutorial stages
Diffstat (limited to 'src/paperflight/static')
-rw-r--r-- | src/paperflight/static/draw.js | 14 | ||||
-rw-r--r-- | src/paperflight/static/items.js | 8 | ||||
-rw-r--r-- | src/paperflight/static/levels.js | 29 |
3 files changed, 46 insertions, 5 deletions
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), |