fix(map): drop the last network's floaters when another one starts
Floaters ("New POP!", payday money) live in FLOATS and fade on the map's
animation clock, which only runs while the game does. A new network
whose clock stands still (the agent's clock on the development page)
kept the previous network's floaters frozen over its map until a reload:
hundreds of them after a payday on a big network at 8x.
Each floater now records the network that raised it, and the map drops
any that belong to another one (new game, another slot, import, puzzle,
title screen). Same code for the 2D and WebGL maps.
This commit is contained in:
parent
dd6e4f4f8a
commit
fca11b39d2
5 changed files with 24 additions and 4 deletions
|
|
@ -18,4 +18,6 @@ const CLOUDS=Array.from({length:7},(_,i)=>({x:R1()*W,y:60+R1()*(H-120),s:.7+R1()
|
|||
const FLOATS=[];
|
||||
// Stamped with the map's animation clock, which stops while paused: on the real clock, every floater born after a
|
||||
// pause lingered off-screen for as long as the pause had lasted, and paydays piled up hundreds of them.
|
||||
function floater(x,y,text,col){if(!animOn()||UI.mapHid)return;FLOATS.push({x,y,text,col,t:animT});}
|
||||
// Each belongs to the network that raised it (s): a new game starts paused, and the last one's, frozen with the clock,
|
||||
// stayed on its map until a reload.
|
||||
function floater(x,y,text,col){if(!animOn()||UI.mapHid)return;FLOATS.push({x,y,text,col,t:animT,s:S});}
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ function drawFrame(now){
|
|||
// the chaos monkey (woken here after a reload, wherever it last snipped)
|
||||
if(UI.mk)mkDraw(ks);else if(mkOn()&&!pzOn()&&CITY[S.monkey.c])mkStart(S.monkey.c);
|
||||
// floaters
|
||||
for(let i=FLOATS.length-1;i>=0;i--){const f=FLOATS[i],a=(now-f.t)/1600;if(a>1){FLOATS.splice(i,1);continue;}
|
||||
for(let i=FLOATS.length-1;i>=0;i--){const f=FLOATS[i],a=(now-f.t)/1600;if(a>1||f.s!==S){FLOATS.splice(i,1);continue;}
|
||||
const font='800 17px "Baloo 2", sans-serif';if(f.w===undefined){ctx.font=font;f.w=ctx.measureText(f.text).width;}
|
||||
for(const k of ks){const [sx,sy]=toS(f.x,f.y,k);ctx.globalAlpha=1-a*a;textStamp(f.text,font,17,f.w,f.col,'#fff',4,sx,sy-a*40);ctx.globalAlpha=1;}}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue