JSFiddle - React, Tailwind, and code Playground
HTML
<!-- Load the simulation. -->
<script src="http://jeffcomput.es/static/js/physicsjs-full.js"></script>
<script src="http://jeffcomput.es/static/js/physics-ctrl-sim.js"></script>
SCSS
#viewport {
border: solid 1px #000;
}
JavaScript
// Enabling this will allow manual control of the square using the arrow keys.
// The `stepController()` function will be disabled.
var enableManual = false;
// The `angle` parameter is the angle off-center of the circle and square:
// 0.0 = circle directly above square
// -90.0 = circle completely to left of square
// 90.0 = circle completely to right of square
// The return value of this function is an acceleration applied to the square;
// positive values are to the right and negative to the left.
function stepController(angle) {
var accel = 0.0;
// Add your code here...
return accel;
}