Skip to content

Commit afa96c6

Browse files
committed
rah ouai
1 parent 0cbbe51 commit afa96c6

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/target
22
/node_modules
3-
/dis
3+
/dist

index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import('./pkg')
1111
world = wasm.World.new();
1212
world.add_object(0., -380., 40., -100., 20., 20., 0.8, false);
1313
world.add_object(-80., 0., 100., -400., 30., 30., 0.8, false);
14+
world.add_object(200., 300., 0., 0., 30., 30., 0.8, true);
1415
}
1516

1617
// Set world to the universal gravitation preset
@@ -23,9 +24,16 @@ import('./pkg')
2324
world.set_meter_size(0.001);
2425
}
2526

27+
function worldMultiCollision() {
28+
world = wasm.World.new();
29+
world.add_object(0., -380., 40., -100., 20., 20., 0.8, false);
30+
world.add_object(-200., 20., 0., 0., 30., 30., 0.8, false);
31+
}
32+
2633
let world_dictionary = {
2734
"collision": worldCollision,
28-
"universal": worldUniversal
35+
"universal": worldUniversal,
36+
2937
}
3038

3139
wolrd_preset_actual = document.getElementById("world_preset").value;

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,16 +170,16 @@ impl World {
170170

171171
if (obj.is_freeze) {
172172
let impulse = (2. * dot_product) / (distance * (obj_.mass + obj_.mass));
173-
let bounce_x = (impulse * obj_.mass * delta_x) / distance + restitution_coef * ((impulse * obj_.mass * delta_x) / distance);
174-
let bounce_y = (impulse * obj_.mass * delta_y) / distance + restitution_coef * ((impulse * obj_.mass * delta_y) / distance);
173+
let bounce_x = (impulse * obj_.mass * delta_x) / distance + restitution_coef * ((impulse * delta_x) / distance);
174+
let bounce_y = (impulse * obj_.mass * delta_y) / distance + restitution_coef * ((impulse * delta_y) / distance);
175175

176176
obj_.velocity_x -= bounce_x;
177177
obj_.velocity_y -= bounce_y;
178178
}
179179
else if (obj_.is_freeze) {
180180
let impulse = (2. * dot_product) / (distance * (obj.mass + obj.mass));
181-
let bounce_x = (impulse * obj.mass * delta_x) / distance + restitution_coef * ((impulse * obj.mass * delta_x) / distance);
182-
let bounce_y = (impulse * obj.mass * delta_y) / distance +restitution_coef * ((impulse * obj.mass * delta_y) / distance);
181+
let bounce_x = (impulse * obj.mass * delta_x) / distance + restitution_coef * ((impulse * delta_x) / distance);
182+
let bounce_y = (impulse * obj.mass * delta_y) / distance +restitution_coef * ((impulse * delta_y) / distance);
183183
obj.velocity_x += bounce_x;
184184
obj.velocity_y += bounce_y;
185185
}

0 commit comments

Comments
 (0)