snake framework
This commit is contained in:
parent
26fabc37e9
commit
8478bc66e7
4 changed files with 380 additions and 0 deletions
60
secret/snake/styles.js
Normal file
60
secret/snake/styles.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
'use strict';
|
||||
const aBtn = document.querySelector('#a');
|
||||
const bBtn = document.querySelector('#b');
|
||||
const gameboy = document.querySelector('.gameboy');
|
||||
const html = document.documentElement;
|
||||
const body = document.body;
|
||||
const dpadButtons = document.querySelectorAll('.dpad-btn');
|
||||
const dpadCenter = document.querySelector('.dpad-center'); // Darker variant
|
||||
const actionButtons = document.querySelectorAll('.btn');
|
||||
|
||||
const colors = [
|
||||
{ gameboyColor: '#B39DDB', htmlColor: '#D1C4E9', buttonColor: '#673AB7', buttonTextColor: '#FFFFFF', dpadCenterColor: '#5E35B1' },
|
||||
{ gameboyColor: '#FFC107', htmlColor: '#FFF9C4', buttonColor: '#FF9800', buttonTextColor: '#000000', dpadCenterColor: '#EF6C00' },
|
||||
{ gameboyColor: '#8BC34A', htmlColor: '#C5E1A5', buttonColor: '#FF5722', buttonTextColor: '#FFFFFF', dpadCenterColor: '#E64A19' },
|
||||
{ gameboyColor: '#F44336', htmlColor: '#FFCDD2', buttonColor: '#E91E63', buttonTextColor: '#FFFFFF', dpadCenterColor: '#C2185B' },
|
||||
{ gameboyColor: '#03A9F4', htmlColor: '#BBDEFB', buttonColor: '#FFEB3B', buttonTextColor: '#000000', dpadCenterColor: '#0277BD' },
|
||||
{ gameboyColor: '#FF7043', htmlColor: '#FFCCBC', buttonColor: '#FF5722', buttonTextColor: '#FFFFFF', dpadCenterColor: '#D84315' },
|
||||
{ gameboyColor: '#9C27B0', htmlColor: '#E1BEE7', buttonColor: '#7B1FA2', buttonTextColor: '#FFFFFF', dpadCenterColor: '#6A1B9A' },
|
||||
{ gameboyColor: '#FFD700', htmlColor: '#FFF9C4', buttonColor: '#FF9800', buttonTextColor: '#FFFFFF', dpadCenterColor: '#F57F17' },
|
||||
{ gameboyColor: '#009688', htmlColor: '#B2DFDB', buttonColor: '#4CAF50', buttonTextColor: '#FFFFFF', dpadCenterColor: '#00796B' },
|
||||
{ gameboyColor: '#795548', htmlColor: '#D7CCC8', buttonColor: '#9E9E9E', buttonTextColor: '#000000', dpadCenterColor: '#5D4037' },
|
||||
{ gameboyColor: '#FF5733', htmlColor: '#FFCCCB', buttonColor: '#C70039', buttonTextColor: '#FFFFFF', dpadCenterColor: '#B71C1C' },
|
||||
{ gameboyColor: '#00BCD4', htmlColor: '#B2EBF2', buttonColor: '#00ACC1', buttonTextColor: '#FFFFFF', dpadCenterColor: '#00838F' }
|
||||
];
|
||||
|
||||
let currentColorIndex = localStorage.getItem('gameboyColorIndex') ? parseInt(localStorage.getItem('gameboyColorIndex')) : 0;
|
||||
|
||||
function updateGameBoyColor() {
|
||||
gameboy.style.backgroundColor = colors[currentColorIndex].gameboyColor;
|
||||
html.style.backgroundColor = colors[currentColorIndex].htmlColor;
|
||||
body.style.backgroundColor = colors[currentColorIndex].htmlColor;
|
||||
|
||||
dpadButtons.forEach(button => {
|
||||
button.style.backgroundColor = colors[currentColorIndex].buttonColor;
|
||||
button.style.color = colors[currentColorIndex].buttonTextColor;
|
||||
});
|
||||
|
||||
// Using darker dpad center color
|
||||
dpadCenter.style.backgroundColor = colors[currentColorIndex].dpadCenterColor;
|
||||
dpadCenter.style.color = colors[currentColorIndex].buttonTextColor;
|
||||
|
||||
actionButtons.forEach(button => {
|
||||
button.style.backgroundColor = colors[currentColorIndex].buttonColor;
|
||||
button.style.color = colors[currentColorIndex].buttonTextColor;
|
||||
});
|
||||
}
|
||||
|
||||
aBtn.addEventListener('click', () => {
|
||||
currentColorIndex = (currentColorIndex - 1 + colors.length) % colors.length;
|
||||
localStorage.setItem('gameboyColorIndex', currentColorIndex);
|
||||
updateGameBoyColor();
|
||||
});
|
||||
|
||||
bBtn.addEventListener('click', () => {
|
||||
currentColorIndex = (currentColorIndex + 1) % colors.length;
|
||||
localStorage.setItem('gameboyColorIndex', currentColorIndex);
|
||||
updateGameBoyColor();
|
||||
});
|
||||
|
||||
updateGameBoyColor();
|
Loading…
Add table
Add a link
Reference in a new issue