我正在制作一个基本游戏。单击此圆圈时,我需要在屏幕上移动另一个随机位置。
剩下的游戏:https ://codepen.io/jtog95/pen/ExPbzvo
var circle = document.getElementById('circle');
var spaceWidth;
var spaceHeight;
initCircle();
function initCircle() {
spaceWidth = screen.height - circle.height;
spaceHeight = screen.width - circle.width;
circle.addEventListener('click', moveCircle)
}
function moveCircle(){
circle.style.top = Math.round(Math.random() * spaceWidth) + 'px';
circle.style.left = Math.round(Math.random() * spaceHeight) + 'px';
}
浮云间
慕田峪9158850
相关分类