gpt-4-0314· OpenAI
WildChat-4.8M (AI2)
一个考验反应力的游戏,600*600的方框,方框的中心是一个黑色的圆形按钮,如果鼠标快碰到圆形按钮时,圆形按钮就会逃走,但每次触发条件只会逃走一次。但逃走的位置绝对不会在鼠标的附…
- User
一个考验反应力的游戏,600*600的方框,方框的中心是一个黑色的圆形按钮,如果鼠标快碰到圆形按钮时,圆形按钮就会逃走,但每次触发条件只会逃走一次。但逃走的位置绝对不会在鼠标的附近或者与鼠标部分进行重叠。圆形按钮的活动范围只能在方框内,方框是边界,圆形按钮随机逃走的位置只能固定在方框之内,还有一个计分器,如果鼠标成功的点击到圆形按钮,便会加分,圆形按钮也会自动复位,以便开始下一局。
- Assistant
这个游戏可以通过简单的 JavaScript 和 HTML/CSS 制作。下面是一个简单的实现。
可以在 HTML 文件中创建一个 div,作为 iframe 元素的容器,设置大小和边界。
HTML 代码:
<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="styles.css" /> </head> <body> <div id="gameArea" onclick="increaseScore()"> <button id="circle" onmouseenter="moveButton()"></button> <p id="score">Score: 0</p> </div> <script src="scripts.js"></script> </body> </html>接下来,在 CSS 文件中设置 div 和按钮的样式。
CSS 代码:
body { display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; } #gameArea { position: relative; width: 600px; height: 600px; border: 1px solid black; background-color: #eee; } #circle { position: absolute; background-color: black; width: 50px; height: 50px; border-radius: 50%; } #score { position: absolute; bottom: 10px; left: 10px; font-size: 18px; }最后,在 JavaScript 文件中实现按钮的逃逸逻辑和计分器。
JavaScript 代码:
let circle = document.getElementById("circle"); let gameArea = document.getElementById("gameArea"); let scoreElement = document.getElementById("score"); let score = 0; function moveButton() { let newX = Math.floor(Math.random() * (gameArea.offsetWidth - circle.offsetWidth)); let newY = Math.floor(Math.random() * (gameArea.offsetHeight - circle.offsetHeight)); const buffer = 100; if (Math.abs(newX - event.clientX) < buffer) { if (newX + buffer < gameArea.offsetWidth) { newX += buffer; } else { newX -= buffer; } } if (Math.abs(newY - event.clientY) < buffer) { if (newY + buffer < gameArea.offsetHeight) { newY += buffer; } else { newY -= buffer; } } circle.style.left = newX + "px"; circle.style.top = newY + "px"; } function increaseScore() { score++; scoreElement.innerHTML = "Score: " + score; resetButtonPosition(); } function resetButtonPosition() { circle.style.left = "50%"; circle.style.top = "50%"; }将 HTML、CSS 和 JavaScript 文件一起运行,就可以启动这个测试反应力的游戏了。
请注意,这只是一个简单的实现,可以自行修改和优化代码以满足游戏效果要求。
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.