summaryrefslogtreecommitdiff
path: root/2d/rigidbody/rigidbody_1
diff options
context:
space:
mode:
Diffstat (limited to '2d/rigidbody/rigidbody_1')
-rwxr-xr-x2d/rigidbody/rigidbody_1/dist/output.wasmbin48801 -> 49033 bytes
-rw-r--r--2d/rigidbody/rigidbody_1/main.cpp7
-rw-r--r--2d/rigidbody/rigidbody_1/snippet3.cpp2
3 files changed, 4 insertions, 5 deletions
diff --git a/2d/rigidbody/rigidbody_1/dist/output.wasm b/2d/rigidbody/rigidbody_1/dist/output.wasm
index f6625a9..b9f4c37 100755
--- a/2d/rigidbody/rigidbody_1/dist/output.wasm
+++ b/2d/rigidbody/rigidbody_1/dist/output.wasm
Binary files differ
diff --git a/2d/rigidbody/rigidbody_1/main.cpp b/2d/rigidbody/rigidbody_1/main.cpp
index 88c322c..a327fee 100644
--- a/2d/rigidbody/rigidbody_1/main.cpp
+++ b/2d/rigidbody/rigidbody_1/main.cpp
@@ -61,8 +61,7 @@ struct Rigidbody {
float32 impulseDtSeconds = nextTimeAppliedSeconds - i.timeAppliedSeconds;
Vector2 forceToApply = i.force * (impulseDtSeconds / i.timeOfApplicationSeconds);
- force += forceToApply * impulseDtSeconds;
-
+ force += forceToApply;
i.timeAppliedSeconds = nextTimeAppliedSeconds;
}
@@ -301,8 +300,8 @@ EM_BOOL onMouseMove(int eventType, const EmscriptenMouseEvent *mouseEvent, void
return true;
}
- pointer.force.x = static_cast<float32>(mouseEvent->movementX) * 100000.f;
- pointer.force.y = static_cast<float32>(-mouseEvent->movementY) * 100000.f;
+ pointer.force.x = static_cast<float32>(mouseEvent->movementX) * 1000.f;
+ pointer.force.y = static_cast<float32>(-mouseEvent->movementY) * 1000.f;
pointer.body.position.x = static_cast<float32>(mouseEvent->targetX);
pointer.body.position.y = static_cast<float32>(600.f - mouseEvent->targetY);
diff --git a/2d/rigidbody/rigidbody_1/snippet3.cpp b/2d/rigidbody/rigidbody_1/snippet3.cpp
index 4727a9a..d3ecc4f 100644
--- a/2d/rigidbody/rigidbody_1/snippet3.cpp
+++ b/2d/rigidbody/rigidbody_1/snippet3.cpp
@@ -31,7 +31,7 @@ struct Rigidbody {
// to calculate the fractional amount of force that was applied in this frame.
float32 impulseDtSeconds = nextTimeAppliedSeconds - i.timeAppliedSeconds;
Vector2 forceToApply = i.force * (impulseDtSeconds / i.timeOfApplicationSeconds);
- force += forceToApply * impulseDtSeconds;
+ force += forceToApply;
i.timeAppliedSeconds = nextTimeAppliedSeconds;
}