0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

マウスでクリックしてる間だけ切り替わるおみくじ

Posted at

動作ページはこちら

もっと良い書き方、ゲーム的に面白くなるやり方があったら教えてくださいm(_ _)m

  <!DOCTYPE html>
  <html lang="ja">
  <head>
      <meta charset="UTF-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>おみくじ</title>

      <script>

        // おみくじの内容
const omikuji = ["大吉", "", "中吉", "小吉", "末吉", ""];
// おみくじの結果
let omikujiResult;

function setup() {
  createCanvas(300, 300);

  // 文字の基準点を上下左右の中央に
  textAlign(CENTER, CENTER);
  // 文字の大きさの設定
  textSize(100);

  // おみくじの結果をランダムにセット
  omikujiResult = random(omikuji);
}

function draw() {
  background("#e02020");

  fill("#FFFFFF");
  stroke("#FFFFFF");
  
  // おみくじの結果を表示
  text(omikujiResult, width / 2, height / 2);

  // クリックされている間の処理
  if (mouseIsPressed == true) {
    // おみくじの結果をランダムにセット
    omikujiResult = random(omikuji);
  }
}
    </script>

    </head>
  <body>
      
  </body>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/p5.js"></script>
  </html>
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?