added hammer, prop targets falling and attentive meter, and references to sources used in readme
This commit is contained in:
46
README.md
46
README.md
@@ -1,43 +1,3 @@
|
|||||||
# Svelte + Vite
|
Commodore 64 by Jason Toff [CC-BY] via Poly Pizza
|
||||||
|
https://freefrontend.com/code/procedural-3d-endless-runner-game-2026-02-24/?utm_source=chatgpt.com
|
||||||
This template should help get you started developing with Svelte in Vite.
|
using perplexity, gemini, google ai studio
|
||||||
|
|
||||||
## Recommended IDE Setup
|
|
||||||
|
|
||||||
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode).
|
|
||||||
|
|
||||||
## Need an official Svelte framework?
|
|
||||||
|
|
||||||
Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.
|
|
||||||
|
|
||||||
## Technical considerations
|
|
||||||
|
|
||||||
**Why use this over SvelteKit?**
|
|
||||||
|
|
||||||
- It brings its own routing solution which might not be preferable for some users.
|
|
||||||
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.
|
|
||||||
|
|
||||||
This template contains as little as possible to get started with Vite + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.
|
|
||||||
|
|
||||||
Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate.
|
|
||||||
|
|
||||||
**Why include `.vscode/extensions.json`?**
|
|
||||||
|
|
||||||
Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project.
|
|
||||||
|
|
||||||
**Why enable `checkJs` in the JS template?**
|
|
||||||
|
|
||||||
It is likely that most cases of changing variable types in runtime are likely to be accidental, rather than deliberate. This provides advanced typechecking out of the box. Should you like to take advantage of the dynamically-typed nature of JavaScript, it is trivial to change the configuration.
|
|
||||||
|
|
||||||
**Why is HMR not preserving my local component state?**
|
|
||||||
|
|
||||||
HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/sveltejs/svelte-hmr/tree/master/packages/svelte-hmr#preservation-of-local-state).
|
|
||||||
|
|
||||||
If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR.
|
|
||||||
|
|
||||||
```js
|
|
||||||
// store.js
|
|
||||||
// An extremely simple external store
|
|
||||||
import { writable } from 'svelte/store'
|
|
||||||
export default writable(0)
|
|
||||||
```
|
|
||||||
|
|||||||
BIN
Simple computer.glb
Normal file
BIN
Simple computer.glb
Normal file
Binary file not shown.
BIN
monitor.glb
Normal file
BIN
monitor.glb
Normal file
Binary file not shown.
179
package-lock.json
generated
179
package-lock.json
generated
@@ -8,6 +8,7 @@
|
|||||||
"name": "neurorunner",
|
"name": "neurorunner",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"p5": "^2.2.3",
|
||||||
"three": "^0.184.0"
|
"three": "^0.184.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -16,6 +17,21 @@
|
|||||||
"vite": "^8.0.9"
|
"vite": "^8.0.9"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@babel/runtime": {
|
||||||
|
"version": "7.29.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.2.tgz",
|
||||||
|
"integrity": "sha512-JiDShH45zKHWyGe4ZNVRrCjBz8Nh9TMmZG1kh4QTK8hCBTWBi8Da+i7s1fJw7/lYpM4ccepSNfqzZ/QvABBi5g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.9.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@davepagurek/bezier-path": {
|
||||||
|
"version": "0.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@davepagurek/bezier-path/-/bezier-path-0.0.7.tgz",
|
||||||
|
"integrity": "sha512-CVlnCOrV1iy4Z12T756i9l4G6kF7r8uhlnb+xqDemAMmWQB+8Q0b+8VEqIiUfywgZDSiDr18Rm7pZlnA69rE8Q==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@emnapi/core": {
|
"node_modules/@emnapi/core": {
|
||||||
"version": "1.9.2",
|
"version": "1.9.2",
|
||||||
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.9.2.tgz",
|
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.9.2.tgz",
|
||||||
@@ -50,6 +66,12 @@
|
|||||||
"tslib": "^2.4.0"
|
"tslib": "^2.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@japont/unicode-range": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@japont/unicode-range/-/unicode-range-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-BckHvA2XdjRBVAWe2uceNuRf78lBeI28kyWEbfr/Q2pE17POkwuZ6WWY/UMv8FL9iBxhW4xfDoNLM9UVZaTeUQ==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@jridgewell/gen-mapping": {
|
"node_modules/@jridgewell/gen-mapping": {
|
||||||
"version": "0.3.13",
|
"version": "0.3.13",
|
||||||
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
||||||
@@ -452,7 +474,6 @@
|
|||||||
"version": "8.16.0",
|
"version": "8.16.0",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz",
|
||||||
"integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
|
"integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"acorn": "bin/acorn"
|
"acorn": "bin/acorn"
|
||||||
@@ -461,6 +482,18 @@
|
|||||||
"node": ">=0.4.0"
|
"node": ">=0.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/acorn-walk": {
|
||||||
|
"version": "8.3.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.5.tgz",
|
||||||
|
"integrity": "sha512-HEHNfbars9v4pgpW6SO1KSPkfoS0xVOM/9UzkJltjlsHZmJasxg8aXkuZa7SMf8vKGIBhpUsPluQSqhJFCqebw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"acorn": "^8.11.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/aria-query": {
|
"node_modules/aria-query": {
|
||||||
"version": "5.3.1",
|
"version": "5.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.1.tgz",
|
||||||
@@ -491,6 +524,16 @@
|
|||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/colorjs.io": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/colorjs.io/-/colorjs.io-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-8lyR2wHzuIykCpqHKgluGsqQi5iDm3/a2IgP2GBZrasn2sBRkE4NOGsglZxWLs/jZQoNkmA/KM/8NV16rLUdBg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/color"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/deepmerge": {
|
"node_modules/deepmerge": {
|
||||||
"version": "4.3.1",
|
"version": "4.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
|
||||||
@@ -518,6 +561,27 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/escodegen": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==",
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"esprima": "^4.0.1",
|
||||||
|
"estraverse": "^5.2.0",
|
||||||
|
"esutils": "^2.0.2"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"escodegen": "bin/escodegen.js",
|
||||||
|
"esgenerate": "bin/esgenerate.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"source-map": "~0.6.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/esm-env": {
|
"node_modules/esm-env": {
|
||||||
"version": "1.2.2",
|
"version": "1.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/esm-env/-/esm-env-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/esm-env/-/esm-env-1.2.2.tgz",
|
||||||
@@ -525,6 +589,19 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/esprima": {
|
||||||
|
"version": "4.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||||
|
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"bin": {
|
||||||
|
"esparse": "bin/esparse.js",
|
||||||
|
"esvalidate": "bin/esvalidate.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/esrap": {
|
"node_modules/esrap": {
|
||||||
"version": "2.2.5",
|
"version": "2.2.5",
|
||||||
"resolved": "https://registry.npmjs.org/esrap/-/esrap-2.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/esrap/-/esrap-2.2.5.tgz",
|
||||||
@@ -543,6 +620,24 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/estraverse": {
|
||||||
|
"version": "5.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
|
||||||
|
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/esutils": {
|
||||||
|
"version": "2.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
|
||||||
|
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/fdir": {
|
"node_modules/fdir": {
|
||||||
"version": "6.5.0",
|
"version": "6.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
|
||||||
@@ -576,6 +671,30 @@
|
|||||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/gifenc": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/gifenc/-/gifenc-1.0.3.tgz",
|
||||||
|
"integrity": "sha512-xdr6AdrfGBcfzncONUOlXMBuc5wJDtOueE3c5rdG0oNgtINLD+f2iFZltrBRZYzACRbKr+mSVU/x98zv2u3jmw==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/i18next": {
|
||||||
|
"version": "19.9.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/i18next/-/i18next-19.9.2.tgz",
|
||||||
|
"integrity": "sha512-0i6cuo6ER6usEOtKajUUDj92zlG+KArFia0857xxiEHAQcUwh/RtOQocui1LPJwunSYT574Pk64aNva1kwtxZg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/runtime": "^7.12.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/i18next-browser-languagedetector": {
|
||||||
|
"version": "4.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/i18next-browser-languagedetector/-/i18next-browser-languagedetector-4.3.1.tgz",
|
||||||
|
"integrity": "sha512-KIToAzf8zwWvacgnRwJp63ase26o24AuNUlfNVJ5YZAFmdGhsJpmFClxXPuk9rv1FMI4lnc8zLSqgZPEZMrW4g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/runtime": "^7.5.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/is-reference": {
|
"node_modules/is-reference": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz",
|
||||||
@@ -586,6 +705,12 @@
|
|||||||
"@types/estree": "^1.0.6"
|
"@types/estree": "^1.0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/libtess": {
|
||||||
|
"version": "1.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/libtess/-/libtess-1.2.2.tgz",
|
||||||
|
"integrity": "sha512-Nps8HPeVVcsmJxUvFLKVJcCgcz+1ajPTXDVAVPs6+giOQP4AHV31uZFFkh+CKow/bkB7GbZWKmwmit7myaqDSw==",
|
||||||
|
"license": "SGI-B-2.0"
|
||||||
|
},
|
||||||
"node_modules/lightningcss": {
|
"node_modules/lightningcss": {
|
||||||
"version": "1.32.0",
|
"version": "1.32.0",
|
||||||
"resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz",
|
"resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz",
|
||||||
@@ -894,6 +1019,39 @@
|
|||||||
],
|
],
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/omggif": {
|
||||||
|
"version": "1.0.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/omggif/-/omggif-1.0.10.tgz",
|
||||||
|
"integrity": "sha512-LMJTtvgc/nugXj0Vcrrs68Mn2D1r0zf630VNtqtpI1FEO7e+O9FP4gqs9AcnBaSEeoHIPm28u6qgPR0oyEpGSw==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/p5": {
|
||||||
|
"version": "2.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/p5/-/p5-2.2.3.tgz",
|
||||||
|
"integrity": "sha512-jz9uy0k3Fcj9vKSOafQlIrpaPZZjO4rAEBZF6dGkbokisshP0M3aFm4qtLHYCoEW1XJSkFaVaOMILCQAQxUHHA==",
|
||||||
|
"license": "LGPL-2.1",
|
||||||
|
"dependencies": {
|
||||||
|
"@davepagurek/bezier-path": "^0.0.7",
|
||||||
|
"@japont/unicode-range": "^1.0.0",
|
||||||
|
"acorn": "^8.15.0",
|
||||||
|
"acorn-walk": "^8.3.4",
|
||||||
|
"colorjs.io": "^0.6.0",
|
||||||
|
"escodegen": "^2.1.0",
|
||||||
|
"gifenc": "^1.0.3",
|
||||||
|
"i18next": "^19.0.2",
|
||||||
|
"i18next-browser-languagedetector": "^4.0.1",
|
||||||
|
"libtess": "^1.2.2",
|
||||||
|
"omggif": "^1.0.10",
|
||||||
|
"pako": "^2.1.0",
|
||||||
|
"zod": "^4.2.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/pako": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==",
|
||||||
|
"license": "(MIT AND Zlib)"
|
||||||
|
},
|
||||||
"node_modules/picocolors": {
|
"node_modules/picocolors": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||||
@@ -977,6 +1135,16 @@
|
|||||||
"@rolldown/binding-win32-x64-msvc": "1.0.0-rc.16"
|
"@rolldown/binding-win32-x64-msvc": "1.0.0-rc.16"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/source-map": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"optional": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/source-map-js": {
|
"node_modules/source-map-js": {
|
||||||
"version": "1.2.1",
|
"version": "1.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||||
@@ -1150,6 +1318,15 @@
|
|||||||
"integrity": "sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==",
|
"integrity": "sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/zod": {
|
||||||
|
"version": "4.3.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz",
|
||||||
|
"integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/colinhacks"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
"vite": "^8.0.9"
|
"vite": "^8.0.9"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"p5": "^2.2.3",
|
||||||
"three": "^0.184.0"
|
"three": "^0.184.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
298
src/App.svelte
298
src/App.svelte
@@ -2,27 +2,27 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
|
import p5 from "p5";
|
||||||
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
||||||
import { clone as cloneSkeleton } from "three/examples/jsm/utils/SkeletonUtils.js";
|
import { clone as cloneSkeleton } from "three/examples/jsm/utils/SkeletonUtils.js";
|
||||||
|
|
||||||
const CONFIG = {
|
const CONFIG = { lane: 2.5, jump: 0.35, grav: 0.015, speed: 55, playerScale: 1.7 };
|
||||||
lane: 2.5,
|
|
||||||
jump: 0.35,
|
|
||||||
grav: 0.015,
|
|
||||||
speed: 55, // Keeping your faster speed
|
|
||||||
playerScale: 1.7 // Increased size significantly
|
|
||||||
};
|
|
||||||
|
|
||||||
let score = 0, isPlaying = false, gameOver = false, startScreen = true;
|
let score = 0, isPlaying = false, gameOver = false, startScreen = true;
|
||||||
|
let attentiveness = 100;
|
||||||
let lane = 0, currX = 0, isJumping = false, jumpV = 0, playerY = 0;
|
let lane = 0, currX = 0, isJumping = false, jumpV = 0, playerY = 0;
|
||||||
let container, canvas, scene, camera, renderer;
|
let container, canvas, scene, camera, renderer, p5Container;
|
||||||
let worldObjects = [], animationFrame;
|
let worldObjects = [], animationFrame, p5Instance;
|
||||||
let isDying = false, hitFlash = false;
|
let isDying = false, hitFlash = false;
|
||||||
|
|
||||||
let playerAnchor, currentModel = null, currentMixer = null, swapToken = 0;
|
// 2D Game Logic
|
||||||
|
let gamePhase = "START";
|
||||||
|
let instructionTimer = 3;
|
||||||
|
let targetType = "NEURON";
|
||||||
|
let targets = [];
|
||||||
|
|
||||||
// Treadmill System
|
let playerAnchor, currentModel = null, currentMixer = null, swapToken = 0;
|
||||||
const CHUNKS = [];
|
let CHUNKS = [];
|
||||||
const CHUNK_COUNT = 3;
|
const CHUNK_COUNT = 3;
|
||||||
const CHUNK_SIZE = 140;
|
const CHUNK_SIZE = 140;
|
||||||
|
|
||||||
@@ -31,6 +31,108 @@ const loader = new GLTFLoader();
|
|||||||
const clock = new THREE.Clock();
|
const clock = new THREE.Clock();
|
||||||
const glbCache = new Map();
|
const glbCache = new Map();
|
||||||
|
|
||||||
|
// --- P5 SKETCH (HUD, 2D Hammer & Rare Targets) ---
|
||||||
|
const sketch = (p) => {
|
||||||
|
p.setup = () => {
|
||||||
|
p.createCanvas(p.windowWidth, p.windowHeight);
|
||||||
|
};
|
||||||
|
|
||||||
|
p.draw = () => {
|
||||||
|
p.clear();
|
||||||
|
if (!isPlaying) return;
|
||||||
|
|
||||||
|
if (gamePhase === "INSTRUCTIONS") {
|
||||||
|
p.fill(0, 180);
|
||||||
|
p.rect(0, 0, p.width, p.height);
|
||||||
|
p.fill(255);
|
||||||
|
p.textAlign(p.CENTER);
|
||||||
|
p.textSize(24);
|
||||||
|
p.text(`NEURO-MISSION: CLICK THE ${targetType}`, p.width/2, p.height/2 - 20);
|
||||||
|
p.textSize(60);
|
||||||
|
p.text(Math.ceil(instructionTimer), p.width/2, p.height/2 + 60);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attentiveness Meter
|
||||||
|
p.noFill();
|
||||||
|
p.stroke(255, 100);
|
||||||
|
p.strokeWeight(2);
|
||||||
|
p.rect(20, 20, 200, 20, 10);
|
||||||
|
let color = p.lerpColor(p.color(255, 50, 50), p.color(50, 255, 150), attentiveness / 100);
|
||||||
|
p.fill(color);
|
||||||
|
p.noStroke();
|
||||||
|
let w = (attentiveness / 100) * 200;
|
||||||
|
if (attentiveness < 30) w += p.sin(p.frameCount * 0.2) * 5;
|
||||||
|
p.rect(20, 20, Math.max(0, w), 20, 10);
|
||||||
|
|
||||||
|
// Spawning Rare 2D Targets (0.4% chance)
|
||||||
|
if (p.random(1) < 0.004) {
|
||||||
|
const types = ["NEURON", "SUGAR", "GLITCH"];
|
||||||
|
targets.push({
|
||||||
|
x: p.random(p.width * 0.2, p.width * 0.8),
|
||||||
|
y: -50,
|
||||||
|
type: types[p.floor(p.random(types.length))],
|
||||||
|
speed: p.random(1.5, 3),
|
||||||
|
rot: 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process 2D Targets
|
||||||
|
for (let i = targets.length - 1; i >= 0; i--) {
|
||||||
|
let t = targets[i];
|
||||||
|
t.y += t.speed;
|
||||||
|
t.rot += 0.02;
|
||||||
|
|
||||||
|
p.push();
|
||||||
|
p.translate(t.x, t.y);
|
||||||
|
p.rotate(t.rot);
|
||||||
|
p.strokeWeight(2);
|
||||||
|
if (t.type === "NEURON") {
|
||||||
|
p.stroke(0, 255, 200); p.noFill();
|
||||||
|
for(let j=0; j<8; j++) p.line(0,0, p.cos(j)*20, p.sin(j)*20);
|
||||||
|
p.ellipse(0, 0, 12);
|
||||||
|
} else if (t.type === "SUGAR") {
|
||||||
|
p.fill(255, 105, 180); p.noStroke();
|
||||||
|
p.ellipse(0, 0, 25, 25); p.fill(255); p.ellipse(0, 0, 8);
|
||||||
|
} else {
|
||||||
|
p.fill(255, 50, 0); p.noStroke();
|
||||||
|
p.rect(-12, -12, 24, 24);
|
||||||
|
}
|
||||||
|
p.pop();
|
||||||
|
|
||||||
|
if (t.y > p.height + 50) targets.splice(i, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2D Hammer
|
||||||
|
p.push();
|
||||||
|
p.translate(p.mouseX, p.mouseY);
|
||||||
|
p.rotate(-0.4);
|
||||||
|
p.fill(120, 80, 50); p.noStroke();
|
||||||
|
p.rect(-5, 0, 10, 40, 2);
|
||||||
|
p.fill(100);
|
||||||
|
p.rect(-20, -10, 40, 20, 4);
|
||||||
|
p.pop();
|
||||||
|
};
|
||||||
|
|
||||||
|
p.mousePressed = () => {
|
||||||
|
if (gamePhase !== "PLAYING") return;
|
||||||
|
for (let i = targets.length - 1; i >= 0; i--) {
|
||||||
|
let t = targets[i];
|
||||||
|
if (p.dist(p.mouseX, p.mouseY, t.x, t.y) < 40) {
|
||||||
|
if (t.type === targetType) {
|
||||||
|
score += 100;
|
||||||
|
attentiveness = Math.min(100, attentiveness + 15);
|
||||||
|
} else {
|
||||||
|
attentiveness -= 20;
|
||||||
|
}
|
||||||
|
targets.splice(i, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// --- SHADERS ---
|
||||||
const grassVertex = `
|
const grassVertex = `
|
||||||
varying vec2 vUv;
|
varying vec2 vUv;
|
||||||
uniform float uTime;
|
uniform float uTime;
|
||||||
@@ -50,35 +152,40 @@ const grassFragment = `
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
function createWorldChunk(zOffset) {
|
// --- WORLD GENERATION ---
|
||||||
|
const createClouds = (group) => {
|
||||||
|
const cloudMaterial = new THREE.MeshLambertMaterial({ color: 0xffffff, transparent: true, opacity: 0.8 });
|
||||||
|
const thickness = 2;
|
||||||
|
const cloudMeshes = Array.from({ length: 20 }).map(() => {
|
||||||
|
const w = 10 + Math.random() * 20;
|
||||||
|
const d = 10 + Math.random() * 20;
|
||||||
|
const cloud = new THREE.Mesh(new THREE.BoxGeometry(w, thickness, d), cloudMaterial);
|
||||||
|
cloud.position.set((Math.random() - 0.5) * 280, 35, (Math.random() - 0.5) * 300);
|
||||||
|
return cloud;
|
||||||
|
});
|
||||||
|
group.add(...cloudMeshes);
|
||||||
|
};
|
||||||
|
|
||||||
|
const createWorldChunk = (zOffset) => {
|
||||||
const group = new THREE.Group();
|
const group = new THREE.Group();
|
||||||
group.position.z = zOffset;
|
group.position.z = zOffset;
|
||||||
|
const floor = new THREE.Mesh(new THREE.PlaneGeometry(160, CHUNK_SIZE + 0.1), new THREE.MeshStandardMaterial({ color: 0x1e2b21 }));
|
||||||
const floor = new THREE.Mesh(
|
|
||||||
new THREE.PlaneGeometry(160, CHUNK_SIZE + 0.1),
|
|
||||||
new THREE.MeshStandardMaterial({ color: 0x1e2b21 })
|
|
||||||
);
|
|
||||||
floor.rotation.x = -Math.PI / 2;
|
floor.rotation.x = -Math.PI / 2;
|
||||||
group.add(floor);
|
group.add(floor);
|
||||||
|
|
||||||
const count = 7000; // Adjusted for slightly larger floor
|
const count = 7000;
|
||||||
const geo = new THREE.PlaneGeometry(0.4, 0.9, 1, 2);
|
const geo = new THREE.PlaneGeometry(0.4, 0.9, 1, 2);
|
||||||
geo.translate(0, 0.45, 0);
|
geo.translate(0, 0.45, 0);
|
||||||
const mat = new THREE.ShaderMaterial({
|
const mat = new THREE.ShaderMaterial({
|
||||||
uniforms: { uTime },
|
uniforms: { uTime }, vertexShader: grassVertex, fragmentShader: grassFragment,
|
||||||
vertexShader: grassVertex,
|
side: THREE.DoubleSide, alphaToCoverage: true
|
||||||
fragmentShader: grassFragment,
|
|
||||||
side: THREE.DoubleSide,
|
|
||||||
alphaToCoverage: true
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const mesh = new THREE.InstancedMesh(geo, mat, count);
|
const mesh = new THREE.InstancedMesh(geo, mat, count);
|
||||||
const dummy = new THREE.Object3D();
|
const dummy = new THREE.Object3D();
|
||||||
for(let i=0; i<count; i++) {
|
for(let i=0; i<count; i++) {
|
||||||
let x = (Math.random() - 0.5) * 120;
|
let x = (Math.random() - 0.5) * 120;
|
||||||
if (x > -10 && x < 10) x += (x > 0) ? 10 : -10;
|
if (x > -10 && x < 10) x += (x > 0) ? 10 : -10;
|
||||||
let z = (Math.random() - 0.5) * CHUNK_SIZE;
|
dummy.position.set(x, 0, (Math.random() - 0.5) * CHUNK_SIZE);
|
||||||
dummy.position.set(x, 0, z);
|
|
||||||
dummy.rotation.y = Math.random() * Math.PI;
|
dummy.rotation.y = Math.random() * Math.PI;
|
||||||
dummy.scale.setScalar(0.7 + Math.random() * 1.6);
|
dummy.scale.setScalar(0.7 + Math.random() * 1.6);
|
||||||
dummy.updateMatrix();
|
dummy.updateMatrix();
|
||||||
@@ -86,13 +193,11 @@ function createWorldChunk(zOffset) {
|
|||||||
}
|
}
|
||||||
group.add(mesh);
|
group.add(mesh);
|
||||||
return group;
|
return group;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// --- CORE LOGIC ---
|
||||||
async function getCachedGLTF(file) {
|
async function getCachedGLTF(file) {
|
||||||
if (!glbCache.has(file)) {
|
if (!glbCache.has(file)) glbCache.set(file, await loader.loadAsync(file));
|
||||||
const gltf = await loader.loadAsync(file);
|
|
||||||
glbCache.set(file, gltf);
|
|
||||||
}
|
|
||||||
return glbCache.get(file);
|
return glbCache.get(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,24 +205,15 @@ async function swapCharacter(file, isDeathAnimation = false) {
|
|||||||
const myToken = ++swapToken;
|
const myToken = ++swapToken;
|
||||||
const source = await getCachedGLTF(file);
|
const source = await getCachedGLTF(file);
|
||||||
if (myToken !== swapToken) return;
|
if (myToken !== swapToken) return;
|
||||||
|
|
||||||
const model = cloneSkeleton(source.scene);
|
const model = cloneSkeleton(source.scene);
|
||||||
model.scale.setScalar(CONFIG.playerScale);
|
model.scale.setScalar(CONFIG.playerScale);
|
||||||
model.rotation.y = Math.PI;
|
model.rotation.y = Math.PI;
|
||||||
|
|
||||||
const mixer = new THREE.AnimationMixer(model);
|
const mixer = new THREE.AnimationMixer(model);
|
||||||
if (source.animations?.length) {
|
if (source.animations?.length) {
|
||||||
const action = mixer.clipAction(source.animations[0]);
|
const action = mixer.clipAction(source.animations[0]);
|
||||||
|
if (isDeathAnimation) { action.setLoop(THREE.LoopOnce, 1); action.clampWhenFinished = true; }
|
||||||
if (isDeathAnimation) {
|
|
||||||
action.setLoop(THREE.LoopOnce, 1);
|
|
||||||
action.clampWhenFinished = true; // STOPS AT THE LAST FRAME
|
|
||||||
action.play();
|
|
||||||
} else {
|
|
||||||
action.play();
|
action.play();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (currentModel) playerAnchor.remove(currentModel);
|
if (currentModel) playerAnchor.remove(currentModel);
|
||||||
currentModel = model; currentMixer = mixer;
|
currentModel = model; currentMixer = mixer;
|
||||||
playerAnchor.add(currentModel);
|
playerAnchor.add(currentModel);
|
||||||
@@ -125,24 +221,32 @@ async function swapCharacter(file, isDeathAnimation = false) {
|
|||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
scene = new THREE.Scene();
|
scene = new THREE.Scene();
|
||||||
const skyColor = 0xa4c3b2;
|
const skyColor = 0x87CEFA;
|
||||||
scene.background = new THREE.Color(skyColor);
|
scene.background = new THREE.Color(skyColor);
|
||||||
scene.fog = new THREE.Fog(skyColor, 35, 150);
|
scene.fog = new THREE.Fog(skyColor, 150, 350);
|
||||||
|
|
||||||
camera = new THREE.PerspectiveCamera(60, 1, 0.1, 1000);
|
camera = new THREE.PerspectiveCamera(60, 1, 0.1, 1000);
|
||||||
camera.position.set(0, 4.5, 13); // Lowered slightly to match bigger player
|
camera.position.set(0, 4.5, 13);
|
||||||
camera.lookAt(0, 1, -5);
|
camera.lookAt(0, 1, -5);
|
||||||
|
|
||||||
renderer = new THREE.WebGLRenderer({ canvas, antialias: true });
|
renderer = new THREE.WebGLRenderer({ canvas, antialias: true });
|
||||||
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.5));
|
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.5));
|
||||||
|
|
||||||
scene.add(new THREE.AmbientLight(0xffffff, 1.2));
|
const lights = [
|
||||||
|
new THREE.AmbientLight(0xffffff, 1.8),
|
||||||
|
new THREE.DirectionalLight(0xffffff, 1.2)
|
||||||
|
];
|
||||||
|
lights[1].position.set(0, 50, 0);
|
||||||
|
scene.add(...lights);
|
||||||
|
|
||||||
for (let i = 0; i < CHUNK_COUNT; i++) {
|
// Re-added Clouds
|
||||||
|
const cloudGroup = new THREE.Group();
|
||||||
|
createClouds(cloudGroup);
|
||||||
|
scene.add(cloudGroup);
|
||||||
|
|
||||||
|
CHUNKS = Array.from({ length: CHUNK_COUNT }).map((_, i) => {
|
||||||
const chunk = createWorldChunk(-i * CHUNK_SIZE);
|
const chunk = createWorldChunk(-i * CHUNK_SIZE);
|
||||||
CHUNKS.push(chunk);
|
|
||||||
scene.add(chunk);
|
scene.add(chunk);
|
||||||
}
|
return chunk;
|
||||||
|
});
|
||||||
|
|
||||||
playerAnchor = new THREE.Group();
|
playerAnchor = new THREE.Group();
|
||||||
scene.add(playerAnchor);
|
scene.add(playerAnchor);
|
||||||
@@ -155,32 +259,40 @@ function init() {
|
|||||||
}).observe(container);
|
}).observe(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
function spawn() {
|
async function spawn() {
|
||||||
const l = Math.floor(Math.random() * 5) - 2;
|
const l = Math.floor(Math.random() * 5) - 2;
|
||||||
const mesh = new THREE.Mesh(
|
const source = await getCachedGLTF("Simple computer.glb");
|
||||||
new THREE.BoxGeometry(1.8, 1.8, 1.8),
|
const model = cloneSkeleton(source.scene);
|
||||||
new THREE.MeshStandardMaterial({ color: 0xffffff, transparent: true, opacity: 0.9 })
|
const pivot = new THREE.Group();
|
||||||
);
|
pivot.position.set(l * CONFIG.lane, 0, -130);
|
||||||
mesh.position.set(l * CONFIG.lane, 0.9, -130);
|
model.position.set(0, 0.6, 0);
|
||||||
scene.add(mesh);
|
model.rotation.y = Math.PI;
|
||||||
worldObjects.push({ mesh, lane: l });
|
model.scale.setScalar(5.5);
|
||||||
|
pivot.add(model);
|
||||||
|
scene.add(pivot);
|
||||||
|
worldObjects = [...worldObjects, { mesh: pivot, lane: l }];
|
||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
const delta = clock.getDelta();
|
const delta = clock.getDelta();
|
||||||
uTime.value = clock.getElapsedTime();
|
uTime.value = clock.getElapsedTime();
|
||||||
|
|
||||||
if (currentMixer) currentMixer.update(delta);
|
if (currentMixer) currentMixer.update(delta);
|
||||||
if (!isPlaying) return;
|
if (!isPlaying) return;
|
||||||
|
|
||||||
|
if (gamePhase === "INSTRUCTIONS") {
|
||||||
|
instructionTimer -= delta;
|
||||||
|
if (instructionTimer <= 0) gamePhase = "PLAYING";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const moveStep = CONFIG.speed * delta;
|
const moveStep = CONFIG.speed * delta;
|
||||||
score++;
|
score++;
|
||||||
|
attentiveness -= 0.05;
|
||||||
|
if (attentiveness <= 0) triggerGameOver();
|
||||||
|
|
||||||
CHUNKS.forEach(chunk => {
|
CHUNKS.forEach(chunk => {
|
||||||
chunk.position.z += moveStep;
|
chunk.position.z += moveStep;
|
||||||
if (chunk.position.z > CHUNK_SIZE) {
|
if (chunk.position.z > CHUNK_SIZE) chunk.position.z -= CHUNK_SIZE * CHUNK_COUNT;
|
||||||
chunk.position.z -= CHUNK_SIZE * CHUNK_COUNT;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
currX += (lane * CONFIG.lane - currX) * 0.18;
|
currX += (lane * CONFIG.lane - currX) * 0.18;
|
||||||
@@ -189,23 +301,18 @@ function update() {
|
|||||||
if (isJumping) {
|
if (isJumping) {
|
||||||
jumpV -= CONFIG.grav;
|
jumpV -= CONFIG.grav;
|
||||||
playerY += jumpV;
|
playerY += jumpV;
|
||||||
if (playerY <= 0) {
|
if (playerY <= 0) { playerY = 0; isJumping = false; if (!isDying) swapCharacter("Running.glb"); }
|
||||||
playerY = 0;
|
|
||||||
isJumping = false;
|
|
||||||
if (!isDying) swapCharacter("Running.glb");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
playerAnchor.position.y = playerY;
|
playerAnchor.position.y = playerY;
|
||||||
|
|
||||||
worldObjects = worldObjects.map(obj => {
|
worldObjects = worldObjects.map(obj => {
|
||||||
obj.mesh.position.z += moveStep;
|
obj.mesh.position.z += moveStep;
|
||||||
// Collision box adjusted for larger character
|
if (Math.abs(obj.mesh.position.z) < 1.5 && obj.lane === lane && playerY < 1.5) triggerGameOver();
|
||||||
if (Math.abs(obj.mesh.position.z) < 1.3 && obj.lane === lane && playerY < 1.5) triggerGameOver();
|
|
||||||
return obj;
|
return obj;
|
||||||
}).filter(obj => {
|
}).filter(obj => {
|
||||||
const keep = obj.mesh.position.z < 25;
|
const active = obj.mesh.position.z < 25;
|
||||||
if (!keep) scene.remove(obj.mesh);
|
if (!active) { scene.remove(obj.mesh); attentiveness = Math.min(100, attentiveness + 2); }
|
||||||
return keep;
|
return active;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (score % 30 === 0) spawn();
|
if (score % 30 === 0) spawn();
|
||||||
@@ -213,55 +320,64 @@ function update() {
|
|||||||
|
|
||||||
function triggerGameOver() {
|
function triggerGameOver() {
|
||||||
isPlaying = false; gameOver = true; isDying = true; hitFlash = true;
|
isPlaying = false; gameOver = true; isDying = true; hitFlash = true;
|
||||||
swapCharacter("Falling Back Death.glb", true); // Pass 'true' for death logic
|
swapCharacter("Falling Back Death.glb", true);
|
||||||
setTimeout(() => hitFlash = false, 150);
|
setTimeout(() => hitFlash = false, 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startGame() {
|
async function startGame() {
|
||||||
worldObjects.forEach(obj => scene.remove(obj.mesh));
|
worldObjects.forEach(obj => scene.remove(obj.mesh));
|
||||||
worldObjects = [];
|
worldObjects = [];
|
||||||
score = 0; isPlaying = true; gameOver = false; startScreen = false;
|
targets = [];
|
||||||
|
score = 0; attentiveness = 100; isPlaying = true; gameOver = false; startScreen = false;
|
||||||
|
gamePhase = "INSTRUCTIONS"; instructionTimer = 3;
|
||||||
lane = 0; currX = 0; isJumping = false; jumpV = 0; playerY = 0; isDying = false;
|
lane = 0; currX = 0; isJumping = false; jumpV = 0; playerY = 0; isDying = false;
|
||||||
|
CHUNKS.forEach((chunk, i) => { chunk.position.z = -i * CHUNK_SIZE; });
|
||||||
CHUNKS.forEach((chunk, i) => {
|
|
||||||
chunk.position.z = -i * CHUNK_SIZE;
|
|
||||||
});
|
|
||||||
|
|
||||||
await swapCharacter("Running.glb");
|
await swapCharacter("Running.glb");
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleKeyDown(e) {
|
const handleKeyDown = (e) => {
|
||||||
if (!isPlaying || isDying) return;
|
if (!isPlaying || isDying) return;
|
||||||
if (e.key === "ArrowLeft" && lane > -2) lane--;
|
const actions = {
|
||||||
if (e.key === "ArrowRight" && lane < 2) lane++;
|
ArrowLeft: () => lane > -2 && lane--, a: () => lane > -2 && lane--, A: () => lane > -2 && lane--,
|
||||||
if ((e.key === " " || e.key === "ArrowUp") && !isJumping) {
|
ArrowRight: () => lane < 2 && lane++, d: () => lane < 2 && lane++, D: () => lane < 2 && lane++,
|
||||||
isJumping = true; jumpV = CONFIG.jump; swapCharacter("Jumping.glb");
|
" ": () => !isJumping && (isJumping = true, jumpV = CONFIG.jump, swapCharacter("Jumping.glb")),
|
||||||
}
|
ArrowUp: () => !isJumping && (isJumping = true, jumpV = CONFIG.jump, swapCharacter("Jumping.glb")),
|
||||||
}
|
w: () => !isJumping && (isJumping = true, jumpV = CONFIG.jump, swapCharacter("Jumping.glb")),
|
||||||
|
W: () => !isJumping && (isJumping = true, jumpV = CONFIG.jump, swapCharacter("Jumping.glb"))
|
||||||
|
};
|
||||||
|
actions[e.key]?.();
|
||||||
|
};
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
init();
|
init();
|
||||||
|
p5Instance = new p5(sketch, p5Container);
|
||||||
const loop = () => { animationFrame = requestAnimationFrame(loop); update(); renderer.render(scene, camera); };
|
const loop = () => { animationFrame = requestAnimationFrame(loop); update(); renderer.render(scene, camera); };
|
||||||
loop();
|
loop();
|
||||||
window.addEventListener("keydown", handleKeyDown);
|
window.addEventListener("keydown", handleKeyDown);
|
||||||
return () => { cancelAnimationFrame(animationFrame); window.removeEventListener("keydown", handleKeyDown); };
|
return () => {
|
||||||
|
cancelAnimationFrame(animationFrame);
|
||||||
|
window.removeEventListener("keydown", handleKeyDown);
|
||||||
|
if (p5Instance) p5Instance.remove();
|
||||||
|
};
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
:global(body, html) { margin: 0; padding: 0; height: 100%; overflow: hidden; background: #a4c3b2; }
|
:global(body, html) { margin: 0; padding: 0; height: 100%; overflow: hidden; background: #8cd0f8; cursor: none; }
|
||||||
#wrapper { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
|
#wrapper { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
|
||||||
canvas { width: 100% !important; height: 100% !important; display: block; }
|
canvas { width: 100% !important; height: 100% !important; display: block; }
|
||||||
|
.p5-hud { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 10; width: 100%; height: 100%; }
|
||||||
.ui { position: absolute; inset: 0; pointer-events: none; color: white; text-align: center; font-family: 'Segoe UI', sans-serif; }
|
.ui { position: absolute; inset: 0; pointer-events: none; color: white; text-align: center; font-family: 'Segoe UI', sans-serif; }
|
||||||
.score { font-size: 2.5rem; margin-top: 30px; font-weight: 800; text-shadow: 0 4px 10px rgba(0,0,0,0.2); }
|
.score { font-size: 2.5rem; margin-top: 60px; font-weight: 800; text-shadow: 0 4px 10px rgba(0,0,0,0.2); }
|
||||||
.modal { pointer-events: auto; background: rgba(255, 255, 255, 0.98); padding: 50px; border-radius: 30px; margin-top: 10vh; color: #1e2b21; display: inline-block; box-shadow: 0 25px 60px rgba(0,0,0,0.15); }
|
.modal { pointer-events: auto; background: rgba(255, 255, 255, 0.98); padding: 50px; border-radius: 30px; margin-top: 10vh; color: #1e2b21; display: inline-block; box-shadow: 0 25px 60px rgba(0,0,0,0.15); }
|
||||||
button { padding: 18px 50px; background: #1e2b21; color: white; border: none; border-radius: 15px; cursor: pointer; font-weight: bold; font-size: 1.2rem; transition: all 0.2s; }
|
button { padding: 18px 50px; background: #1e2b21; color: white; border: none; border-radius: 15px; cursor: pointer; font-weight: bold; font-size: 1.2rem; transition: all 0.2s; }
|
||||||
button:hover { transform: translateY(-3px); background: #2b3d2f; }
|
button:hover { transform: translateY(-3px); background: #2b3d2f; }
|
||||||
.flash { position: absolute; inset: 0; background: white; z-index: 10; pointer-events: none; }
|
.flash { position: absolute; inset: 0; background: white; z-index: 20; pointer-events: none; }
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div id="wrapper" bind:this={container}>
|
<div id="wrapper" bind:this={container}>
|
||||||
<canvas bind:this={canvas}></canvas>
|
<canvas bind:this={canvas}></canvas>
|
||||||
|
<div class="p5-hud" bind:this={p5Container}></div>
|
||||||
{#if hitFlash} <div class="flash"></div> {/if}
|
{#if hitFlash} <div class="flash"></div> {/if}
|
||||||
<div class="ui">
|
<div class="ui">
|
||||||
<div class="score">{score}</div>
|
<div class="score">{score}</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user