Loading...
    • 開發者指南
    • API 參考
    • MCP
    • 資源
    • 發行說明
    Search...
    ⌘K

    資源

    overview詞彙表系統提示

    使用案例

    概述工單路由客戶支援代理內容審核法律文件摘要

    提示詞庫

    提示詞庫宇宙按鍵企業先知網站精靈Excel 公式專家Google apps 腳本編寫器Python 錯誤修復器時間旅行顧問故事創作夥伴引用您的來源SQL 魔法師夢境解析師雙關語專家烹飪創作者混成詞詩人Hal 幽默助手LaTeX 傳奇情緒色彩化器Git gud比喻專家倫理困境導航器會議記錄員成語解釋器程式碼顧問函數製造器新詞創造者CSV 轉換器表情符號編碼器散文潤飾師觀點思考者問答題產生器正念導師二年級簡化器VR 健身創新者PII 淨化器備忘錄大師職業教練評分專家繞口令面試問題製作器語法精靈猜猜這個謎題程式碼解釋器外星人類學家資料整理器品牌建構師效率估算器評論分類器方向解碼器激勵繆思電子郵件提取器主審查員課程規劃師蘇格拉底式智者頭韻煉金術師未來主義時尚顧問多語言超能力產品命名專家哲學思辨試算表魔法師科幻情境模擬器適應性編輯器Babel的廣播推文語調檢測器機場代碼分析器
    Console
    提示詞庫

    宇宙按鍵

    在單一 HTML 檔案中生成互動式速度打字遊戲,具有橫向捲動遊戲玩法和 Tailwind CSS 樣式。

    將此提示複製到我們的開發者 Console 中親自試試看!

    內容
    User為我寫一個完整的網頁應用程式,作為單一 HTML 檔案。該應用程式應包含一個簡單的橫向捲動遊戲,我使用 WASD 來移動。在世界中移動時,角色/精靈偶爾會遇到單字。當遇到單字時,玩家必須盡可能快速地正確輸入該單字。單字輸入成功的速度越快,玩家獲得的分數就越多。我們應該在右上角有一個計數器來追蹤分數。單字應該是隨機且高度變化的,以保持遊戲的趣味性。

    你應該讓網站非常美觀並使用 Tailwind。

    範例輸出

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <script src="https://cdn.tailwindcss.com"></script>
        <title>Side-Scrolling Typing Game</title>
      </head>
      <body class="bg-gray-900 text-white">
        <div class="fixed top-4 right-4 text-2xl">
          Score: <span id="score">0</span>
        </div>
        <div id="game" class="h-screen w-screen overflow-hidden relative">
          <div
            id="player"
            class="absolute bottom-10 left-10 w-8 h-8 bg-blue-500"
          ></div>
        </div>
        <div
          id="word-input"
          class="fixed top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 bg-white text-black p-4 rounded hidden"
        >
          <input
            type="text"
            id="typed-word"
            class="border border-gray-300 rounded px-2 py-1 mb-2 w-full"
          />
          <button id="submit-word" class="bg-blue-500 text-white px-4 py-2 rounded">
            Submit
          </button>
        </div>
        <script>
          const words = [
            'ability',
            'able',
            'about',
            'above',
            'accept',
            'according',
            'account',
            'across',
            'action',
            'activity',
            'actually',
            'address',
            'administration',
            'admit',
            'adult',
            'affect',
            'after',
            'again',
            'against',
            'agency',
            'agent',
            'ago',
            'agree',
            'agreement',
            'ahead',
            'air',
            'all',
            'allow',
            'almost',
            'alone',
            'along',
            'already',
            'also',
            'although',
            'always',
            'American',
            'among',
            'amount',
            'analysis',
            'and',
            'animal',
            'another',
            'answer',
            'any',
            'anyone',
            'anything',
            'appear',
            'apply',
            'approach',
            'area',
            'argue',
            'arm',
            'around',
            'arrive',
            'art',
            'article',
            'artist',
            'as',
            'ask',
            'assume',
            'at',
            'attack',
            'attention',
            'attorney',
            'audience',
            'author',
            'authority',
            'available',
            'avoid',
            'away',
            'baby',
            'back',
            'bad',
            'bag',
            'ball',
            'bank',
            'bar',
            'base',
            'be',
            'beat',
            'beautiful',
            'because',
            'become',
            'bed',
            'before',
            'begin',
            'behavior',
            'behind',
            'believe',
            'benefit',
            'best',
            'better',
            'between',
            'beyond',
            'big',
            'bill',
            'billion',
            'bit',
            'black',
            'blood',
            'blue',
            'board',
            'body',
            'book',
            'born',
            'both',
            'box',
            'boy',
            'break',
            'bring',
            'brother',
            'budget',
            'build',
            'building',
            'business',
            'but',
            'buy',
            'by',
            'call',
            'camera',
            'campaign',
          ];
    
          let score = 0;
          let currentWord;
          let startTime;
    
          const game = document.getElementById('game');
          const player = document.getElementById('player');
          const wordInput = document.getElementById('word-input');
          const typedWord = document.getElementById('typed-word');
          const submitWord = document.getElementById('submit-word');
          const scoreDisplay = document.getElementById('score');
    
          let playerX = 10;
          let playerY = game.offsetHeight - 50;
          const speed = 5;
    
          function placeWord() {
            const word = document.createElement('div');
            word.textContent = words[Math.floor(Math.random() * words.length)];
            word.className = 'absolute text-2xl';
            word.style.left = `${game.offsetWidth + 10}px`;
            word.style.top = `${Math.random() * (game.offsetHeight - 50)}px`;
            game.appendChild(word);
            return word;
          }
    
          function checkCollision(word) {
            const playerRect = player.getBoundingClientRect();
            const wordRect = word.getBoundingClientRect();
            return !(
              playerRect.right < wordRect.left ||
              playerRect.left > wordRect.right ||
              playerRect.bottom < wordRect.top ||
              playerRect.top > wordRect.bottom
            );
          }
    
          function startInput(word) {
            currentWord = word.textContent;
            wordInput.style.display = 'block';
            typedWord.value = '';
            typedWord.focus();
            startTime = Date.now();
          }
    
          function endInput() {
            wordInput.style.display = 'none';
            const endTime = Date.now();
            const elapsedTime = endTime - startTime;
            const timeBonus = Math.max(2000 - elapsedTime, 0);
            score += Math.round(1000 + timeBonus);
            scoreDisplay.textContent = score;
          }
    
          function checkInput() {
            if (typedWord.value === currentWord) {
              endInput();
            }
          }
    
          function gameLoop() {
            playerY = Math.max(
              0,
              Math.min(playerY, game.offsetHeight - player.offsetHeight)
            );
            playerX = Math.max(
              0,
              Math.min(playerX, game.offsetWidth - player.offsetWidth)
            );
            player.style.top = `${playerY}px`;
            player.style.left = `${playerX}px`;
    
            const words = Array.from(
              document.querySelectorAll('#game > div:not(#player)')
            );
            words.forEach((word) => {
              const currentLeft = parseInt(word.style.left);
              word.style.left = `${currentLeft - speed}px`;
              if (checkCollision(word)) {
                startInput(word);
              }
              if (currentLeft < -word.offsetWidth) {
                word.remove();
              }
            });
    
            if (Math.random() < 0.01) {
              placeWord();
            }
    
            requestAnimationFrame(gameLoop);
          }
    
          document.addEventListener('keydown', (e) => {
            if (e.key === 'w') playerY -= speed;
            if (e.key === 'a') playerX -= speed;
            if (e.key === 's') playerY += speed;
            if (e.key === 'd') playerX += speed;
          });
    
          typedWord.addEventListener('input', checkInput);
          submitWord.addEventListener('click', checkInput);
    
          gameLoop();
        </script>
      </body>
    </html>

    API 請求

    import anthropic
    
    client = anthropic.Anthropic(
        # defaults to os.environ.get("ANTHROPIC_API_KEY")
        api_key="my_api_key",
    )
    message = client.messages.create(
        model="claude-sonnet-4-5",
        max_tokens=2000,
        temperature=0,
        messages=[
            {
                "role": "user",
                "content": [
                    {
                        "type": "text",
                        "text": "Write me a fully complete web app as a single HTML file. The app should contain a simple side-scrolling game where I use WASD to move around.  When moving around the world, occasionally the character/sprite will encounter words. When a word is encountered, the player must correctly type the word as fast as possible.The faster the word is successfully typed, the more point the player gets. We should have a counter in the top-right to keep track of points. Words should be random and highly variable to keep the game interesting.  \n  \nYou should make the website very aesthetic and use Tailwind."
                    }
                ]
            }
        ]
    )
    print(message.content)
    • API 請求
    © 2025 ANTHROPIC PBC

    Products

    • Claude
    • Claude Code
    • Max plan
    • Team plan
    • Enterprise plan
    • Download app
    • Pricing
    • Log in

    Features

    • Claude and Slack
    • Claude in Excel

    Models

    • Opus
    • Sonnet
    • Haiku

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Claude Developer Platform

    • Overview
    • Developer docs
    • Pricing
    • Amazon Bedrock
    • Google Cloud’s Vertex AI
    • Console login

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Help and security

    • Availability
    • Status
    • Support center

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy

    Products

    • Claude
    • Claude Code
    • Max plan
    • Team plan
    • Enterprise plan
    • Download app
    • Pricing
    • Log in

    Features

    • Claude and Slack
    • Claude in Excel

    Models

    • Opus
    • Sonnet
    • Haiku

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Claude Developer Platform

    • Overview
    • Developer docs
    • Pricing
    • Amazon Bedrock
    • Google Cloud’s Vertex AI
    • Console login

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Help and security

    • Availability
    • Status
    • Support center

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy
    © 2025 ANTHROPIC PBC