SandGame/config.js

49 lines
1.5 KiB
JavaScript
Raw Normal View History

2026-10-22 14:05:51 +00:00
// c:\Users\benji\OneDrive\Documents\Source Code\sandgame\config.js
export const defaultConfig = {
global: { gravity: 0.5, drag: 0.9 },
time: { paused: false, speed: 1 },
explosive: {
radius: 15,
force: 2.0,
destroy: { rock: true, wood: true, dirt: true, plant: true, water: false, acid: true }
},
acid: {
dissolveChance: 0.05,
sinkChance: 0.2,
explodeTNT: false,
dissolve: { rock: false, wood: true, dirt: true, plant: true, water: false }
},
fire: { burnChance: 0.01 },
water: { flowChance: 1.0 },
steam: { condenseChance: 0.01 },
plant: { growChance: 0.02, woodificationChance: 0.01, burnChance: 0.4 },
wood: { burnChance: 0.05 },
visual: { style: 'blocky' }
};
export let config = JSON.parse(JSON.stringify(defaultConfig));
export function setConfig(newConfig) {
config = newConfig;
}
export function saveSettings() {
localStorage.setItem('sandGameSettings', JSON.stringify(config));
}
export function loadSettings() {
if (localStorage.getItem('sandGameSettings')) {
try {
const saved = JSON.parse(localStorage.getItem('sandGameSettings'));
// Merge saved settings into config
for (const key in saved) {
if (config[key]) {
Object.assign(config[key], saved[key]);
}
}
} catch (e) {
console.error('Error loading settings:', e);
}
}
}