Skip to content

Commit 2950ba4

Browse files
Update cursor-interactions.cpp
1 parent 7d17197 commit 2950ba4

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

cursor-interactions/cursor-interactions.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -365,19 +365,30 @@ Thing randomMotion(Thing t) {
365365
tuple<Thing, Thing> handleCollision(Thing t1, Thing t2) { // handling collisions between objects
366366
float n = dist(t1.x, t1.y, t1.z, t2.x, t2.y, t2.z);
367367
if (n < (float)(t1.size + t2.size)) {
368-
float temp;
368+
if (t2.paused) {
369+
t1.vx = -t1.vx;
370+
t1.vy = -t1.vy;
371+
t1.vz = -t1.vz;
372+
}
373+
else if (t1.paused) {
374+
t2.vx = -t2.vx;
375+
t2.vy = -t2.vy;
376+
t2.vz = -t2.vz;
377+
}
378+
else {
379+
float temp;
369380

370-
temp = t1.vx;
371-
t1.vx = t2.vx;
372-
t2.vx = temp;
381+
temp = t1.vx;
382+
t1.vx = t2.vx;
383+
t2.vx = temp;
373384

374-
temp = t1.vy;
375-
t1.vy = t2.vy;
376-
t2.vy = temp;
385+
temp = t1.vy;
386+
t1.vy = t2.vy;
387+
t2.vy = temp;
377388

378-
temp = t1.vz;
379-
t1.vz = t2.vz;
380-
t2.vz = temp;
389+
temp = t1.vz;
390+
t1.vz = t2.vz;
391+
t2.vz = temp;
381392
}
382393
return make_tuple(t1, t2);
383394
}

0 commit comments

Comments
 (0)