diff --git a/.gitignore b/.gitignore index 075dc7d..04f6152 100755 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ api.sock *swp *swo +# web +node_modules/ # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/api.py b/api.py index 487176b..eec66d9 100755 --- a/api.py +++ b/api.py @@ -1,10 +1,9 @@ -from flask import Flask - +from flask import Flask, render_template app = Flask(__name__) @app.route('/') def home(): - return '

Hey yo!

' + return render_template('index.html') if __name__ == '__main__': app.run(host='0.0.0.0') diff --git a/static/LICENSE b/static/LICENSE new file mode 100644 index 0000000..4d0a325 --- /dev/null +++ b/static/LICENSE @@ -0,0 +1,24 @@ +BSD 2-Clause License + +Copyright (c) 2023, Ayo Ayco + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/static/README.md b/static/README.md new file mode 100644 index 0000000..eadc378 --- /dev/null +++ b/static/README.md @@ -0,0 +1,3 @@ +# A crazy invention by Kahel and Ayo + +![screenshot](./kaboom.gif) \ No newline at end of file diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..bdb42ab --- /dev/null +++ b/static/index.html @@ -0,0 +1,26 @@ + + + + + + Twists and Shapes and Turns + + + + +

Hello Kahel!

+ + + +
+
+
+ + + diff --git a/static/index.js b/static/index.js new file mode 100644 index 0000000..54768c9 --- /dev/null +++ b/static/index.js @@ -0,0 +1,80 @@ +// module aliases +let { Engine, Render, Runner, Bodies, Composite } = Matter; + +// create an engine +let engine = Engine.create({ + timing: { + timeScale: 0.3, + }, +}); + +const width = window.innerWidth > 0 ? window.innerWidth : screen.width; +const height = window.innerHeight > 0 ? window.innerHeight : screen.height; + +// create runner +let runner = Runner.create(); +let ground = Bodies.rectangle(width / 2, height - 300, width / 2, 60, { + isStatic: true, +}); + +// create a renderer +let render = Render.create({ + element: document.getElementById("canvas"), + engine: engine, + options: { + width: width - 18, + height: height - 150, + }, +}); + +generateWorld(); + +function clearTheWorld() { + Composite.clear(engine.world); + Composite.add(engine.world, ground); +} + +function kaboom() { + let manyShapes = new Array(50) + .fill() + .map(() => + Bodies.polygon( + Math.random() * 1 + width / 2, + Math.random() * 450 + 1, + Math.random() * 16 + 1, + Math.random() * 80 + 1 + ) + ); + + // add all of the bodies to the world + Composite.add(engine.world, manyShapes); + + // run the engine + Runner.run(runner, engine); +} + +function addShape() { + // to be continued + // let oneShape = Bodies.circle(80, 80, 80); + let oneShape = Bodies.polygon( + // Math.random() * (width / 2) + 1, + width / 2, + 0, + Math.random() * 12 + 1, + Math.random() * 150 + 100 + ); + Composite.add(engine.world, oneShape); + + // run the engine + Runner.run(runner, engine); +} + +function generateWorld() { + Composite.add(engine.world, ground); + + // run the renderer + Render.run(render); + + // run the engine + Runner.run(runner, engine); +} diff --git a/static/kaboom.gif b/static/kaboom.gif new file mode 100644 index 0000000..1b7ab31 Binary files /dev/null and b/static/kaboom.gif differ diff --git a/static/package-lock.json b/static/package-lock.json new file mode 100644 index 0000000..1bb625d --- /dev/null +++ b/static/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "twists-and-shapes-and-turns", + "version": "0.0.1", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "twists-and-shapes-and-turns", + "version": "0.0.1", + "license": "ISC", + "dependencies": { + "matter-js": "^0.18.0" + } + }, + "node_modules/matter-js": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/matter-js/-/matter-js-0.18.0.tgz", + "integrity": "sha512-/ZVem4WygUnbmo/iE4oHZpZS97btfBtYy5Iwn1396vUZU7YhgVEN8J4UWwfZwY1ZqoTYlPgjvSw9WXauuXL0mg==" + } + }, + "dependencies": { + "matter-js": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/matter-js/-/matter-js-0.18.0.tgz", + "integrity": "sha512-/ZVem4WygUnbmo/iE4oHZpZS97btfBtYy5Iwn1396vUZU7YhgVEN8J4UWwfZwY1ZqoTYlPgjvSw9WXauuXL0mg==" + } + } +} diff --git a/static/package.json b/static/package.json new file mode 100644 index 0000000..589fa01 --- /dev/null +++ b/static/package.json @@ -0,0 +1,16 @@ +{ + "name": "twists-and-shapes-and-turns", + "version": "0.0.1", + "description": "This is a game about crazy inventions", + "main": "index.js", + "scripts": { + "start": "npx http-server .", + "test": "echo \"Error: no test specified\" && exit 1", + "deploy": "scp -r . ayo@ayco.io:~/kaboom/" + }, + "author": "Ayo and Kahel", + "license": "ISC", + "dependencies": { + "matter-js": "^0.18.0" + } +} diff --git a/static/screenshot.png b/static/screenshot.png new file mode 100644 index 0000000..f979ef6 Binary files /dev/null and b/static/screenshot.png differ diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..bdb42ab --- /dev/null +++ b/templates/index.html @@ -0,0 +1,26 @@ + + + + + + Twists and Shapes and Turns + + + + +

Hello Kahel!

+ + + +
+
+
+ + +