diff options
author | Mark Powers <markppowers0@gmail.com> | 2020-05-13 22:39:19 -0500 |
---|---|---|
committer | Mark Powers <markppowers0@gmail.com> | 2020-05-13 22:39:19 -0500 |
commit | 7889250b115eec8709c0c9ff8345e0bef88037b5 (patch) | |
tree | 6e20aa84ff1361e23b569811e617951518faa1aa /src/paperflight/static | |
parent | e0552a705e3ddfd79a684ee7a67ca02f57fbb2bc (diff) |
Add item constructors
Diffstat (limited to 'src/paperflight/static')
-rw-r--r-- | src/paperflight/static/items.js | 42 | ||||
-rw-r--r-- | src/paperflight/static/levels.js | 143 |
2 files changed, 61 insertions, 124 deletions
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 |