emmahogan / 225FinalProject

0 stars 0 forks source link

Gravity Issue #4

Closed Timothy-Ryan closed 4 years ago

Timothy-Ryan commented 4 years ago

Dr. Teresco, I seem to be having an issue with adding momentum to the rope simulation. When dragging the mouse around I can swing the rope around in a semi-realistic manner without issue, but as soon as the mouse stops moving the points also stop. I think this is because the 'previous' variables are only getting updated in the mouseDragged method, but I'm unsure as to what the best way to fix this would be. I'm trying some ideas I have, but if you know a solution please let me know. Thanks, Tim Ryan

jteresco commented 4 years ago

Anything you want to have happening outside of event handlers will need a thread. Here's an idea: have a thread that's responsible for all motion, running at whatever rate (30 per second?) seems to work. It can apply the gravity all the time, and the effects of mouse motion when the mouse is moving, maybe as simply as remembering the drag point and if it's been set since the last iteration of your gravity thread, it does what it would have done in response to your mouse event.

Timothy-Ryan commented 4 years ago

Dr. Teresco, I've created a new class that functions as an array for the segments while also running a Thread in order to make sure each 'previous' is being updated. It seems to have fixed the issue. Thanks for the advice, Tim Ryan

jteresco commented 4 years ago

Good!