WIP: bounce off walls
This commit is contained in:
@@ -126,7 +126,6 @@
|
||||
|
||||
<!-- <polygon class="wall" points="20,-50 10,-50 10,-60 20,-60" /> -->
|
||||
<!-- <polygon class="wall" points="-10,10 10,10 10,40 -10,40" /> -->
|
||||
<!-- <polygon class="wall" points="-10,10 10,20 -10,40 -20,20" /> -->
|
||||
<polygon class="wall" points="-10,10 10,30 -10,40 -20,20" />
|
||||
|
||||
<!-- <polygon class="wall" points="-20,-50 -10,-50 -10,-60 -20,-60" /> -->
|
||||
@@ -572,18 +571,21 @@ const Move = (() => {
|
||||
console.log("theta between edge vector and velocity vector", edgeTheta, "degrees", edgeTheta * 180 / Math.PI);
|
||||
console.log("theta between normal vector and velocity vector", normalTheta, "degrees", normalTheta * 180 / Math.PI);
|
||||
|
||||
const newTheta = (Math.PI - normalTheta) * 2;
|
||||
const newY = -Math.cos(newTheta) * velocityVectorMagnitude;
|
||||
const newX = Math.sin(newTheta) * velocityVectorMagnitude;
|
||||
|
||||
Velocity[entity_id] = {
|
||||
// x: v.x * Math.sin(thetaX) + v.y * Math.cos(thetaY),
|
||||
// y: v.y * Math.sin(thetaY) + v.x * Math.cos(thetaX)
|
||||
x: v.y,
|
||||
x: newX,
|
||||
// y: v.y * Math.sin(thetaY) + v.x * Math.cos(thetaX)
|
||||
y: 0
|
||||
y: newY
|
||||
};
|
||||
|
||||
console.log("VELOCITY AFTER", Velocity[entity_id]);
|
||||
|
||||
Position[entity_id] = { x: p.x, y: p.y };
|
||||
// Position[entity_id] = { x: p.x, y: p.y };
|
||||
// console.log("contact", contact.edge);
|
||||
// Position[entity_id] = contact.position;
|
||||
} else {
|
||||
|
||||
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
Reference in New Issue
Block a user