ui가 예쁜가위바위보 게임 즉석해서 만들어줘
- User
ui가 예쁜가위바위보 게임 즉석해서 만들어줘
Assistant
물론입니다! 간단하면서도 예쁜 UI를 가진 가위바위보 게임을 만들어 드리겠습니다. 이 게임은 HTML, CSS, 그리고 JavaScript를 사용하여 구현할 것입니다.
HTML 코드
<!DOCTYPE html> <html lang="ko"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>가위바위보 게임</title> <link rel="stylesheet" href="styles.css"> </head> <body> <div class="game-container"> <h1>가위바위보 게임</h1> <div class="choices"> <button class="choice" onclick="playGame('rock')">✊</button> <button class="choice" onclick="playGame('paper')">✋</button> <button class="choice" onclick="playGame('scissors')">✌️</button> </div> <div class="result"> <p id="resultText"></p> </div> </div> <script src="script.js"></script> </body> </html>CSS 코드 (styles.css)
body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background: linear-gradient(to right, #ff758c, #ff7eb3); font-family: 'Arial', sans-serif; } .game-container { text-align: center; background: white; padding: 20px; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); } h1 { margin-bottom: 20px; color: #ff758c; } .choices { display: flex; justify-content: center; margin-bottom: 20px; } .choice { background: #ff7eb3; border: none; color: white; padding: 20px; margin: 0 10px; border-radius: 5px; font-size: 2rem; cursor: pointer; transition: background 0.3s; } .choice:hover { background: #ff758c; } .result { margin-top: 20px; } #resultText { font-size: 1.5rem; color: #333; }JavaScript 코드 (script.js)
function getComputerChoice() { const choices = ['rock', 'paper', 'scissors']; const randomIndex = Math.floor(Math.random() * 3); return choices[randomIndex]; } function determineWinner(userChoice, computerChoice) { if (userChoice === computerChoice) { return "비겼습니다!"; } if ((userChoice === 'rock' && computerChoice === 'scissors') || (userChoice === 'paper' && computerChoice === 'rock') || (userChoice === 'scissors' && computerChoice === 'paper')) { return "사용자 승리!"; } else { return "컴퓨터 승리!"; } } function playGame(userChoice) { const computerChoice = getComputerChoice(); const result = determineWinner(userChoice, computerChoice); document.getElementById('resultText').textContent = `당신: ${userChoice}, 컴퓨터: ${computerChoice}\n${result}`; }이 코드를 복사하여 각각
index.html,styles.css,script.js파일에 붙여넣으면 됩니다. 브라우저에서index.html파일을 열면 가위바위보 게임을 할 수 있습니다. 간단하면서도 예쁜 UI를 가진 게임이 완성되었습니다!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.