Cable ships a size bigger on the map; a ship at work sits just off the cut marker
This commit is contained in:
parent
a77eef8ce7
commit
620253b57b
1 changed files with 2 additions and 2 deletions
|
|
@ -32,13 +32,13 @@ function shipSprite(x,y,face,sc,col,now,mode){const c=ctx;c.save();c.translate(x
|
|||
if(mode==='work'&&Math.floor(now/350)%2){c.fillStyle='#FFD23F';c.font='900 11px sans-serif';c.textAlign='center';c.fillText('✦',12,-8);}
|
||||
c.restore();}
|
||||
function drawShips(ks,now){SHIP_HITS.length=0;if(!S||pzOn()||!S.fleet)return;
|
||||
const T=S.day+(UI.speed?clamp(acc/DAY_MS,0,0.999):0),z=cam.z,sc=Math.max(0.75,Math.min(1.4,Math.sqrt(z)))*(lodFar()?0.8:1),list=[];
|
||||
const T=S.day+(UI.speed?clamp(acc/DAY_MS,0,0.999):0),z=cam.z,sc=Math.max(0.9,Math.min(1.6,Math.sqrt(z)))*(lodFar()?1:1.25),list=[];
|
||||
for(const s of SHIPS){const p=shipAt(s,T);if(p.m==='port'&&z<1.1)continue;list.push({p,s,col:s.club==='prv'?'#7A5CFF':'#FF4D5E'});}
|
||||
for(const l of S.links)if(layOwn(l)&&l.ready>S.day&&T>=layStart(l)){const g=linkGeom(l),q=layDone(l,T),two=!!l.ship2;
|
||||
const put=(t,k,dir)=>{const [x,y]=polyAt(g.pts,g.cum,clamp(t,0,1)),[x2]=polyAt(g.pts,g.cum,clamp(t+dir*0.01,0,1));list.push({p:{x,y,m:'lay',dx:x2-x||dir},lay:l,k,col:'#16A866'});};
|
||||
if(two){put(q/2,0,1);put(1-q/2,1,-1);}else put(q,0,1);}
|
||||
for(const it of list)for(const k of ks){const [sx,sy]=toS(it.p.x,it.p.y,k);if(sx<-30||sx>CW+30||sy<-30||sy>CH+30)continue;
|
||||
shipSprite(sx,sy,it.p.dx<0?-1:1,sc,it.col,now,it.p.m);SHIP_HITS.push({x:sx,y:sy,r:14*sc,it});}}
|
||||
const oy=it.p.m==='work'?-18*sc:0;shipSprite(sx,sy+oy,it.p.dx<0?-1:1,sc,it.col,now,it.p.m);SHIP_HITS.push({x:sx,y:sy+oy,r:14*sc,it});}}
|
||||
function shipHit(cx,cy){const r=cv.getBoundingClientRect(),x=cx-r.left,y=cy-r.top;let best=null,bd=Infinity;
|
||||
for(const h of SHIP_HITS){const d=Math.hypot(h.x-x,h.y-y);if(d<=h.r+6&&d<bd){bd=d;best=h.it;}}return best;}
|
||||
// Tapping a ship says who it is and what it is doing, with a way to the cable it works on.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue