evolve: 花朵摇摆反馈/青苔滋养增殖/流星山头余光(2026-09-22)
Browse files贪吃蛇:蛇头近篱花朵 0.5s 摇摆反馈;2048:≥1024 砖块行列交叉格缝青苔 +1 档;打地鼠:流星落地远山极淡暖白余光 alpha 0.04 衰退 0.5s。均为纯表现层。
- 2048.html +13 -5
- snake.html +45 -9
- whack-a-mole.html +12 -0
2048.html
CHANGED
|
@@ -299,9 +299,9 @@ function cellXY(r,c){ return [OX+GAP+c*(CELL+GAP), OY+GAP+r*(CELL+GAP)]; }
|
|
| 299 |
function pickMossSpots(){
|
| 300 |
const pts=[];
|
| 301 |
for(let r=0;r<=N;r++) for(let c=0;c<=N;c++)
|
| 302 |
-
pts.push(
|
| 303 |
for(let i=pts.length-1;i>0;i--){ const j=(Math.random()*(i+1))|0; const t=pts[i]; pts[i]=pts[j]; pts[j]=t; }
|
| 304 |
-
return pts.slice(0,12).map(p=>({x:p
|
| 305 |
}
|
| 306 |
function tileAt(r,c){ return G.tiles.find(t=>t.r===r&&t.c===c&&!t.dead); }
|
| 307 |
function emptyCells(){
|
|
@@ -494,13 +494,21 @@ function draw(){
|
|
| 494 |
if(TF_OK.moss&&TF_IMG.moss.naturalWidth&&G.mossSpots){
|
| 495 |
const _el=(nowFx-G.startT)/1000;
|
| 496 |
const _tier=_el>180?2:(_el>60?1:0);
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 500 |
ctx.save(); ctx.translate(s.x,s.y); ctx.rotate(s.rot); ctx.globalAlpha=s.al;
|
| 501 |
ctx.drawImage(TF_IMG.moss,-_sz/2,-_sz/2,_sz,_sz);
|
| 502 |
ctx.restore();
|
| 503 |
window.__tfMossDraws=(window.__tfMossDraws||0)+1;
|
|
|
|
| 504 |
}
|
| 505 |
}
|
| 506 |
if(slateReady()){
|
|
|
|
| 299 |
function pickMossSpots(){
|
| 300 |
const pts=[];
|
| 301 |
for(let r=0;r<=N;r++) for(let c=0;c<=N;c++)
|
| 302 |
+
pts.push({x:OX+c*(CELL+GAP),y:OY+r*(CELL+GAP),si:r,sj:c});
|
| 303 |
for(let i=pts.length-1;i>0;i--){ const j=(Math.random()*(i+1))|0; const t=pts[i]; pts[i]=pts[j]; pts[j]=t; }
|
| 304 |
+
return pts.slice(0,12).map(p=>({x:p.x,y:p.y,si:p.si,sj:p.sj,rot:Math.random()*6.283,sc:0.7+Math.random()*0.7,al:0.5+Math.random()*0.3}));
|
| 305 |
}
|
| 306 |
function tileAt(r,c){ return G.tiles.find(t=>t.r===r&&t.c===c&&!t.dead); }
|
| 307 |
function emptyCells(){
|
|
|
|
| 494 |
if(TF_OK.moss&&TF_IMG.moss.naturalWidth&&G.mossSpots){
|
| 495 |
const _el=(nowFx-G.startT)/1000;
|
| 496 |
const _tier=_el>180?2:(_el>60?1:0);
|
| 497 |
+
/* 青苔随砖块值高地增殖场景层(纯表现层:棋盘内已生成 ≥1024 的砖块所在行/列交叉格缝处青苔斑点密度+1 档("被大砖块滋养");加载失败跳过,不改逻辑) */
|
| 498 |
+
const _bigTiles=G.tiles.filter(t=>!t.dead&&t.v>=1024);
|
| 499 |
+
window.__tfMossBoosted=0; // 探针:本帧被大砖块滋养的斑点数
|
| 500 |
+
for(let i=0;i<12;i++){
|
| 501 |
+
const s=G.mossSpots[i];
|
| 502 |
+
let _nearBig=false;
|
| 503 |
+
for(const t of _bigTiles){ if((s.si===t.r||s.si===t.r+1)&&(s.sj===t.c||s.sj===t.c+1)){_nearBig=true;break;} }
|
| 504 |
+
const _req=Math.max(0,(i<4?0:(i<8?1:2))-(_nearBig?1:0));
|
| 505 |
+
if(_tier<_req) continue;
|
| 506 |
+
const _sz=58*s.sc;
|
| 507 |
ctx.save(); ctx.translate(s.x,s.y); ctx.rotate(s.rot); ctx.globalAlpha=s.al;
|
| 508 |
ctx.drawImage(TF_IMG.moss,-_sz/2,-_sz/2,_sz,_sz);
|
| 509 |
ctx.restore();
|
| 510 |
window.__tfMossDraws=(window.__tfMossDraws||0)+1;
|
| 511 |
+
if(_nearBig)window.__tfMossBoosted++;
|
| 512 |
}
|
| 513 |
}
|
| 514 |
if(slateReady()){
|
snake.html
CHANGED
|
@@ -169,6 +169,8 @@ const SN_HFL=new Image(); let SN_HFL_OK=false;
|
|
| 169 |
SN_HFL.onload=()=>{ SN_HFL_OK=true; };
|
| 170 |
SN_HFL.onerror=()=>{ SN_HFL_OK=false; };
|
| 171 |
SN_HFL.src='art/sn-hedge-flowers.webp';
|
|
|
|
|
|
|
| 172 |
/* 蒲公英绒伞随风漂移场景层(纯表现层:4 朵绒伞背景上层随时间横向漂移循环、纯时间驱动无状态;加载失败跳过;不改玩法/碰撞) */
|
| 173 |
const SN_FLUFF=new Image(); let SN_FLUFF_OK=false;
|
| 174 |
SN_FLUFF.onload=()=>{ SN_FLUFF_OK=true; };
|
|
@@ -413,29 +415,63 @@ function draw(){
|
|
| 413 |
ctx.restore();
|
| 414 |
}
|
| 415 |
/* 灌木篱花朵开放差异化(纯表现层:灌木篱贴图上叠加白/黄小花、随时间呼吸开合;加载失败跳过,不改玩法/碰撞) */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 416 |
if(SN_HFL_OK&&SN_HFL.naturalWidth){
|
| 417 |
window.__snakeHedgeFlowerDraws=(window.__snakeHedgeFlowerDraws||0);
|
| 418 |
-
|
|
|
|
|
|
|
| 419 |
for(let i=0;i<nx;i++){
|
| 420 |
const w=Math.min(tileW,COLS*CELL-i*tileW);
|
| 421 |
const _ph=_ft/1.4+i*1.7;
|
| 422 |
const _s=1+0.16*Math.sin(_ph); // 开合呼吸:纵向缩放
|
| 423 |
const _dh=HH*_s, _dy=HH-_dh;
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 428 |
}
|
| 429 |
-
for(const ex of [OX-HH/2,OX+COLS*CELL-HH/2]){
|
| 430 |
ctx.save(); ctx.translate(ex,OY); ctx.rotate(Math.PI/2);
|
| 431 |
for(let i=0;i<ny;i++){
|
| 432 |
const h=Math.min(tileW,ROWS*CELL-i*tileW);
|
| 433 |
const _ph=_ft/1.4+i*2.1+3.7;
|
| 434 |
const _s=1+0.16*Math.sin(_ph);
|
| 435 |
const _dh=HH*_s, _dy=HH-_dh;
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
}
|
| 440 |
ctx.restore();
|
| 441 |
}
|
|
|
|
| 169 |
SN_HFL.onload=()=>{ SN_HFL_OK=true; };
|
| 170 |
SN_HFL.onerror=()=>{ SN_HFL_OK=false; };
|
| 171 |
SN_HFL.src='art/sn-hedge-flowers.webp';
|
| 172 |
+
/* 花朵摇摆触发时间戳(模块级:tileKey -> 最近一次触发时间;蛇头在旁逗留时每 0.5s 补一次脉冲,离开后 0.5s 衰退) */
|
| 173 |
+
const FLOWER_SWAY_T={};
|
| 174 |
/* 蒲公英绒伞随风漂移场景层(纯表现层:4 朵绒伞背景上层随时间横向漂移循环、纯时间驱动无状态;加载失败跳过;不改玩法/碰撞) */
|
| 175 |
const SN_FLUFF=new Image(); let SN_FLUFF_OK=false;
|
| 176 |
SN_FLUFF.onload=()=>{ SN_FLUFF_OK=true; };
|
|
|
|
| 415 |
ctx.restore();
|
| 416 |
}
|
| 417 |
/* 灌木篱花朵开放差异化(纯表现层:灌木篱贴图上叠加白/黄小花、随时间呼吸开合;加载失败跳过,不改玩法/碰撞) */
|
| 418 |
+
/* 花朵随蛇经过轻微摇摆反馈(纯表现层:蛇头进入某块灌木篱花朵区 2 格内时该块花朵摇摆 0.5s(旋转±0.08 衰减),环境互动感;纯时间/距离驱动;不改玩法/碰撞) */
|
| 419 |
+
if(SN_HFL_OK&&SN_HFL.naturalWidth&&G.snake&&G.snake.length){
|
| 420 |
+
const _hx=G.snake[0].x,_hy=G.snake[0].y,_swNow=performance.now();
|
| 421 |
+
const _cd=(x0,x1,y0,y1)=>Math.max(0,x0-_hx,_hx-x1,y0-_hy,_hy-y1); // 蛇头到格矩形的切比雪夫距离
|
| 422 |
+
const _trg=(key)=>{ if(FLOWER_SWAY_T[key]===undefined||_swNow-FLOWER_SWAY_T[key]>500) FLOWER_SWAY_T[key]=_swNow; }; // 每 0.5s 最多补一脉冲
|
| 423 |
+
for(let i=0;i<nx;i++){
|
| 424 |
+
const w=Math.min(tileW,COLS*CELL-i*tileW),x0=i*tileW/CELL,x1=(i*tileW+w)/CELL;
|
| 425 |
+
if(_cd(x0,x1,-1,1)<=2)_trg('T'+i);
|
| 426 |
+
if(_cd(x0,x1,ROWS-1,ROWS+1)<=2)_trg('B'+i);
|
| 427 |
+
}
|
| 428 |
+
for(let i=0;i<ny;i++){
|
| 429 |
+
const h=Math.min(tileW,ROWS*CELL-i*tileW),y0=i*tileW/CELL,y1=(i*tileW+h)/CELL;
|
| 430 |
+
if(_cd(-1,1,y0,y1)<=2)_trg('L'+i);
|
| 431 |
+
if(_cd(COLS-1,COLS+1,y0,y1)<=2)_trg('R'+i);
|
| 432 |
+
}
|
| 433 |
+
}
|
| 434 |
if(SN_HFL_OK&&SN_HFL.naturalWidth){
|
| 435 |
window.__snakeHedgeFlowerDraws=(window.__snakeHedgeFlowerDraws||0);
|
| 436 |
+
window.__snakeFlowerSwayN=0; // 探针:本帧摇摆中的花朵块数
|
| 437 |
+
const _ft=performance.now()/1000,_swT=performance.now();
|
| 438 |
+
const _swayRot=(key)=>{const t0=FLOWER_SWAY_T[key];if(t0===undefined)return 0;const a=(_swT-t0)/500;if(a>=1)return 0;window.__snakeFlowerSwayN++;return 0.08*Math.sin(a*Math.PI*3)*(1-a);};
|
| 439 |
for(let i=0;i<nx;i++){
|
| 440 |
const w=Math.min(tileW,COLS*CELL-i*tileW);
|
| 441 |
const _ph=_ft/1.4+i*1.7;
|
| 442 |
const _s=1+0.16*Math.sin(_ph); // 开合呼吸:纵向缩放
|
| 443 |
const _dh=HH*_s, _dy=HH-_dh;
|
| 444 |
+
for(const _sd of ['T','B']){
|
| 445 |
+
const _yy=_sd==='T'?OY-HH/2+_dy/2:OY+ROWS*CELL-HH/2+_dy/2;
|
| 446 |
+
const _rot=_swayRot(_sd+i);
|
| 447 |
+
if(_rot){ // 摇摆中:绕块中心旋转(纯表现层)
|
| 448 |
+
ctx.save(); ctx.globalAlpha=0.55+0.45*Math.abs(Math.sin(_ph*0.8));
|
| 449 |
+
ctx.translate(OX+i*tileW+w/2,_yy+_dh/2); ctx.rotate(_rot);
|
| 450 |
+
ctx.drawImage(SN_HFL,i*tileW,0,w,32,-w/2,-_dh/2,w,_dh); ctx.restore();
|
| 451 |
+
}else{
|
| 452 |
+
ctx.save(); ctx.globalAlpha=0.55+0.45*Math.abs(Math.sin(_ph*0.8));
|
| 453 |
+
ctx.drawImage(SN_HFL,i*tileW,0,w,32,OX+i*tileW,_yy,w,_dh); ctx.restore();
|
| 454 |
+
}
|
| 455 |
+
window.__snakeHedgeFlowerDraws++;
|
| 456 |
+
}
|
| 457 |
}
|
| 458 |
+
for(const [si,ex] of [['L',OX-HH/2],['R',OX+COLS*CELL-HH/2]]){
|
| 459 |
ctx.save(); ctx.translate(ex,OY); ctx.rotate(Math.PI/2);
|
| 460 |
for(let i=0;i<ny;i++){
|
| 461 |
const h=Math.min(tileW,ROWS*CELL-i*tileW);
|
| 462 |
const _ph=_ft/1.4+i*2.1+3.7;
|
| 463 |
const _s=1+0.16*Math.sin(_ph);
|
| 464 |
const _dh=HH*_s, _dy=HH-_dh;
|
| 465 |
+
const _rot=_swayRot(si+i);
|
| 466 |
+
if(_rot){
|
| 467 |
+
ctx.save(); ctx.globalAlpha=0.55+0.45*Math.abs(Math.sin(_ph*0.8));
|
| 468 |
+
ctx.translate(i*tileW+h/2,-HH/2+_dy/2+_dh/2); ctx.rotate(_rot);
|
| 469 |
+
ctx.drawImage(SN_HFL,i*tileW,0,h,32,-h/2,-_dh/2,h,_dh); ctx.restore();
|
| 470 |
+
}else{
|
| 471 |
+
ctx.save(); ctx.globalAlpha=0.55+0.45*Math.abs(Math.sin(_ph*0.8));
|
| 472 |
+
ctx.drawImage(SN_HFL,i*tileW,0,h,32,i*tileW,-HH/2+_dy/2,h,_dh); ctx.restore();
|
| 473 |
+
}
|
| 474 |
+
window.__snakeHedgeFlowerDraws++;
|
| 475 |
}
|
| 476 |
ctx.restore();
|
| 477 |
}
|
whack-a-mole.html
CHANGED
|
@@ -949,6 +949,18 @@ function draw(now){
|
|
| 949 |
ctx.save(); ctx.fillStyle='rgba(255,244,214,'+_glow.toFixed(4)+')';
|
| 950 |
ctx.fillRect(0,0,W,H); ctx.restore();
|
| 951 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 952 |
// 顶部装饰线
|
| 953 |
ctx.strokeStyle='rgba(255,215,94,.16)'; ctx.lineWidth=1;
|
| 954 |
ctx.beginPath(); ctx.moveTo(18,108,W-18,108); ctx.stroke();
|
|
|
|
| 949 |
ctx.save(); ctx.fillStyle='rgba(255,244,214,'+_glow.toFixed(4)+')';
|
| 950 |
ctx.fillRect(0,0,W,H); ctx.restore();
|
| 951 |
}}
|
| 952 |
+
/* 流星落地远处山头微光反射(纯表现层:流星最后 0.2s 在远山剪影区叠一层极淡暖白 alpha 0.04、结束后 0.5s 衰退,事件余波;纯 canvas;不改玩法/分值) */
|
| 953 |
+
/* 注:山头位置取自原远山剪影层几何(y=166-mtnH~166);当前背景若走 galaxy-bg 路径则山形已烘焙在背景里,反光落在同一位置 */
|
| 954 |
+
{const _mper2=window.__meteorPeriod||21,_mage2=(now/1000)%_mper2,_mdur2=0.9;let _mg=0;
|
| 955 |
+
if(_mage2<_mdur2){ if(_mdur2-_mage2<=0.2)_mg=0.04; }
|
| 956 |
+
else if(_mage2<_mdur2+0.5){ _mg=0.04*(1-(_mage2-_mdur2)/0.5); }
|
| 957 |
+
window.__meteorMtnGlowAlpha=_mg; // 探针:当前山头微光 alpha
|
| 958 |
+
if(_mg>0){
|
| 959 |
+
const _mtnH=Math.round(W*160/840);
|
| 960 |
+
ctx.save(); ctx.fillStyle='rgba(255,244,214,'+_mg.toFixed(4)+')';
|
| 961 |
+
ctx.fillRect(0,166-_mtnH,W,_mtnH); ctx.restore();
|
| 962 |
+
window.__meteorMtnGlowDraws=(window.__meteorMtnGlowDraws||0)+1;
|
| 963 |
+
}}
|
| 964 |
// 顶部装饰线
|
| 965 |
ctx.strokeStyle='rgba(255,215,94,.16)'; ctx.lineWidth=1;
|
| 966 |
ctx.beginPath(); ctx.moveTo(18,108,W-18,108); ctx.stroke();
|