Javascript Shortcode Area
-----Version 110606-----
 asdf-j7 

<head>
<meta charset="UTF-8">
<title>Game</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Mono:wght@400&display=swap" rel="stylesheet">
<style>
body, tt, input, font, span {
font-family: "Noto Sans Mono", monospace;
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
}
/* ★★★ 修正点: tt#F に line-height を指定して行間を詰める ★★★ */
tt#F {
line-height: 1.0; /* まずは1.0を試します。これで詰まりすぎる場合は1.1や1.2に、まだ空きすぎる場合は0.9や0.85などに調整してください。 */
}
</style>
</head>
<body id ="gg" bgcolor=black text=white onKeyDown="K=event.keyCode-37">
<tt id=F style="font-size: 200%;">
<script>
// JavaScript部分は前回の修正から変更ありません
var D;
var j;
var C;

// R関数の無限ループ対策 と getElementByIdの使用
function R(H){
let S_val;
let attempts = 0;
const MAX_ATTEMPTS = 2000;
let found = false;
while(attempts < MAX_ATTEMPTS && !found) {
S_val = 40 + Math.ceil(ccc(0) * 319);
if (S_val < 0) S_val = 40;
if (S_val >= 360) S_val = 359;
let cellElement = D.getElementById("F"+S_val);
if (cellElement && cellElement.innerHTML === C) {
I(S_val, H);
found = true;
}
attempts++;
}
}

// getElementByIdの使用
function I(T,H){
let targetElement;
if (T === "" || T === null || typeof T === 'undefined') {
targetElement = D.getElementById("F");
} else {
targetElement = D.getElementById("F"+String(T));
}
if (targetElement) {
targetElement.innerHTML = H;
}
}
function ccc(cc){j=j+1;a=Math.sin((cc+0.1+j/100)/24);a=""+a;b=a.slice(-8,-2);a=eval(b)/1000000;return a}
function HT(event) {tX =event.touches[0].clientX;K=0;if(tX > window.innerWidth/2){K=2;}}

function Y(){
if(K+1){M=[-1,0,1,0][K];}Z=P;P=P+M;
if (P < 0 || P >= 400) P = Z;
let P_below = P + 20;
if (P_below < 0 || P_below >= 400) P_below = P;

let cellP = D.getElementById("F"+P);
let cellP_below = D.getElementById("F"+P_below);
X = cellP ? cellP.innerHTML : "";
XX = cellP_below ? cellP_below.innerHTML : "";

if(XX===C && M===0){P=P+20;}
if(X===O || XX===O){alert("GAME OVER SCORE: "+SC*10); clearTimeout(ID); return;}
if(X===T || XX===T){KY=1;Q="<font color=\"Purple\" style=\"font-size: inherit;\">●</font>";P=P+20;}
if(X===U || XX===U){if(KY===1){SC++;YY();}else{P=P-20;}}
if(X===W){P=P-M;}
if(X===N || XX===N){
P=P-(20*6);
while(P<0){P=P+20;}
let attempts = 0;
let landed = false;
while(attempts < 20 && P >= 0){
let landingCell = D.getElementById("F"+P);
if(landingCell && landingCell.innerHTML === C){
landed = true;
break;
}
P=P-20;
attempts++;
}
if(!landed) P = Z;
}
if (P < 0 || P >= 400) P = Z;
I(Z,C);I(P,Q);K=-1;M=0;ID=setTimeout(Y,100);
}

function YY(){
D = document;
j = 0;
C = " ";
U="<font color=\"Lime\" style=\"font-size: inherit;\">門</font>";
Q="<font color=\"blue\" style=\"font-size: inherit;\">●</font>";
W="<font color=\"Maroon\" style=\"font-size: inherit;\">■</font>";
N="<font color=\"aqua\" style=\"font-size: inherit;\">=</font>";
O="<font color=\"white\" style=\"font-size: inherit;\">*</font>";
T="<font color=\"yellow\" style=\"font-size: inherit;\">ー</font>";
E="<INPUT TYPE=\"button\" VALUE=\"☆\" STYLE=\"font-size: inherit;\" ONCLICK=\"clearTimeout(ID);YYY()\">";
let S_board="";
for(let i=0;i<400;i++)
S_board+=(i%20?"":"<br>")+"<span id=F"+i+">"+((i+1)%20>1&&i<379?C:W)+"</span>";
I("",S_board);
for(let i=0;i<11;i++) R(N);
I("399",E);
for(let i=0;i<(2+SC);i++) R(O);
for(let i=0;i<2;i++){
let S_val = Math.ceil(360+ccc(i)*18);
if (S_val < 360) S_val = 360;
if (S_val >= 400) S_val = 399;
I(String(S_val),N);
}
R(U);
R(T);
KY=0;
let gg_element = D.getElementById("gg");
if (gg_element) {
gg_element.addEventListener("touchmove", HT, {passive: true});
}
}

function YYY(){
window.SC = 0;
window.K = -1;
window.M = 0;
window.P = 370;
window.Z = 370;
window.KY = 0;
window.ID = null;
YY();
Y();
}
YYY();
</script>
</tt>
</body>
</html>


使用変数

a
attempts
b
bgcolor
C
ccc -------( Function )
cellElement
cellP
cellP_below
charset
color
D
E
family
found
gg_element
href
HT -------( Function )
I -------( Function )
i
id
ID
innerHTML
j
K
KY
landed
landingCell
M
MAX_ATTEMPTS
N
O
ONCLICK
onKeyDown
P
P_below
Q
R -------( Function )
rel
SC
style
STYLE
S_board
S_val
T
targetElement
text
tX
TYPE
U
VALUE
W
wght@400&display
X
XX
Y -------( Function )
YY -------( Function )
YYY -------( Function )
Z