ymo2017 commited on
Commit
4c19400
·
verified ·
1 Parent(s): 4dba460

大航海商人船尾波纹涟漪+扫雷剩余归零闪绿+贪吃蛇吃果蛇头发亮

Browse files
Files changed (3) hide show
  1. minesweeper.html +18 -3
  2. sailing-trader.html +27 -2
  3. snake.html +15 -1
minesweeper.html CHANGED
@@ -162,7 +162,7 @@ function reset(){
162
  G.board.push(row);
163
  }
164
  G.state='playing'; G.paused=false; G.started=false;
165
- G.opened=0; G.flags=0; G.elapsed=0; G.boom=null; G.winTime=0; G.flagMode=false;
166
  G.fxFlash=0; G.fxShake=0; G.fxFlashCol='255,120,140';
167
  parts.length=0; rings.length=0;
168
  flagBtn.classList.remove('on');
@@ -238,6 +238,7 @@ function toggleFlag(x,y){
238
  c.flag=!c.flag;
239
  if(c.flag) c.flagT=performance.now(); // 插旗弹跳动画计时(纯表现层)
240
  G.flags+=c.flag?1:-1;
 
241
  if(c.flag) SFX.flag(); else SFX.unflag();
242
  }
243
  /* 双击数字区:邻旗数==数字时展开周围 */
@@ -278,6 +279,7 @@ function checkWin(){
278
  if(c.mine&&!c.flag){ c.flag=true; }
279
  }
280
  G.flags=G.mines;
 
281
  retryBtn.classList.add('show');
282
  }
283
  }
@@ -426,16 +428,29 @@ function drawHUD(){
426
  ctx.fillStyle='#22e6ff';
427
  ctx.font='700 26px "PingFang SC","Microsoft YaHei",monospace';
428
  const remain=Math.max(0,G.mines-G.flags);
 
 
 
 
 
 
 
429
  if(MS_BOMB_OK&&MS_BOMB.naturalWidth){
430
  ctx.save();
431
  ctx.globalCompositeOperation='lighter';
432
  ctx.drawImage(MS_BOMB,14,44-26,26,26);
433
  ctx.restore();
434
- ctx.fillStyle='#22e6ff';
 
 
435
  ctx.fillText(String(remain),14+32,44);
 
436
  }else{
437
- ctx.fillStyle='#22e6ff';
 
 
438
  ctx.fillText('💣 '+remain,14,44);
 
439
  }
440
  ctx.textAlign='center';
441
  ctx.fillStyle='#ffd93b';
 
162
  G.board.push(row);
163
  }
164
  G.state='playing'; G.paused=false; G.started=false;
165
+ G.opened=0; G.flags=0; G.elapsed=0; G.boom=null; G.winTime=0; G.flagMode=false; G.zeroT=0;
166
  G.fxFlash=0; G.fxShake=0; G.fxFlashCol='255,120,140';
167
  parts.length=0; rings.length=0;
168
  flagBtn.classList.remove('on');
 
238
  c.flag=!c.flag;
239
  if(c.flag) c.flagT=performance.now(); // 插旗弹跳动画计时(纯表现层)
240
  G.flags+=c.flag?1:-1;
241
+ if(G.mines-G.flags===0) G.zeroT=performance.now(); // 剩余雷数归零时 HUD 闪绿提示(纯表现层,不改逻辑)
242
  if(c.flag) SFX.flag(); else SFX.unflag();
243
  }
244
  /* 双击数字区:邻旗数==数字时展开周围 */
 
279
  if(c.mine&&!c.flag){ c.flag=true; }
280
  }
281
  G.flags=G.mines;
282
+ G.zeroT=performance.now(); // 剩余雷数归零时 HUD 闪绿提示(纯表现层)
283
  retryBtn.classList.add('show');
284
  }
285
  }
 
428
  ctx.fillStyle='#22e6ff';
429
  ctx.font='700 26px "PingFang SC","Microsoft YaHei",monospace';
430
  const remain=Math.max(0,G.mines-G.flags);
431
+ /* 剩余雷数归零时 HUD 闪绿呼吸 3 次(纯表现层,不改逻辑) */
432
+ let zeroPulse=0;
433
+ if(remain===0&&G.zeroT){
434
+ const zAge=performance.now()-G.zeroT;
435
+ if(zAge<1800) zeroPulse=Math.abs(Math.sin(zAge/300*Math.PI));
436
+ }
437
+ const mineNumColor=zeroPulse>0?('rgba(57,255,106,'+(0.55+0.45*zeroPulse).toFixed(3)+')'):'#22e6ff';
438
  if(MS_BOMB_OK&&MS_BOMB.naturalWidth){
439
  ctx.save();
440
  ctx.globalCompositeOperation='lighter';
441
  ctx.drawImage(MS_BOMB,14,44-26,26,26);
442
  ctx.restore();
443
+ ctx.save();
444
+ if(zeroPulse>0){ ctx.shadowColor='#39ff6a'; ctx.shadowBlur=14; }
445
+ ctx.fillStyle=mineNumColor;
446
  ctx.fillText(String(remain),14+32,44);
447
+ ctx.restore();
448
  }else{
449
+ ctx.save();
450
+ if(zeroPulse>0){ ctx.shadowColor='#39ff6a'; ctx.shadowBlur=14; }
451
+ ctx.fillStyle=mineNumColor;
452
  ctx.fillText('💣 '+remain,14,44);
453
+ ctx.restore();
454
  }
455
  ctx.textAlign='center';
456
  ctx.fillStyle='#ffd93b';
sailing-trader.html CHANGED
@@ -180,7 +180,7 @@ function reset(){
180
  G.cargo=[0,0,0,0,0,0];
181
  G.prices=[]; G.prevPrices=[];
182
  for(let p=0;p<PORTS.length;p++){ G.prices.push(rollPrices(p)); G.prevPrices.push(G.prices[p].slice()); }
183
- G.sail=null; G.paused=false; G.won=false; G.time=0; G.arriveFx=null; G.departFx=null;
184
  hideOverlay(); hidePause();
185
  setBanner('','');
186
  render();
@@ -497,6 +497,16 @@ function drawMap(){
497
  if(G.arriveFx) drawGoldBurst(G.arriveFx);
498
  // 离港特效:纯表现层
499
  if(G.departFx) drawGoldBurst(G.departFx);
 
 
 
 
 
 
 
 
 
 
500
  // 船
501
  if(G.sail){
502
  const A=PORTS[G.sail.from],B=PORTS[G.sail.to];
@@ -530,7 +540,22 @@ function tick(ts){
530
  G.time+=dt;
531
  if(G.arriveFx){ G.arriveFx.t+=dt; if(G.arriveFx.t>=G.arriveFx.dur) G.arriveFx=null; }
532
  if(G.departFx){ G.departFx.t+=dt; if(G.departFx.t>=G.departFx.dur) G.departFx=null; }
533
- if(G.sail){ G.sail.t+=dt; if(G.sail.t>=G.sail.dur) arrive(); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
  }
535
  drawMap();
536
  requestAnimationFrame(tick);
 
180
  G.cargo=[0,0,0,0,0,0];
181
  G.prices=[]; G.prevPrices=[];
182
  for(let p=0;p<PORTS.length;p++){ G.prices.push(rollPrices(p)); G.prevPrices.push(G.prices[p].slice()); }
183
+ G.sail=null; G.paused=false; G.won=false; G.time=0; G.arriveFx=null; G.departFx=null; G.wake=[]; G.wakeT=0;
184
  hideOverlay(); hidePause();
185
  setBanner('','');
186
  render();
 
497
  if(G.arriveFx) drawGoldBurst(G.arriveFx);
498
  // 离港特效:纯表现层
499
  if(G.departFx) drawGoldBurst(G.departFx);
500
+ // 船尾波纹涟漪(纯表现层)
501
+ for(const w of G.wake){
502
+ const wk=w.t/w.dur;
503
+ ctx.save();
504
+ ctx.globalAlpha=(1-wk)*0.55;
505
+ ctx.strokeStyle='#7fd4ff'; ctx.lineWidth=2;
506
+ ctx.shadowColor='#7fd4ff'; ctx.shadowBlur=8;
507
+ ctx.beginPath(); ctx.arc(w.x,w.y,4+wk*12,0,TAU); ctx.stroke();
508
+ ctx.restore();
509
+ }
510
  // 船
511
  if(G.sail){
512
  const A=PORTS[G.sail.from],B=PORTS[G.sail.to];
 
540
  G.time+=dt;
541
  if(G.arriveFx){ G.arriveFx.t+=dt; if(G.arriveFx.t>=G.arriveFx.dur) G.arriveFx=null; }
542
  if(G.departFx){ G.departFx.t+=dt; if(G.departFx.t>=G.departFx.dur) G.departFx=null; }
543
+ for(let i=G.wake.length-1;i>=0;i--){ G.wake[i].t+=dt; if(G.wake[i].t>=G.wake[i].dur) G.wake.splice(i,1); } // 船尾波纹涟漪消退(纯表现层)
544
+ if(G.sail){
545
+ G.sail.t+=dt;
546
+ /* 航行中船尾波纹涟漪:每 0.4 秒在船尾推一圈扩散小波纹,1 秒消退(纯表现层,不改航行/事件逻辑) */
547
+ G.wakeT+=dt;
548
+ if(G.wakeT>=0.4){
549
+ G.wakeT=0;
550
+ const A=PORTS[G.sail.from],B=PORTS[G.sail.to];
551
+ const k=Math.min(1,G.sail.t/G.sail.dur);
552
+ const e=k<.5?2*k*k:1-Math.pow(-2*k+2,2)/2;
553
+ const bx=A.x+(B.x-A.x)*e, by=A.y+(B.y-A.y)*e;
554
+ const ang=Math.atan2(B.y-A.y,B.x-A.x);
555
+ G.wake.push({x:bx-Math.cos(ang)*16,y:by-Math.sin(ang)*16,t:0,dur:1});
556
+ }
557
+ if(G.sail.t>=G.sail.dur) arrive();
558
+ }
559
  }
560
  drawMap();
561
  requestAnimationFrame(tick);
snake.html CHANGED
@@ -110,7 +110,7 @@ function reset(){
110
  G.snake=[{x:cx,y:cy},{x:cx-1,y:cy},{x:cx-2,y:cy}];
111
  G.headTrail=[]; // 蛇头拖尾历史(纯表现层)
112
  G.dir={x:1,y:0}; G.queued=null;
113
- G.score=0; G.stepMs=150; G.acc=0; G.paused=false; G.flash=0; G.shake=0; G.overT=1;
114
  retryBtn.classList.remove('show');
115
  spawnFood();
116
  }
@@ -156,6 +156,7 @@ function step(){
156
  if(G.food&&head.x===G.food.x&&head.y===G.food.y){
157
  G.score+=10;
158
  G.stepMs=Math.max(70,150-G.score/10*4); // 吃得越多越快
 
159
  burst(OX+G.food.x*CELL+CELL/2, OY+G.food.y*CELL+CELL/2);
160
  G.flash=1;
161
  SFX.eat();
@@ -259,6 +260,19 @@ function draw(){
259
  if(head){ // 眼睛:朝向移动方向
260
  const dx=G.dir.x, dy=G.dir.y;
261
  const ex=x+CELL/2, ey=y+CELL/2;
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  ctx.fillStyle='#02120a';
263
  ctx.beginPath();
264
  ctx.arc(ex+dx*4-dy*4,ey+dy*4+dx*4,2.6,0,Math.PI*2);
 
110
  G.snake=[{x:cx,y:cy},{x:cx-1,y:cy},{x:cx-2,y:cy}];
111
  G.headTrail=[]; // 蛇头拖尾历史(纯表现层)
112
  G.dir={x:1,y:0}; G.queued=null;
113
+ G.score=0; G.stepMs=150; G.acc=0; G.paused=false; G.flash=0; G.shake=0; G.overT=1; G.headGlowT=0;
114
  retryBtn.classList.remove('show');
115
  spawnFood();
116
  }
 
156
  if(G.food&&head.x===G.food.x&&head.y===G.food.y){
157
  G.score+=10;
158
  G.stepMs=Math.max(70,150-G.score/10*4); // 吃得越多越快
159
+ G.headGlowT=performance.now(); // 吃红果加速时蛇头短暂发亮(纯表现层,不改速度/碰撞)
160
  burst(OX+G.food.x*CELL+CELL/2, OY+G.food.y*CELL+CELL/2);
161
  G.flash=1;
162
  SFX.eat();
 
260
  if(head){ // 眼睛:朝向移动方向
261
  const dx=G.dir.x, dy=G.dir.y;
262
  const ex=x+CELL/2, ey=y+CELL/2;
263
+ if(G.headGlowT){ // 吃红果加速时蛇头短暂发亮(纯表现层,不改速度/碰撞)
264
+ const ga=performance.now()-G.headGlowT;
265
+ if(ga<600){
266
+ const gk=1-ga/600;
267
+ ctx.save(); ctx.globalCompositeOperation='lighter';
268
+ ctx.globalAlpha=0.6*gk;
269
+ const hg=ctx.createRadialGradient(ex,ey,2,ex,ey,CELL*1.2);
270
+ hg.addColorStop(0,'#ffe9a8'); hg.addColorStop(1,'rgba(255,215,106,0)');
271
+ ctx.fillStyle=hg;
272
+ ctx.beginPath(); ctx.arc(ex,ey,CELL*1.2,0,Math.PI*2); ctx.fill();
273
+ ctx.restore();
274
+ }
275
+ }
276
  ctx.fillStyle='#02120a';
277
  ctx.beginPath();
278
  ctx.arc(ex+dx*4-dy*4,ey+dy*4+dx*4,2.6,0,Math.PI*2);