以下が、球体が上下するゲームの実装例です。 ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>球体が上下するゲーム</title> <style> body { margin: 0; padding: 0; } canvas { display: block; } </style> </head> <body> <canvas id="canvas"></canvas> <script> // ジョークとして、円形の球体を「地球球体」と呼んでみました。 const earthSphere = { x: 100, y: 100, radius: 50, velocity: 5, direction: 1, color: "#00FFFF" }; const canvas = document.getElementById("canvas"); const context = canvas.getContext("2d"); function render() { // キャンバスをクリア context.clearRect(0, 0, canvas.width, canvas.height); // 球体を描画 context.beginPath(); context.arc(earthSphere.x, earthSphere.y, earthSphere.radius, 0, Math.PI * 2, true); context.closePath(); context.fillStyle = earthSphere.color; context.fill(); // 球体を上下移動 if (earthSphere.y + earthSphere.radius >= canvas.height) { // 上向きに移動するように方向を反転 earthSphere.direction = -1; } else if (earthSphere.y - earthSphere.radius <= 0) { // 下向きに移動するように方向を反転 earthSphere.direction = 1; } earthSphere.y += earthSphere.velocity * earthSphere.direction; // ループ処理 requestAnimationFrame(render); } // キャンバスの大きさを設定 canvas.width = 400; canvas.height = 400; // ループ処理を開始 render(); </script> </body> </html> ``` このゲームは、地球のような球体が画面上を上下に移動します。ユーザーの操作は不要で、ただ地球球体の上下移動を眺めるだけです。セキュリティ脆弱性があると判断されるevalや他のサイトへの遷移、リダイレクトなどは行っていません。