aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Powers <markppowers0@gmail.com>2020-05-13 22:39:19 -0500
committerMark Powers <markppowers0@gmail.com>2020-05-13 22:39:19 -0500
commit7889250b115eec8709c0c9ff8345e0bef88037b5 (patch)
tree6e20aa84ff1361e23b569811e617951518faa1aa
parente0552a705e3ddfd79a684ee7a67ca02f57fbb2bc (diff)
Add item constructors
-rw-r--r--src/paperflight/index.html1
-rw-r--r--src/paperflight/server.js1
-rw-r--r--src/paperflight/static/items.js42
-rw-r--r--src/paperflight/static/levels.js143
4 files changed, 63 insertions, 124 deletions
diff --git a/src/paperflight/index.html b/src/paperflight/index.html
index c22f322..dc60794 100644
--- a/src/paperflight/index.html
+++ b/src/paperflight/index.html
@@ -18,6 +18,7 @@
</script>
<script src="/paperflight/update.js"></script>
<script src="/paperflight/draw.js"></script>
+ <script src="/paperflight/items.js"></script>
<script src="/paperflight/levels.js"></script>
<script>
var username = undefined
diff --git a/src/paperflight/server.js b/src/paperflight/server.js
index 1f05de2..35a2669 100644
--- a/src/paperflight/server.js
+++ b/src/paperflight/server.js
@@ -4,6 +4,7 @@ function setUpRoutes(server, models, jwtFunctions, database) {
server.get('/paperflight/levels.js', (req, res) => res.sendFile(__dirname + "/static/levels.js"))
server.get('/paperflight/update.js', (req, res) => res.sendFile(__dirname + "/static/update.js"))
server.get('/paperflight/draw.js', (req, res) => res.sendFile(__dirname + "/static/draw.js"))
+ server.get('/paperflight/items.js', (req, res) => res.sendFile(__dirname + "/static/items.js"))
}
module.exports = {
diff --git a/src/paperflight/static/items.js b/src/paperflight/static/items.js
new file mode 100644
index 0000000..11c2047
--- /dev/null
+++ b/src/paperflight/static/items.js
@@ -0,0 +1,42 @@
+function vent(x, y, width, height){
+ return {
+ draw: drawVent,
+ update: updateVent,
+ x, y, width, height
+ }
+}
+function coin(x, y, radius=10){
+ return {
+ draw: drawCoin,
+ update: updateCoin,
+ x, y, radius
+ }
+}
+function block(x, y, width, height){
+ return {
+ draw: drawBlock,
+ update: updateBlock,
+ x, y, width, height
+ }
+}
+function ramp(x, y, width, height, slope){
+ return {
+ draw: drawRamp,
+ update: updateRamp,
+ x, y, width, height, slope
+ }
+}
+function getSwitch(x, y, width, height, stateCount){
+ return {
+ draw: drawSwitch,
+ update: updateSwitch,
+ x, y, width, height, stateCount
+ }
+}
+function switchRect(x, y, width, height, state){
+ return{
+ draw: drawSwitchRect,
+ update: updateSwitchRect,
+ x, y, width, height, state
+ }
+} \ No newline at end of file
diff --git a/src/paperflight/static/levels.js b/src/paperflight/static/levels.js
index aba9712..33d011c 100644
--- a/src/paperflight/static/levels.js
+++ b/src/paperflight/static/levels.js
@@ -1,142 +1,37 @@
var levels = {
- 1: {
+ 2: {
coinsNeeded: 0,
exit: {
x: 40,
y: 460
},
title: "Switch madness",
- items: [{
- draw: drawSwitch,
- update: updateSwitch,
- x: 120,
- y: 400,
- width: 60,
- height: 60,
- stateCount: 3
- },
- {
- draw: drawSwitchRect,
- update: updateSwitchRect,
- x: 300,
- y: 400,
- width: 60,
- height: 60,
- state: 0
- },
- {
- draw: drawSwitchRect,
- update: updateSwitchRect,
- x: 400,
- y: 400,
- width: 60,
- height: 60,
- state: 1
- },
- {
- draw: drawSwitchRect,
- update: updateSwitchRect,
- x: 500,
- y: 400,
- width: 60,
- height: 60,
- state: 2
- },
+ items: [
+ getSwitch(120, 400, 60, 60, 3),
+ switchRect(300, 400, 60, 60, 0),
+ switchRect(400, 400, 60, 60, 1),
+ switchRect(500, 400, 60, 60, 2),
]
},
- 2: {
+ 1: {
coinsNeeded: 5,
exit: {
x: 40,
y: 460
},
title: "Downwards Dash",
- items: [{
- draw: drawVent,
- update: updateVent,
- x: 420,
- y: 580,
- width: 60,
- height: 600
- },
- {
- draw: drawCoin,
- update: updateCoin,
- x: 40,
- y: 80,
- radius: 10
- },
- {
- draw: drawVent,
- update: updateVent,
- x: 120,
- y: 100,
- width: 280,
- height: 100
- },
- {
- draw: drawBlock,
- update: updateBlock,
- x: 580,
- y: 200,
- width: 10,
- height: 250
- },
- {
- draw: drawCoin,
- update: updateCoin,
- x: 700,
- y: 240,
- radius: 10
- },
- {
- draw: drawCoin,
- update: updateCoin,
- x: 700,
- y: 320,
- radius: 10
- },
- {
- draw: drawCoin,
- update: updateCoin,
- x: 700,
- y: 400,
- radius: 10
- },
- {
- draw: drawRamp,
- update: updateRamp,
- x: 70,
- y: 410,
- slope: 2 / 5,
- width: 200,
- height: 10
- },
- {
- draw: drawRamp,
- update: updateRamp,
- x: 70,
- y: 470,
- slope: 2 / 5,
- width: 200,
- height: 10
- },
- {
- draw: drawCoin,
- update: updateCoin,
- x: 170,
- y: 405,
- radius: 10
- },
- {
- draw: drawRamp,
- update: updateRamp,
- x: 0,
- y: 0,
- slope: 0,
- width: 800,
- height: 40
- },
+ items: [
+ vent(420, 580, 60, 600),
+ coin(40, 80),
+ vent(120, 100, 280, 100),
+ block(580, 200, 10, 250),
+ coin(700, 240),
+ coin(700, 320),
+ coin(700, 400),
+ ramp(70, 410, 200, 10, 2/5),
+ ramp(70, 470, 200, 10, 2/5),
+ coin(170, 405),
+ block(0, 0, 800, 40)
]
}
} \ No newline at end of file