Could you suggests some VueJS3 mini game?
- User
Could you suggests some VueJS3 mini game?
- Assistant
- User
Simon game seems good. Could you show me the sample code?
- Assistant
Sure, here's a simple example of a Simon Says game using Vue.js 3:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Simon Says Game</title> <style> .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; } .cell { width: 50px; height: 50px; background-color: #f0f0f0; display: flex; align-items: center; justify-content: center; font-size: 24px; cursor: pointer; } .cell.active { background-color: #00ff00; } </style> </head> <body> <div id="app"> <div class="grid" ref="grid"></div> <button @click="nextStep">Next Step</button> </div> <script src="https://unpkg.com/vue@next"></script> <script> const { createApp, ref } = Vue; const app = createApp({ setup() { const grid = ref(null); const steps = [ [{ row: 0, col: 0 }, { row: 0, col: 1 }], [{ row: 0, col: 1 }, { row: 1, col: 1 }], [{ row: 1, col: 1 }, { row: 1, col: 0 }], [{ row: 1, col: 0 }, { row: 0, col: 0 }], ]; let currentStep = 0; const handleClick = (row, col) => { const cell = grid.value.children[row * 3 + col]; cell.classList.toggle("active"); }; const nextStep = () => { currentStep++; if (currentStep >= steps.length) { alert("You've completed the game!"); return; } const step = steps[currentStep]; for (const { row, col } of step) { const cell = grid.value.children[row * 3 + col]; cell.classList.add("active"); } }; return { grid, handleClick, nextStep, }; }, }); app.mount("#app"); </script> </body> </html>
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.