feat: building purchase particle burst effects (#57)
Adds DOM-based particle burst animations when buying buildings and completing research projects. Blue particles for buildings, gold for projects. Lightweight CSS animation with no external dependencies. Refs #57 — Night of Polish, Task 1 (Visual Identity)
This commit is contained in:
12
js/engine.js
12
js/engine.js
@@ -303,6 +303,12 @@ function buyBuilding(id) {
|
||||
updateRates();
|
||||
const label = qty > 1 ? `x${qty}` : '';
|
||||
log(`Built ${def.name} ${label} (total: ${G.buildings[id]})`);
|
||||
// Particle burst on purchase
|
||||
const btn = document.querySelector('[onclick="buyBuilding(\'' + id + '\')"]');
|
||||
if (btn) {
|
||||
const rect = btn.getBoundingClientRect();
|
||||
spawnParticles(rect.left + rect.width / 2, rect.top + rect.height / 2, '#4a9eff', 10);
|
||||
}
|
||||
render();
|
||||
}
|
||||
|
||||
@@ -329,6 +335,12 @@ function buyProject(id) {
|
||||
}
|
||||
|
||||
updateRates();
|
||||
// Gold particle burst on project completion
|
||||
const pBtn = document.querySelector('[onclick="buyProject(\'' + id + '\')"]');
|
||||
if (pBtn) {
|
||||
const rect = pBtn.getBoundingClientRect();
|
||||
spawnParticles(rect.left + rect.width / 2, rect.top + rect.height / 2, '#ffd700', 16);
|
||||
}
|
||||
render();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user