Merge pull request #304 from antt0n/fix/map-stale-floaters
fix(map): drop the last network's floaters when another one starts
This commit is contained in:
commit
4ec3fb4a1a
5 changed files with 23 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