Hot answers tagged

2

You don't need matrices at all. Just take the rotation angle in radians, get its cosine and sine, multiply them by the distance you want between the two objects and add the x and y values of the fixed object: rotatingObject.x = Math.cos(rotationAngle) * distance + fixedObject.x rotatingObject.y = Math.sin(rotationAngle) * distance + fixedObject.y


2

First , your polarToComponent(magnitude, angle) { return { x: magnitude * Math.cos(angle), y: magnitude * Math.sin(angle) }; Called for each ball at start time, introduce a numeric error. So you must calculate the total velocity before starting simulation and compare with that instead of 30. Second your function checkCollisions() ...


1

The gist of CCD is really nothing dazzling. Here's the description of a serial set-up (a chain of links and joints) you have an assembly of N joints and N links the first joint is called the root joint and has index 0 joint i defines the frame where the rigid body for link i has its geometry described in (it's easier since people usually select a local ...


1

Nothing in this code snippet makes a distinction between this tree vs. the tree the player is looking at. Unless that's what Camera_script.tree is supposed to do, but at long as that variable isn't null, the if-check will be true. I think what you want there is Camera_script.tree == this.tree


1

In Javascript, a property can also be a function. Don't make enemyType a string. Make it an object which has multiple methods for different interactions. violetThing = { name: "violet", sprite: "violetThing.png", onTouchFunction: setMagnetic, color: '#ffdd22' } yellowThing = { name: "yellow", sprite: "yellowThing.png", ...



Only top voted, non community-wiki answers of a minimum length are eligible