Pull away from contacted walls
This commit is contained in:
@@ -119,3 +119,8 @@ Delete your `.sitegen_cache` file.
|
|||||||
* use sitecache with pandoc renderer
|
* use sitecache with pandoc renderer
|
||||||
* draft documents
|
* draft documents
|
||||||
* treesitter highlighting for moonscript
|
* treesitter highlighting for moonscript
|
||||||
|
|
||||||
|
--
|
||||||
|
|
||||||
|
- Bounce off corners algo
|
||||||
|
- Bounce off multiple simultaneous contacts
|
||||||
|
|||||||
@@ -515,6 +515,10 @@ const Move = (() => {
|
|||||||
const run = contact.edge.xb-contact.edge.xa;
|
const run = contact.edge.xb-contact.edge.xa;
|
||||||
|
|
||||||
drawLine(p.x - v.x, p.y - v.y, p.x, p.y, "blue"); // velocity vector
|
drawLine(p.x - v.x, p.y - v.y, p.x, p.y, "blue"); // velocity vector
|
||||||
|
console.log("velocity vector", v.x, v.y);
|
||||||
|
const det = v.x * rise - v.y * run;
|
||||||
|
console.log("DEEEEEEEETTTTTTTTTTTTTTT", det);
|
||||||
|
|
||||||
drawLine(contact.edge.xa, contact.edge.ya, contact.edge.xb, contact.edge.yb, "green"); // edge vector
|
drawLine(contact.edge.xa, contact.edge.ya, contact.edge.xb, contact.edge.yb, "green"); // edge vector
|
||||||
|
|
||||||
let newY;
|
let newY;
|
||||||
@@ -568,13 +572,15 @@ const Move = (() => {
|
|||||||
newY = prAvy - prBvy;
|
newY = prAvy - prBvy;
|
||||||
|
|
||||||
drawLine(p.x, p.y, p.x + vec2.rightNormal.x , p.y + vec2.rightNormal.y, "black"); // edge normal vector
|
drawLine(p.x, p.y, p.x + vec2.rightNormal.x , p.y + vec2.rightNormal.y, "black"); // edge normal vector
|
||||||
drawLine(p.x, p.y, p.x + newX , p.y + newY, "blue"); // bounced velocity vector
|
drawLine(p.x, p.y, p.x + newX, p.y + newY, "blue"); // bounced velocity vector
|
||||||
|
|
||||||
Velocity[entity_id] = { x: newX, y: newY };
|
if (det < 0) {
|
||||||
|
Velocity[entity_id] = { x: newX, y: newY };
|
||||||
// TODO can't set position without ball getting stuck
|
Position[entity_id] = contact.position;
|
||||||
// Position[entity_id] = { x: p.x, y: p.y };
|
} else {
|
||||||
// Position[entity_id] = contact.position;
|
Velocity[entity_id] = { x: v.x, y: v.y };
|
||||||
|
Position[entity_id] = { x: p.x, y: p.y };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Velocity[entity_id] = { x: v.x, y: v.y };
|
Velocity[entity_id] = { x: v.x, y: v.y };
|
||||||
@@ -664,7 +670,7 @@ function init() {
|
|||||||
started = false;
|
started = false;
|
||||||
const mult = 10;
|
const mult = 10;
|
||||||
|
|
||||||
s.position = { x: 0, y: 0 };
|
s.position = { x: 0, y: -10 };
|
||||||
// s.velocity = { x: 0, y: -10 };
|
// s.velocity = { x: 0, y: -10 };
|
||||||
// s.velocity = { x: 10, y: 20 };
|
// s.velocity = { x: 10, y: 20 };
|
||||||
s.velocity = { x: 0, y: 0 };
|
s.velocity = { x: 0, y: 0 };
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
Reference in New Issue
Block a user