Compare commits
2 Commits
1324f424e4
...
ba8aa7e73b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba8aa7e73b | ||
|
|
68527227eb |
@ -67,7 +67,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
document.body.classList.toggle('dark-theme', theme === 'dark');
|
||||
themeToggle.checked = theme === 'dark';
|
||||
localStorage.setItem('snakeTheme', theme);
|
||||
draw();
|
||||
}
|
||||
|
||||
settingsBtn.addEventListener('click', openSettings);
|
||||
@ -113,14 +112,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
|
||||
function draw() {
|
||||
const accentColor = getComputedStyle(document.body).getPropertyValue('--accent-color').trim();
|
||||
const canvasBg = getComputedStyle(document.body).getPropertyValue('--canvas-bg').trim();
|
||||
|
||||
ctx.fillStyle = canvasBg;
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
snake.forEach((segment, index) => {
|
||||
ctx.fillStyle = accentColor;
|
||||
const hue = (segment.x * 5 + segment.y * 5) % 360;
|
||||
ctx.fillStyle = `hsl(${hue}, 100%, 50%)`;
|
||||
if (index === 0) {
|
||||
ctx.fillRect(segment.x * gridSize, segment.y * gridSize, gridSize, gridSize);
|
||||
} else {
|
||||
@ -238,5 +237,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
if ((key === 'ArrowRight' || key.toLowerCase() === 'd') && direction !== 'left') direction = 'right';
|
||||
});
|
||||
|
||||
placeFood();
|
||||
draw();
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user