JavaScript-demo-圆形碰撞检测

本文通过JavaScript演示如何进行圆形之间的碰撞检测。详细介绍了检测逻辑和源代码,适用于游戏开发或互动应用中的碰撞响应。
摘要由CSDN通过智能技术生成

source code:

<html>
	<head>
		<style>
			#circleA {
				background:red;
				width:100px;
				height:100px;
				border-radius:50px;
				position:absolute;
			}
			#circleB {
				background:green;
				width:100px;
				height:100px;
				border-radius:50px;
				position:absolute;
			}
		</style>
	</head>
	<body>
		<div id='textArea' style='font-size:30px;'>
			两个圆的圆心之间的距离 如果 小于两个圆的半径和 则 两个圆一定碰撞了!
		</div>
		<div id='circleA' style='left:500px; top:400px;'></div>
		<div id='circleB' style='left:300px; top:290px;'></div>
		<script>
			var circleACell = document.getElementById('circleA');
			var circleBCell = document.getElementById('circleB');
			var textAreaCell = document.getElementById('textArea');
			window.onmousemove = function(){
				var e = event
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值