Click here for free DL of the app version that can save data.
No:3561 1105
Prev Next
Nyamo Series
Developer sayaensm|Date and time 23/6/25 15:56:49
Build time 21.625 sec|Game capacity 2.4KB|Script

では、にゃもシリーズの一作「にゃもパターンズ」をお届けします。

このゲームは、画面内にランダムに表示されるにゃものパターンに合わせて、プレイヤーが指定された操作を行うというものです。

準備するものは、以下の通りです。

・HTMLファイル
・JavaScriptファイル
・CSSファイル

それでは、実際に動くプログラムを以下に記述します。


  
    
  
  
    

  


※HTMLは必要最低限の設定のみとなっています。


(function () {
    // キャンバス設定
    const canvas = document.getElementById('canvas');
    const ctx = canvas.getContext('2d');
    const width = window.innerWidth;
    const height = window.innerHeight;
  
    canvas.width = width;
    canvas.height = height;
  
    // パターン配列
    const patterns = [
      'にゃも、頭を左に傾けて座る',
      'にゃも、右足を上げて立つ',
      'にゃも、尻尾を広げて寝転がる',
      'にゃも、丸まって寝る',
      'にゃも、前足で体を支えて立つ'
    ];
  
    // ゲーム開始
    window.onload = function () {
      const startButton = document.getElementById('start-button');
  
      startButton.onclick = function () {
        ctx.clearRect(0, 0, width, height);
        const pattern = patterns[Math.floor(Math.random() * patterns.length)];
        ctx.fillText(pattern, width / 2, height / 2);
  
        // ゲーム指示
        const command = promptHisa('上のパターンに合わせて操作してください!', '');
  
        // パターン判定
        if (command === '合わせたらエンターを押してね!') {
          alertHisa('おめでとう!にゃもと同じパターンを作れました!');
        } else {
          alertHisa('残念!にゃものパターンと違います…');
        }
  
        // 再度挑戦する場合は再読み込み
        ;
      }
    }
  })();


※ゲームの詳しい説明は上記コメントをご覧ください。

以上のプログラムで、「にゃもパターンズ」が実装されております。ぜひお楽しみください!


*This prompt didn't get me into the game this time. Plz try to generate it a few times.
Prev Next   Back  0  2 Menu 

[PR]現在の新着人気ランキング

Click here for free DL of the app version that can save data.

(C)2023 HisashiApp