refactor: separate js code

This commit is contained in:
2026-06-25 05:58:51 +05:00
parent ddc8b93804
commit b3b0c645e9
13 changed files with 1182 additions and 1444 deletions
+204
View File
@@ -0,0 +1,204 @@
const CONFIG = {
commands: { play: "!play" },
texts: {
startTitle: "SHOOTING WORD",
startSubtitle: "Введи !play чтобы играть",
gameOverTitle: "ЧАТ, ВЫ ПРОИГРАЛИ!",
gameOverSubtitle: "Введи !play чтобы играть",
scoreLabel: "SCORE:",
waveLabel: "WAVE:",
livesLabel: "LIVES:",
finalScoreLabel: "Final Score:",
armorLabel: "ARMOR",
},
game: {
startLives: 10,
startWave: 1,
startScore: 0,
spawnIntervalBase: 240,
spawnIntervalMin: 60,
spawnIntervalDecayPerWave: 12,
waveInterval: 900,
heavyEnemyChanceBase: 0.25,
heavyEnemyChancePerWave: 0.02,
scoreSimple: 10,
scoreHeavy: 50,
},
speed: {
simpleEnemyCrossTime: 60,
simpleEnemyCrossTimeRand: 120,
simpleEnemyCrossTimeDecay: 4000,
heavyEnemyCrossTime: 120,
heavyEnemyCrossTimeRand: 240,
projectileCrossTime: 1.3,
gridSpeed: 0.5,
},
visual: {
gridSize: 80,
enemyPaddingX: 60,
enemyAlienOffset: 16,
armorBarPad: 20,
armorBarFont: 20,
missTargetPadX: 60,
missTargetPadY: 100,
inputAreaHeight: 105,
removeZone: 60,
playerY: 32,
playerRadius: 16,
playerGlow: 30,
enemySimpleHeight: 30,
enemyHeavyHeight: 42,
enemySimpleFont: 28,
enemyHeavyFont: 30,
enemyArmorBarHeight: 6,
enemyArmorBarOffset: 11,
enemyArmorLabelOffset: 15,
enemyGlow: 10,
enemyFlashGlow: 50,
enemyLineWidth: 3,
projectileGlow: 30,
projectileHitRadius: 30,
projectileMissRadius: 30,
projectileFont: 28,
projectileCircleRadius: 30,
shakeHit: 8,
shakeMiss: 6,
shakeDamage: 16,
particleVel: 12,
particleSizeMin: 4,
particleSizeMax: 10,
particleGlow: 16,
trailSizeBase: 4,
trailSizeInc: 1,
trailGlow: 20,
shooterOffset: 50,
},
visualRatio: {
missTargetYRange: 0.5,
projectileTrailLength: 8,
projectileTrailDecay: 0.15,
projectileTrailAlpha: 0.6,
projectileCircleAlpha: 0.5,
enemyPulseRate: 0.05,
enemyAlphaBase: 0.7,
enemyAlphaRange: 0.3,
enemyGlowPulse: 5,
particleDecayBase: 0.02,
particleDecayRange: 0.03,
particleDamping: 0.98,
},
counts: {
projectileTrailLength: 8,
particleHit: 15,
particleMiss: 20,
particleDestroySimple: 15,
particleDestroyHeavy: 30,
particleArmorBreak: 15,
flashDuration: 10,
shakeHitDuration: 6,
shakeMissDuration: 5,
shakeDamageDuration: 10,
trailMaxLength: 10,
trailDecay: 0.12,
trailAlpha: 0.5,
},
timing: {
inputShootDelay: 150,
glitchDuration: 300,
},
colors: {
primary: "#00ff41",
primaryDim: "#00cc33",
primaryGlow: "rgba(0,255,65,0.2)",
primaryGrid: "rgba(0,255,65,0.08)",
heavy: "#ffaa00",
heavyDim: "#cc8800",
miss: "#ff0044",
white: "#ffffff",
red: "#ff0000",
armorBarBg: "rgba(255,0,0,0.3)",
armorBarFill: "#ffaa00",
playerBase: "rgba(0,255,65,0.15)",
scanline: "rgba(0,255,65,0.03)",
},
intro: {
fontSize: 44,
textYR: 0.35,
subtitleYOffset: 60,
fadeInFrames: 40,
shot1Frame: 45,
shot2Frame: 70,
shot3Frame: 95,
shotSpeed: 0.045,
particleCountPerHit: 18,
slideStartFrame: 122,
slideDuration: 20,
totalFrames: 180,
startDelay: 300,
glow: 50,
trailGlow: 20,
projectileGlow: 30,
projectileRadius: 8,
trailRect: 8,
trailMax: 10,
trailDecay: 0.12,
trailAlpha: 0.5,
subtitleFont: 32,
subtitleGlow: 20,
},
};
const WordGenerator = {
simpleWords: [
"hack", "code", "data", "node", "link", "byte", "bit", "net", "web", "sys",
"run", "log", "bug", "fix", "api", "cpu", "ram", "ssd", "gpu", "dns",
"ip", "url", "tag", "css", "js", "sql", "git", "cli", "env", "dev",
"app", "bot", "ai", "io", "os", "ui", "ux", "vm", "vpn", "lan",
"wan", "ftp", "ssh", "http", "json", "xml", "yaml", "md", "py", "go",
"rust", "java", "php", "cpp", "ts", "rb", "kt", "swift", "dart", "lua",
"perl", "bash", "zsh", "fish", "vim", "nano", "emacs", "sed", "awk", "grep",
"find", "cat", "ls", "cd", "mv", "cp", "rm", "mkdir", "chmod", "chown",
"ping", "curl", "wget", "nc", "nmap", "tcp", "udp", "ip4", "ip6", "mac",
"hex", "bin", "dec", "oct", "xor", "and", "or", "not", "shl", "shr",
"key", "lock", "door", "gate", "wall", "fire", "ice", "wind", "storm", "rain",
"sun", "moon", "star", "void", "null", "zero", "one", "two", "ten", "max",
],
heavyWords: [
["root", "access"], ["data", "breach"], ["fire", "wall"], ["deep", "web"],
["dark", "net"], ["cloud", "base"], ["neural", "net"], ["quantum", "bit"],
["block", "chain"], ["smart", "contract"], ["machine", "learn"], ["deep", "fake"],
["zero", "day"], ["back", "door"], ["side", "channel"], ["man", "middle"],
["denial", "service"], ["brute", "force"], ["social", "engineer"], ["phishing", "attack"],
["sql", "inject"], ["cross", "site"], ["buffer", "over"], ["heap", "spray"],
["stack", "pivot"], ["return", "orient"], ["format", "string"], ["race", "condition"],
["time", "check"], ["use", "after"], ["double", "free"], ["null", "pointer"],
["integer", "over"], ["type", "confus"], ["memory", "leak"], ["dead", "lock"],
["live", "lock"], ["starvation", "mode"], ["priority", "invert"], ["cache", "miss"],
["branch", "mispred"], ["speculative", "exec"], ["meltdown", "flaw"], ["spectre", "bug"],
["row", "hammer"], ["cold", "boot"], ["evil", "maid"], ["supply", "chain"],
["hardware", "troj"], ["firmware", "root"], ["bios", "implant"], ["uefi", "shell"],
["smm", "exploit"], ["ring", "zero"], ["kernel", "panic"], ["blue", "screen"],
["kernel", "oops"], ["seg", "fault"], ["bus", "error"], ["illegal", "op"],
["trap", "divide"], ["trap", "debug"], ["trap", "nmi"], ["trap", "break"],
["trap", "overflow"], ["trap", "bound"], ["trap", "invalid"], ["trap", "device"],
["trap", "double"], ["trap", "copro"], ["trap", "tss"], ["trap", "segment"],
["trap", "stack"], ["trap", "general"], ["trap", "page"], ["trap", "x87"],
["trap", "align"], ["trap", "machine"], ["trap", "simd"], ["trap", "virtual"],
["security", "check"], ["stack", "cookie"], ["aslr", "bypass"], ["dep", "bypass"],
["cfg", "bypass"], ["cet", "bypass"], ["shadow", "stack"], ["control", "flow"],
["indirect", "call"], ["jump", "oriented"], ["call", "oriented"], ["data", "oriented"],
["counterfeit", "obj"], ["use", "after"], ["heap", "feng"], ["house", "spirit"],
["house", "lore"], ["house", "force"], ["fast", "bin"], ["tcache", "poison"],
["unsorted", "bin"], ["large", "bin"], ["small", "bin"], ["mmap", "chunk"],
["top", "chunk"], ["wilderness", "area"], ["arena", "corrupt"], ["thread", "cache"],
["per", "thread"], ["main", "arena"],
],
generateWord(isHeavy) {
if (isHeavy) {
const pair = this.heavyWords[Math.floor(Math.random() * this.heavyWords.length)];
return pair;
}
return this.simpleWords[Math.floor(Math.random() * this.simpleWords.length)];
},
};