Compare commits

..

9 Commits
test ... main

Author SHA1 Message Date
e059ff91eb add lock 2026-02-01 23:12:02 +01:00
87e42d87a5 change color 2025-10-30 19:57:06 +01:00
c494780fad update color 2025-10-29 19:45:26 +01:00
d4610bf5e8 change color 2025-10-29 02:04:13 +01:00
6c8897746c update color 2025-10-29 01:36:35 +01:00
afe39c77c4 update color 2025-10-29 01:33:40 +01:00
0ad707476d change color 2025-10-29 01:06:51 +01:00
bf7a37e66c fix deps 2025-10-27 18:56:03 +01:00
c64d89b5db move to vite 2025-09-30 20:04:22 +02:00
11 changed files with 1092 additions and 5400 deletions

1
.gitignore vendored
View File

@ -30,4 +30,3 @@ glow.apk
compose-scripts.md compose-scripts.md
uploads uploads
package-lock.json

View File

@ -5,7 +5,7 @@ A snake implementation with vanilla JavaScript
[PLAY!](http://zzznake.surge.sh/) [PLAY!](http://zzznake.surge.sh/)
Todo Todo
* [x] Add restart logic * [ ] Add restart logic
* [ ] Make it functional * [ ] Make it functional
* [ ] Use canvas instead of div's * [ ] Use canvas instead of div's
* [ ] Add animations * [ ] Add animations

6
index.html Normal file
View File

@ -0,0 +1,6 @@
<html>
<body>
<div id="app"></div>
<script type="module" src="/src/index.js"></script>
</body>
</html>

1068
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -9,11 +9,10 @@
"lodash": "^4.17.4" "lodash": "^4.17.4"
}, },
"scripts": { "scripts": {
"start": "neutrino start --use neutrino-preset-web", "start": "vite",
"build": "neutrino build --use neutrino-preset-web" "build": "vite build --outDir build"
}, },
"devDependencies": { "devDependencies": {
"neutrino": "^6.1.5", "vite": "^7.1.7"
"neutrino-preset-web": "^6.1.5"
} }
} }

View File

@ -1,4 +1,5 @@
export default { export default {
bgColor: "grey",
unit: 20, unit: 20,
dimensions: { dimensions: {
width: 30, width: 30,

View File

@ -9,7 +9,7 @@ import {
import keys from "./utils/keys"; import keys from "./utils/keys";
import { S, N, A, K, E } from "./utils/letters"; import { S, N, A, K, E } from "./utils/letters";
const { dimensions, unit, snake, food } = config; const { dimensions, unit, snake, food, bgColor } = config;
let GAME_STARTED = false; let GAME_STARTED = false;
let GAME_RUNNING; let GAME_RUNNING;
@ -40,7 +40,7 @@ for (let i = 0; i < dimensions.height; i++) {
width: `${unit}px`, width: `${unit}px`,
height: `${unit}px`, height: `${unit}px`,
display: "inline-block", display: "inline-block",
background: "#000", background: bgColor,
}, },
"board" "board"
); );

View File

@ -3,7 +3,7 @@
*/ */
export const createDivElement = (name, styles, target) => { export const createDivElement = (name, styles, target) => {
window[name] = document.createElement("div"); window[name] = document.createElement('div');
window[name].id = name; window[name].id = name;
Object.assign(window[name].style, styles); Object.assign(window[name].style, styles);
@ -29,8 +29,7 @@ export const setDivColor = (color, x, y) => {
export const setDivsColor = (divs, color) => { export const setDivsColor = (divs, color) => {
divs.forEach(({ x, y }) => { divs.forEach(({ x, y }) => {
((document.getElementById(`${x}.${y}`) || {}).style || {}).background = ((document.getElementById(`${x}.${y}`) || {}).style || {}).background = color;
color;
}); });
}; };
@ -39,9 +38,5 @@ export const setDivsColor = (divs, color) => {
*/ */
export const drawLetter = (char) => { export const drawLetter = (char) => {
setDivColor( setDivColor('#333', char.toString().split('.')[0], char.toString().split('.')[1]);
"#333",
char.toString().split(".")[0],
char.toString().split(".")[1]
);
}; };

View File

@ -8,4 +8,4 @@ export default {
UP: 38, UP: 38,
RIGHT: 39, RIGHT: 39,
DOWN: 40, DOWN: 40,
}; }

View File

@ -3,18 +3,7 @@
*/ */
export const S = [2.2, 2.3, 2.4, 2.5, 3.2, 4.3, 5.4, 6.5, 7.5, 7.4, 7.3, 7.2]; export const S = [2.2, 2.3, 2.4, 2.5, 3.2, 4.3, 5.4, 6.5, 7.5, 7.4, 7.3, 7.2];
export const N = [ export const N = [2.7, 3.7, 4.7, 5.7, 6.7, 7.7, 3.8, 4.9, 5.9, 6.10, 6.11, 7.11, 6.11, 5.11, 4.11, 3.11, 2.11];
2.7, 3.7, 4.7, 5.7, 6.7, 7.7, 3.8, 4.9, 5.9, 6.1, 6.11, 7.11, 6.11, 5.11, export const A = [2.13, 3.13, 4.13, 5.13, 6.13, 7.13, 2.14, 2.15, 2.16, 2.17, 3.17, 4.17, 5.17, 6.17, 7.17, 5.16, 5.15, 5.14];
4.11, 3.11, 2.11, export const K = [2.19, 3.19, 4.19, 4.20, 5.19, 5.20, 6.19, 7.19, 6.21, 7.22, 3.21, 2.22];
]; export const E = [2.24, 3.24, 4.24, 5.24, 6.24, 7.24, 2.25, 2.26, 2.27, 2.28, 7.25, 7.26, 7.27, 7.28, 4.25];
export const A = [
2.13, 3.13, 4.13, 5.13, 6.13, 7.13, 2.14, 2.15, 2.16, 2.17, 3.17, 4.17, 5.17,
6.17, 7.17, 5.16, 5.15, 5.14,
];
export const K = [
2.19, 3.19, 4.19, 4.2, 5.19, 5.2, 6.19, 7.19, 6.21, 7.22, 3.21, 2.22,
];
export const E = [
2.24, 3.24, 4.24, 5.24, 6.24, 7.24, 2.25, 2.26, 2.27, 2.28, 7.25, 7.26, 7.27,
7.28, 4.25,
];

5365
yarn.lock

File diff suppressed because it is too large Load Diff