Skip to content

jg-k/Elastic-collisions-in-Ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Elastic collision simulator

This is a useless but soothing elastic collision simulator using ruby and the ruby2d library.

You can just watch the balls colliding, or to be more active, you can also "grab" and release a ball with your mouse and force collisions with other balls.

Run:

Clone the repository, then in the folder, run:

$ ruby main.rb

In main.rb, you also specify input number of balls, positions and speed or let random numbers be generated.

Collision model

Screenshot

screenshot

Bugs and improvements

  • Sometimes, the collision detection and calculator are not accurate enough, such that to 2 (or more) balls can get locked into a romantic dance. Another collision with some other balls can sometimes break the dance!
  • The ball grab logic could be improved. sometimes balls get hidden behind the grabbed ball and never come out (also due to imprecise collision detection)
  • With user mouse control, if you move too fast, you "lose" the ball.
  • Add walls and random shapes
  • Make a game out of it

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages