Compare commits

..

2 Commits
main ... test

Author SHA1 Message Date
0ffaa4d08e fix formatting 2025-09-30 19:51:14 +02:00
f24ab96870 test 2025-09-30 19:47:33 +02:00
11 changed files with 5400 additions and 1092 deletions

1
.gitignore vendored
View File

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

View File

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

View File

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

1068
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,7 +3,18 @@
*/
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 = [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];
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.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 N = [
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,
4.11, 3.11, 2.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,
];
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 Normal file

File diff suppressed because it is too large Load Diff