很简单的给第一个初速度和加速度,小球做减速运动(当加速度为0时是匀速直线运动),碰撞到第二个小球,第二个小球继续做减速运动的模型,比较粗糙,希望能帮助到刚刚学习Js的小孩。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>小球碰撞</title>
</head>
<body>
<div id="blackBall" style="position:absolute;left:20px;top:50px;width:20px;height:20px;border-radius:50%;display:inline;background:black;"></div>
<div id="yellowBall" style="position:absolute;left:500px;top:50px;width:20px;height:20px;border-radius:50%;display:inline;background:yellow;">